mailing list of musl libc
 help / color / mirror / code / Atom feed
394f92ac9cba89474f74c00137a13cd53210e4b8 blob 517 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
#include "stdio_impl.h"
#include <wchar.h>
#include <limits.h>
#include <ctype.h>
#include <string.h>

wint_t ungetwc(wint_t c, FILE *f)
{
	unsigned char mbc[MB_LEN_MAX];
	int l=1;

	FLOCK(f);

	f->mode |= f->mode+1;

	if (!f->rpos) __toread(f);
	if (!f->rpos || f->rpos < f->buf - UNGET + l || c == WEOF ||
	    (!isascii(c) && (l = wctomb((void *)mbc, c)) < 0)) {
		FUNLOCK(f);
		return WEOF;
	}

	if (isascii(c)) *--f->rpos = c;
	else memcpy(f->rpos -= l, mbc, l);

	f->flags &= ~F_EOF;

	FUNLOCK(f);
	return c;
}
debug log:

solving 394f92a ...
found 394f92a in https://git.vuxu.org/mirror/musl/

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).