aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/stdio/fgetws.c
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2002-09-18 05:58:11 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2002-09-18 05:58:11 +0000
commit24990dfad088db7073e30b8870d62366fb510cd3 (patch)
tree89b31678132bc76b873bf1bba095a04aa70ff775 /lib/libc/stdio/fgetws.c
parent11142c6f5488b60ab8109f8a90f2294266758078 (diff)
downloadsrc-24990dfad088db7073e30b8870d62366fb510cd3.tar.gz
src-24990dfad088db7073e30b8870d62366fb510cd3.zip
Notes
Diffstat (limited to 'lib/libc/stdio/fgetws.c')
-rw-r--r--lib/libc/stdio/fgetws.c13
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';