SUSv3 said, if an encoding error occurs, the error indicator
for the stream shall be set.
This commit is contained in:
parent
daf99d36cd
commit
c98a8494d4
|
@ -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,
|
* Copyright (c)2001 Citrus Project,
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#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 */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -78,6 +78,7 @@ __fgetwc_unlock(FILE *fp)
|
||||||
size = mbrtowc(&wc, &c, 1, st);
|
size = mbrtowc(&wc, &c, 1, st);
|
||||||
if (size == (size_t)-1) {
|
if (size == (size_t)-1) {
|
||||||
errno = EILSEQ;
|
errno = EILSEQ;
|
||||||
|
fp->_flags |= __SERR;
|
||||||
return WEOF;
|
return WEOF;
|
||||||
}
|
}
|
||||||
} while (size == (size_t)-2);
|
} while (size == (size_t)-2);
|
||||||
|
|
|
@ -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.
|
* Copyright (c) 2002 Tim J. Robbins.
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#if defined(LIB_SCCS) && !defined(lint)
|
#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
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -64,10 +64,10 @@ fgetws(ws, n, fp)
|
||||||
|
|
||||||
wsp = ws;
|
wsp = ws;
|
||||||
while (n-- > 1) {
|
while (n-- > 1) {
|
||||||
if ((wc = __fgetwc_unlock(fp)) == WEOF && errno == EILSEQ) {
|
wc = __fgetwc_unlock(fp);
|
||||||
|
if (__sferror(fp) != 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
if (__sfeof(fp) != 0) {
|
||||||
if (wc == WEOF) {
|
|
||||||
if (wsp == ws) {
|
if (wsp == ws) {
|
||||||
/* EOF/error, no characters read yet. */
|
/* EOF/error, no characters read yet. */
|
||||||
goto error;
|
goto error;
|
||||||
|
|
Loading…
Reference in New Issue