Last change
on this file since 425 was 337, checked in by coas-nagasima, 6 years ago |
ASP3版ECNLを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
633 bytes
|
Rev | Line | |
---|
[337] | 1 | #include "stdio_impl.h"
|
---|
| 2 | #include "locale_impl.h"
|
---|
| 3 | #include <wchar.h>
|
---|
| 4 | #include <limits.h>
|
---|
| 5 | #include <ctype.h>
|
---|
| 6 | #include <string.h>
|
---|
| 7 |
|
---|
| 8 | wint_t ungetwc(wint_t c, FILE *f)
|
---|
| 9 | {
|
---|
| 10 | unsigned char mbc[MB_LEN_MAX];
|
---|
| 11 | int l;
|
---|
| 12 | locale_t *ploc = &CURRENT_LOCALE, loc = *ploc;
|
---|
| 13 |
|
---|
| 14 | FLOCK(f);
|
---|
| 15 |
|
---|
| 16 | if (f->mode <= 0) fwide(f, 1);
|
---|
| 17 | *ploc = f->locale;
|
---|
| 18 |
|
---|
| 19 | if (!f->rpos) __toread(f);
|
---|
| 20 | if (!f->rpos || c == WEOF || (l = wcrtomb((void *)mbc, c, 0)) < 0 ||
|
---|
| 21 | f->rpos < f->buf - UNGET + l) {
|
---|
| 22 | FUNLOCK(f);
|
---|
| 23 | *ploc = loc;
|
---|
| 24 | return WEOF;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | if (isascii(c)) *--f->rpos = c;
|
---|
| 28 | else memcpy(f->rpos -= l, mbc, l);
|
---|
| 29 |
|
---|
| 30 | f->flags &= ~F_EOF;
|
---|
| 31 |
|
---|
| 32 | FUNLOCK(f);
|
---|
| 33 | *ploc = loc;
|
---|
| 34 | return c;
|
---|
| 35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.