diff --git a/lib/libc/stdio/fgetwc.c b/lib/libc/stdio/fgetwc.c index 14788d11ef91..8b2b626d0b1a 100644 --- a/lib/libc/stdio/fgetwc.c +++ b/lib/libc/stdio/fgetwc.c @@ -1,4 +1,4 @@ -/* $NetBSD: fgetwc.c,v 1.4 2005/06/12 05:21:27 lukem Exp $ */ +/* $NetBSD: fgetwc.c,v 1.5 2006/07/03 17:06:36 tnozaki Exp $ */ /*- * Copyright (c)2001 Citrus Project, @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fgetwc.c,v 1.4 2005/06/12 05:21:27 lukem Exp $"); +__RCSID("$NetBSD: fgetwc.c,v 1.5 2006/07/03 17:06:36 tnozaki Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -78,6 +78,7 @@ __fgetwc_unlock(FILE *fp) size = mbrtowc(&wc, &c, 1, st); if (size == (size_t)-1) { errno = EILSEQ; + fp->_flags |= __SERR; return WEOF; } } while (size == (size_t)-2); diff --git a/lib/libc/stdio/fgetws.c b/lib/libc/stdio/fgetws.c index 9b8efe84e750..c78ee5a792c2 100644 --- a/lib/libc/stdio/fgetws.c +++ b/lib/libc/stdio/fgetws.c @@ -1,4 +1,4 @@ -/* $NetBSD: fgetws.c,v 1.1 2003/03/07 07:11:37 tshiozak Exp $ */ +/* $NetBSD: fgetws.c,v 1.2 2006/07/03 17:06:36 tnozaki Exp $ */ /*- * Copyright (c) 2002 Tim J. Robbins. @@ -32,7 +32,7 @@ #include #if defined(LIB_SCCS) && !defined(lint) -__RCSID("$NetBSD: fgetws.c,v 1.1 2003/03/07 07:11:37 tshiozak Exp $"); +__RCSID("$NetBSD: fgetws.c,v 1.2 2006/07/03 17:06:36 tnozaki Exp $"); #endif #include @@ -64,10 +64,10 @@ fgetws(ws, n, fp) wsp = ws; while (n-- > 1) { - if ((wc = __fgetwc_unlock(fp)) == WEOF && errno == EILSEQ) { + wc = __fgetwc_unlock(fp); + if (__sferror(fp) != 0) goto error; - } - if (wc == WEOF) { + if (__sfeof(fp) != 0) { if (wsp == ws) { /* EOF/error, no characters read yet. */ goto error;