fgetwc.c (ed04e0c3dcea4b07d73bda30b678beaf67829a67) | fgetwc.c (88eb1553b0d71ba5b89351e1e32221d7513cd4ae) |
---|---|
1/*- 2 * Copyright (c) 2002-2004 Tim J. Robbins. 3 * All rights reserved. 4 * 5 * Copyright (c) 2011 The FreeBSD Foundation 6 * All rights reserved. 7 * Portions of this software were developed by David Chisnall 8 * under sponsorship from the FreeBSD Foundation. --- 70 unchanged lines hidden (view full) --- 79 size_t nconv; 80 struct xlocale_ctype *l = XLOCALE_CTYPE(locale); 81 82 *nread = 0; 83 if (fp->_r <= 0 && __srefill(fp)) 84 return (WEOF); 85 do { 86 nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs); | 1/*- 2 * Copyright (c) 2002-2004 Tim J. Robbins. 3 * All rights reserved. 4 * 5 * Copyright (c) 2011 The FreeBSD Foundation 6 * All rights reserved. 7 * Portions of this software were developed by David Chisnall 8 * under sponsorship from the FreeBSD Foundation. --- 70 unchanged lines hidden (view full) --- 79 size_t nconv; 80 struct xlocale_ctype *l = XLOCALE_CTYPE(locale); 81 82 *nread = 0; 83 if (fp->_r <= 0 && __srefill(fp)) 84 return (WEOF); 85 do { 86 nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs); |
87 if (nconv == (size_t)-1) 88 break; 89 else if (nconv == (size_t)-2) | 87 if (nconv == (size_t)-1) { 88 fp->_flags |= __SERR; 89 return (WEOF); 90 } else if (nconv == (size_t)-2) |
90 continue; 91 else if (nconv == 0) { 92 fp->_p++; 93 fp->_r--; 94 (*nread)++; 95 return (L'\0'); 96 } else { 97 fp->_p += nconv; 98 fp->_r -= nconv; 99 *nread += nconv; 100 return (wc); 101 } 102 } while (__srefill(fp) == 0); | 91 continue; 92 else if (nconv == 0) { 93 fp->_p++; 94 fp->_r--; 95 (*nread)++; 96 return (L'\0'); 97 } else { 98 fp->_p += nconv; 99 fp->_r -= nconv; 100 *nread += nconv; 101 return (wc); 102 } 103 } while (__srefill(fp) == 0); |
103 fp->_flags |= __SERR; 104 errno = EILSEQ; | 104 if (__sfeof(fp)) { 105 fp->_flags |= __SERR; 106 errno = EILSEQ; 107 } |
105 return (WEOF); 106} | 108 return (WEOF); 109} |