summaryrefslogtreecommitdiff
path: root/src/locale/newlocale.c
blob: 4e0cbd34072f23675cda75cf047dfc9fbace184d (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
#include <stdlib.h>
#include <string.h>
#include "locale_impl.h"
#include "libc.h"

locale_t __newlocale(int mask, const char *name, locale_t loc)
{
	int i;

	if (!loc) {
		loc = malloc(sizeof *loc);
		if (!loc) return 0;
		for (i=0; i<LC_ALL; i++)
			if (!(mask & (1<<i)))
				loc->cat[i] = __get_locale(i, "");
	}

	for (i=0; i<LC_ALL; i++)
		if (mask & (1<<i))
			loc->cat[i] = __get_locale(i, name);

	return loc;
}

weak_alias(__newlocale, newlocale);