| OLD | NEW | 
|---|
| 1 #include "stdio_impl.h" | 1 #include "stdio_impl.h" | 
| 2 #include <wchar.h> | 2 #include <wchar.h> | 
| 3 | 3 | 
| 4 wint_t __fgetwc_unlocked(FILE *); | 4 wint_t __fgetwc_unlocked(FILE*); | 
| 5 | 5 | 
| 6 wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f) | 6 wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict f) { | 
| 7 { | 7   wchar_t* p = s; | 
| 8 »       wchar_t *p = s; |  | 
| 9 | 8 | 
| 10 »       if (!n--) return s; | 9   if (!n--) | 
|  | 10     return s; | 
| 11 | 11 | 
| 12 »       FLOCK(f); | 12   FLOCK(f); | 
| 13 | 13 | 
| 14 »       for (; n; n--) { | 14   for (; n; n--) { | 
| 15 »       »       wint_t c = __fgetwc_unlocked(f); | 15     wint_t c = __fgetwc_unlocked(f); | 
| 16 »       »       if (c == WEOF) break; | 16     if (c == WEOF) | 
| 17 »       »       *p++ = c; | 17       break; | 
| 18 »       »       if (c == '\n') break; | 18     *p++ = c; | 
| 19 »       } | 19     if (c == '\n') | 
| 20 »       *p = 0; | 20       break; | 
| 21 »       if (ferror(f)) p = s; | 21   } | 
|  | 22   *p = 0; | 
|  | 23   if (ferror(f)) | 
|  | 24     p = s; | 
| 22 | 25 | 
| 23 »       FUNLOCK(f); | 26   FUNLOCK(f); | 
| 24 | 27 | 
| 25 »       return (p == s) ? NULL : s; | 28   return (p == s) ? NULL : s; | 
| 26 } | 29 } | 
| 27 | 30 | 
| 28 weak_alias(fgetws, fgetws_unlocked); | 31 weak_alias(fgetws, fgetws_unlocked); | 
| OLD | NEW | 
|---|