source: azure_iot_hub/trunk/musl-1.1.18/src/stdio/ungetwc.c@ 388

Last change on this file since 388 was 388, checked in by coas-nagasima, 5 years ago

Azure IoT Hub Device C SDK を使ったサンプルの追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 633 bytes
Line 
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
8wint_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.