From ff89965e8b8722741c5d90e256ed4c3e6891e09a Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sat, 20 Jul 2013 22:17:26 +0000 Subject: [PATCH] fix fwscanf test (don't use wide and byte io in the same FILE) --- src/functional/fwscanf.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/functional/fwscanf.c b/src/functional/fwscanf.c index 3a96ae0..69a7bbf 100644 --- a/src/functional/fwscanf.c +++ b/src/functional/fwscanf.c @@ -17,12 +17,18 @@ static FILE *writetemp(const char *data) { FILE *f = tmpfile(); + size_t n = strlen(data); if (!f) return 0; - if (!fwrite(data, strlen(data), 1, f)) { + if (write(fileno(f), data, n) != n) { + t_error("write: %s\n", strerror(errno)); + fclose(f); + return 0; + } + if (lseek(fileno(f), 0, SEEK_SET) != 0) { + t_error("lseek: %s\n", strerror(errno)); fclose(f); return 0; } - rewind(f); return f; } -- 2.20.1