1
#include <locale.h>
2
#include <string.h>
3
4
static char current_locale[] = "C";
5
6
static struct lconv c_locale = {
7
.decimal_point = ".",
8
.thousands_sep = "",
9
.grouping = "",
10
.int_curr_symbol = "",
11
.currency_symbol = "",
12
.mon_decimal_point = "",
13
.mon_thousands_sep = "",
14
.mon_grouping = "",
15
.positive_sign = "",
16
.negative_sign = "",
17
.int_frac_digits = (char)0xff,
18
.frac_digits = (char)0xff,
19
.p_cs_precedes = (char)0xff,
20
.p_sep_by_space = (char)0xff,
21
.n_cs_precedes = (char)0xff,
22
.n_sep_by_space = (char)0xff,
23
.p_sign_posn = (char)0xff,
24
.n_sign_posn = (char)0xff,
25
};
26
27
char *setlocale(int category, const char *locale) {
28
if (category < LC_ALL || category > LC_TIME) {
29
return NULL;
30
}31
32
if (!locale) {
33
return current_locale;
34
}35
36
if (!locale[0] || !strcmp(locale, "C") || !strcmp(locale, "POSIX")) {
37
current_locale[0] = 'C';
38
current_locale[1] = '\0';
39
return current_locale;
40
}41
42
return NULL;
43
}44
45
struct lconv *localeconv(void) {
46
return &c_locale;
47
}