about summary refs log tree commit diff
path: root/src/locale/newlocale.c
blob: 39501d0c1b9a3305cbd2405e716dc06620d310c7 (plain) (blame)
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
#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 = calloc(1, sizeof *loc + LOCALE_NAME_MAX + 1);
		if (!loc) return 0;
		loc->messages_name = (void *)(loc+1);
		for (i=0; i<LC_ALL; i++)
			if (!(mask & (1<<i)))
				__setlocalecat(loc, i, "");
	}

	for (i=0; i<LC_ALL; i++)
		if (mask & (1<<i))
			__setlocalecat(loc, i, name);

	return loc;
}

weak_alias(__newlocale, newlocale);