diff options
author | Tim J. Robbins <tjr@FreeBSD.org> | 2002-09-18 05:58:11 +0000 |
---|---|---|
committer | Tim J. Robbins <tjr@FreeBSD.org> | 2002-09-18 05:58:11 +0000 |
commit | 24990dfad088db7073e30b8870d62366fb510cd3 (patch) | |
tree | 89b31678132bc76b873bf1bba095a04aa70ff775 /lib/libc/stdio/fgetws.c | |
parent | 11142c6f5488b60ab8109f8a90f2294266758078 (diff) | |
download | src-24990dfad088db7073e30b8870d62366fb510cd3.tar.gz src-24990dfad088db7073e30b8870d62366fb510cd3.zip |
Reimplement the functionality of fgetrune(), fputrune(), and fungetrune()
here in terms of mbrtowc(), wcrtomb(), and the single-byte I/O functions.
The rune I/O functions are about to become deprecated in favour of the
ones provided by ISO C90 Amd. 1 and C99.
Notes
Notes:
svn path=/head/; revision=103523
Diffstat (limited to 'lib/libc/stdio/fgetws.c')
-rw-r--r-- | lib/libc/stdio/fgetws.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/libc/stdio/fgetws.c b/lib/libc/stdio/fgetws.c index 9d456a1dd894..d39b082ac51f 100644 --- a/lib/libc/stdio/fgetws.c +++ b/lib/libc/stdio/fgetws.c @@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include <errno.h> -#include <rune.h> #include <stdio.h> #include <wchar.h> #include "un-namespace.h" @@ -40,7 +39,7 @@ wchar_t * fgetws(wchar_t * __restrict ws, int n, FILE * __restrict fp) { wchar_t *wsp; - long r; + wint_t wc; ORIENTLOCK(fp, 1); @@ -50,18 +49,16 @@ fgetws(wchar_t * __restrict ws, int n, FILE * __restrict fp) wsp = ws; while (n-- > 1) { /* XXX Inefficient */ - if ((r = fgetrune(fp)) == _INVALID_RUNE) { - errno = EILSEQ; + if ((wc = fgetwc(fp)) == WEOF && errno == EILSEQ) return (NULL); - } - if (r == EOF) { + if (wc == WEOF) { if (wsp == ws) /* EOF/error, no characters read yet. */ return (NULL); break; } - *wsp++ = (wchar_t)r; - if (r == L'\n') + *wsp++ = (wchar_t)wc; + if (wc == L'\n') break; } *wsp++ = L'\0'; |