scc

A fork of https://git.simple-cc.org/scc/ for Qute

git clone https://git.8pit.net/scc.git

 1#include <limits.h>
 2#include <stdio.h>
 3#include <string.h>
 4#include <wchar.h>
 5
 6#undef fputwc
 7
 8wint_t
 9_fputwc(wchar_t wc, FILE *fp, int *np)
10{
11	int n;
12	char buf[MB_LEN_MAX];
13
14	if ((n = wcrtomb(buf, wc, &fp->mbs)) == -1)
15		goto err;
16	if (fwrite(buf, 1, n, fp) < n)
17		goto err;
18
19	if (np)
20		*np = n;
21
22	return wc;
23
24err:
25	fp->flags |= _IOERR;
26	return WEOF;
27}
28
29wint_t
30fputwc(wchar_t wc, FILE *fp)
31{
32	return _fputwc(wc, fp, NULL);
33}