mailing list of musl libc
 help / color / mirror / code / Atom feed
2bfb832bc7b4a0c30ad15eb5bc9196c86072d6d2 blob 1250 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "locale_impl.h"
#include "libc.h"

int __loc_is_allocated(locale_t loc)
{
	return loc && loc != C_LOCALE && loc != UTF8_LOCALE;
}

locale_t __newlocale(int mask, const char *name, locale_t loc)
{
	int i, j;
	struct __locale_struct tmp;
	const struct __locale_map *lm;

	/* For locales with allocated storage, modify in-place. */
	if (__loc_is_allocated(loc)) {
		for (i=0; i<LC_ALL; i++)
			if (mask & (1<<i))
				loc->cat[i] = __get_locale(i, name);
		return loc;
	}

	/* Otherwise, build a temporary locale object, which will only
	 * be instantiated in allocated storage if it does not match
	 * one of the built-in static locales. This makes the common
	 * usage case for newlocale, getting a C locale with predictable
	 * behavior, very fast, and more importantly, fail-safe. */
	for (j=i=0; i<LC_ALL; i++) {
		if (loc && !(mask & (1<<i)))
			lm = loc->cat[i];
		else
			lm = __get_locale(i, mask & (1<<i) ? name : "");
		if (lm) j++;
		tmp.cat[i] = lm;
	}

	if (!j)
		return C_LOCALE;
	if (j==1 && tmp.cat[LC_CTYPE]==&__c_dot_utf8)
		return UTF8_LOCALE;

	if ((loc = malloc(sizeof *loc))) *loc = tmp;
	else errno = ENOMEM;

	return loc;
}

weak_alias(__newlocale, newlocale);
debug log:

solving 2bfb832 ...
found 2bfb832 in https://inbox.vuxu.org/musl/52B93B58-3345-45E1-B108-C68AA212952F@gmail.com/
found f50bbe9 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 f50bbe9132df39445c642ea3215428b4b2b960d5	src/locale/newlocale.c

applying [1/1] https://inbox.vuxu.org/musl/52B93B58-3345-45E1-B108-C68AA212952F@gmail.com/
diff --git a/src/locale/newlocale.c b/src/locale/newlocale.c
index f50bbe9..2bfb832 100644

Checking patch src/locale/newlocale.c...
Applied patch src/locale/newlocale.c cleanly.

index at:
100644 2bfb832bc7b4a0c30ad15eb5bc9196c86072d6d2	src/locale/newlocale.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).