diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 2016-08-27 10:00:36 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 2016-08-27 10:00:36 +0000 |
commit | 6caca4266a11cedca767362dec324e4883f8049f (patch) | |
tree | 8d272b2d5f945b483ed43a8308114e478103523b | |
parent | 47d23d393c1c11bedcaf0a9659954672b013272d (diff) |
Notes
-rw-r--r-- | lib/libc/stdio/getdelim.c | 4 | ||||
-rw-r--r-- | lib/libc/stdio/vfprintf.c | 6 | ||||
-rw-r--r-- | lib/libc/stdio/vfwprintf.c | 6 |
3 files changed, 14 insertions, 2 deletions
diff --git a/lib/libc/stdio/getdelim.c b/lib/libc/stdio/getdelim.c index d7d5627ec92f6..7e0b2e2b6edb6 100644 --- a/lib/libc/stdio/getdelim.c +++ b/lib/libc/stdio/getdelim.c @@ -125,7 +125,7 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim, if (fp->_r <= 0 && __srefill(fp)) { /* If fp is at EOF already, we just need space for the NUL. */ - if (__sferror(fp) || expandtofit(linep, 1, linecapp)) + if (!__sfeof(fp) || expandtofit(linep, 1, linecapp)) goto error; FUNLOCKFILE(fp); (*linep)[0] = '\0'; @@ -137,7 +137,7 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim, if (sappend(linep, &linelen, linecapp, fp->_p, fp->_r)) goto error; if (__srefill(fp)) { - if (__sferror(fp)) + if (!__sfeof(fp)) goto error; goto done; /* hit EOF */ } diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index e54e8acf00ff7..bf45bfb421ede 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -364,6 +364,7 @@ __vfprintf(FILE *fp, locale_t locale, const char *fmt0, va_list ap) int nextarg; /* 1-based argument index */ va_list orgap; /* original argument pointer */ char *convbuf; /* wide to multibyte conversion result */ + int savserr; static const char xdigs_lower[16] = "0123456789abcdef"; static const char xdigs_upper[16] = "0123456789ABCDEF"; @@ -460,6 +461,9 @@ __vfprintf(FILE *fp, locale_t locale, const char *fmt0, va_list ap) return (EOF); } + savserr = fp->_flags & __SERR; + fp->_flags &= ~__SERR; + convbuf = NULL; fmt = (char *)fmt0; argtable = NULL; @@ -1031,6 +1035,8 @@ error: free(convbuf); if (__sferror(fp)) ret = EOF; + else + fp->_flags |= savserr; if ((argtable != NULL) && (argtable != statargtable)) free (argtable); return (ret); diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c index b75c504b1e721..9a5381d54b9bb 100644 --- a/lib/libc/stdio/vfwprintf.c +++ b/lib/libc/stdio/vfwprintf.c @@ -444,6 +444,7 @@ __vfwprintf(FILE *fp, locale_t locale, const wchar_t *fmt0, va_list ap) int nextarg; /* 1-based argument index */ va_list orgap; /* original argument pointer */ wchar_t *convbuf; /* multibyte to wide conversion result */ + int savserr; static const char xdigs_lower[16] = "0123456789abcdef"; static const char xdigs_upper[16] = "0123456789ABCDEF"; @@ -536,6 +537,9 @@ __vfwprintf(FILE *fp, locale_t locale, const wchar_t *fmt0, va_list ap) return (EOF); } + savserr = fp->_flags & __SERR; + fp->_flags &= ~__SERR; + convbuf = NULL; fmt = (wchar_t *)fmt0; argtable = NULL; @@ -1096,6 +1100,8 @@ error: free(convbuf); if (__sferror(fp)) ret = EOF; + else + fp->_flags |= savserr; if ((argtable != NULL) && (argtable != statargtable)) free (argtable); return (ret); |