mailing list of musl libc
 help / color / mirror / code / Atom feed
8645e1121277a8d9ba1a3a7fdfe4537d9f5dc83c blob 807 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
31
 
#include <uchar.h>
#include <wchar.h>

__attribute__((__noinline__))
static size_t c8rtomb_slow(char *__restrict s, unsigned char c8, mbstate_t *__restrict st)
{
	// We need an internal state different from mbrtowc.
	static mbstate_t internal_state;
	if (!st) st = &internal_state;
	wchar_t wc;

	// mbrtowc has return values -2, -1, 0, 1.
	size_t res = mbrtowc(&wc, (char const*)&c8, 1, st);
	switch (res) {
	// our implementation of wcrtomb ignores the state
	case  1: res = wcrtomb(s, wc, 0); break;
	case  0: res = 1; if (s) *s = 0;  break;
	}
	return res;
}

static size_t __c8rtomb(char *__restrict s, unsigned char c8, mbstate_t *__restrict st)
{
        if (st && !*(unsigned*)st && (c8 < 0x80)) {
		if (s) *s = c8;
		return 1;
	}
	return c8rtomb_slow(s, c8, st);
}

weak_alias(__c8rtomb, c8rtomb);
debug log:

solving 8645e112 ...
found 8645e112 in https://inbox.vuxu.org/musl/976b592b08c82bd6b1f8834904071db6602f3885.1685534402.git.Jens.Gustedt@inria.fr/ ||
	https://inbox.vuxu.org/musl/a4faa3c9cef8b48d685f059ab8425ec3fd5087db.1684932960.git.Jens.Gustedt@inria.fr/

applying [1/2] https://inbox.vuxu.org/musl/976b592b08c82bd6b1f8834904071db6602f3885.1685534402.git.Jens.Gustedt@inria.fr/
diff --git a/src/multibyte/c8rtomb.c b/src/multibyte/c8rtomb.c
new file mode 100644
index 00000000..8645e112

Checking patch src/multibyte/c8rtomb.c...
Applied patch src/multibyte/c8rtomb.c cleanly.

skipping https://inbox.vuxu.org/musl/a4faa3c9cef8b48d685f059ab8425ec3fd5087db.1684932960.git.Jens.Gustedt@inria.fr/ for 8645e112
index at:
100644 8645e1121277a8d9ba1a3a7fdfe4537d9f5dc83c	src/multibyte/c8rtomb.c

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).