summaryrefslogtreecommitdiff
path: root/src/stdlib/mbtowc.c
blob: c2780bf63be275bc148eed9e532bab6f9bdf585f (plain)
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
31
32
33
34
35
36
37
38
39
40
41
#include <stdlib.h>
#include "_stdlib.h"

/** convert a multibyte character to a wide character **/

int mbtowc(wchar_t * restrict pwc, const char * restrict s, size_t n)
{
	SIGNAL_SAFE(0);
	ASSERT_NOOVERLAP(pwc, sizeof(*pwc), s, n);

	/* FIXME: forward dependency on AMD1 */
	#if 0
	static mbstate_t ps = 0;
	return mbrtowc(pwc, s, n, &ps);
	#else
	(void)pwc; (void)s; (void)n;
	return 0;
	#endif
}

/***
converts the multibyte character, of no more than ARGUMENT(n) bytes, at
ARGUMENT(s) to a wide character, which is stored at the address pointed to by
ARGUMENT(pwc).

If ARGUMENT(s) is CONSTANT(NULL), THIS() tests whether multibyte encodings carry
state dependency.

If ARGUMENT(pwc) is CONSTANT(NULL), THIS() counts the number of bytes in the
multibyte character at ARGUMENT(s).
***/

/*
LC_CTYPE
RETURN(0, If ARGUMENT(s) is CONSTANT(NULL), multibyte encodings do not have state dependencies)
RETURN(NONZERO, If ARGUMENT(s) is CONSTANT(NULL), multibyte encodings do have state dependencies)
RETURN(-1, The ARGUMENT(n) bytes at ARGUMENT(s) do not form a valid mutlibyte character)
RETURN(0, ARGUMENT(s) points to a null character)
RETURN(TYPE(int), the number of bytes in the converted multibyte character)
STDC(1)
*/