fix fwscanf test (don't use wide and byte io in the same FILE)
[libc-test] / src / functional / fwscanf.c
index 3a96ae0..69a7bbf 100644 (file)
 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;
 }