fgetwc.c (24990dfad088db7073e30b8870d62366fb510cd3) fgetwc.c (bddc6280f25a0e47aacf5abec9f5094861dad18b)
1/*-
2 * Copyright (c) 2002 Tim J. Robbins.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 47 unchanged lines hidden (view full) ---

56 }
57 buf[n++] = (char)c;
58 memset(&mbs, 0, sizeof(mbs));
59 nconv = mbrtowc(&wc, buf, n, &mbs);
60 if (nconv == n)
61 return (wc);
62 else if (nconv == 0)
63 return (L'\0');
1/*-
2 * Copyright (c) 2002 Tim J. Robbins.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 47 unchanged lines hidden (view full) ---

56 }
57 buf[n++] = (char)c;
58 memset(&mbs, 0, sizeof(mbs));
59 nconv = mbrtowc(&wc, buf, n, &mbs);
60 if (nconv == n)
61 return (wc);
62 else if (nconv == 0)
63 return (L'\0');
64 else if (nconv == (size_t)-2 || nconv == (size_t)-1)
64 else if (nconv == (size_t)-1)
65 break;
66 }
67
68 while (n-- != 0)
69 ungetc((unsigned char)buf[n], fp);
70 errno = EILSEQ;
71 return (WEOF);
72}
65 break;
66 }
67
68 while (n-- != 0)
69 ungetc((unsigned char)buf[n], fp);
70 errno = EILSEQ;
71 return (WEOF);
72}