1 |
|
|
/* $OpenBSD: nl_langinfo.c,v 1.9 2017/09/05 03:16:13 schwarze Exp $ */ |
2 |
|
|
/* |
3 |
|
|
* Written by J.T. Conklin <jtc@netbsd.org>. |
4 |
|
|
* Public domain. |
5 |
|
|
*/ |
6 |
|
|
|
7 |
|
|
#include <locale.h> |
8 |
|
|
#include <nl_types.h> |
9 |
|
|
#include <langinfo.h> |
10 |
|
|
|
11 |
|
|
#include "localedef.h" |
12 |
|
|
#include "rune.h" |
13 |
|
|
#include "runetype.h" |
14 |
|
|
|
15 |
|
|
char * |
16 |
|
|
nl_langinfo(nl_item item) |
17 |
|
|
{ |
18 |
|
|
const char *s; |
19 |
|
|
|
20 |
|
|
switch (item) { |
21 |
|
|
case D_T_FMT: |
22 |
|
|
s = _CurrentTimeLocale->d_t_fmt; |
23 |
|
|
break; |
24 |
|
|
case D_FMT: |
25 |
|
|
s = _CurrentTimeLocale->d_fmt; |
26 |
|
|
break; |
27 |
|
|
case T_FMT: |
28 |
|
|
s = _CurrentTimeLocale->t_fmt; |
29 |
|
|
break; |
30 |
|
|
case T_FMT_AMPM: |
31 |
|
|
s = _CurrentTimeLocale->t_fmt_ampm; |
32 |
|
|
break; |
33 |
|
|
case AM_STR: |
34 |
|
|
case PM_STR: |
35 |
|
|
s = _CurrentTimeLocale->am_pm[item - AM_STR]; |
36 |
|
|
break; |
37 |
|
|
case DAY_1: |
38 |
|
|
case DAY_2: |
39 |
|
|
case DAY_3: |
40 |
|
|
case DAY_4: |
41 |
|
|
case DAY_5: |
42 |
|
|
case DAY_6: |
43 |
|
|
case DAY_7: |
44 |
|
|
s = _CurrentTimeLocale->day[item - DAY_1]; |
45 |
|
|
break; |
46 |
|
|
case ABDAY_1: |
47 |
|
|
case ABDAY_2: |
48 |
|
|
case ABDAY_3: |
49 |
|
|
case ABDAY_4: |
50 |
|
|
case ABDAY_5: |
51 |
|
|
case ABDAY_6: |
52 |
|
|
case ABDAY_7: |
53 |
|
|
s = _CurrentTimeLocale->abday[item - ABDAY_1]; |
54 |
|
|
break; |
55 |
|
|
case MON_1: |
56 |
|
|
case MON_2: |
57 |
|
|
case MON_3: |
58 |
|
|
case MON_4: |
59 |
|
|
case MON_5: |
60 |
|
|
case MON_6: |
61 |
|
|
case MON_7: |
62 |
|
|
case MON_8: |
63 |
|
|
case MON_9: |
64 |
|
|
case MON_10: |
65 |
|
|
case MON_11: |
66 |
|
|
case MON_12: |
67 |
|
|
s = _CurrentTimeLocale->mon[item - MON_1]; |
68 |
|
|
break; |
69 |
|
|
case ABMON_1: |
70 |
|
|
case ABMON_2: |
71 |
|
|
case ABMON_3: |
72 |
|
|
case ABMON_4: |
73 |
|
|
case ABMON_5: |
74 |
|
|
case ABMON_6: |
75 |
|
|
case ABMON_7: |
76 |
|
|
case ABMON_8: |
77 |
|
|
case ABMON_9: |
78 |
|
|
case ABMON_10: |
79 |
|
|
case ABMON_11: |
80 |
|
|
case ABMON_12: |
81 |
|
|
s = _CurrentTimeLocale->abmon[item - ABMON_1]; |
82 |
|
|
break; |
83 |
|
|
case RADIXCHAR: |
84 |
|
|
s = _CurrentNumericLocale->decimal_point; |
85 |
|
|
break; |
86 |
|
|
case THOUSEP: |
87 |
|
|
s = _CurrentNumericLocale->thousands_sep; |
88 |
|
|
break; |
89 |
|
|
case YESSTR: |
90 |
|
|
s = _CurrentMessagesLocale->yesstr; |
91 |
|
|
break; |
92 |
|
|
case YESEXPR: |
93 |
|
|
s = _CurrentMessagesLocale->yesexpr; |
94 |
|
|
break; |
95 |
|
|
case NOSTR: |
96 |
|
|
s = _CurrentMessagesLocale->nostr; |
97 |
|
|
break; |
98 |
|
|
case NOEXPR: |
99 |
|
|
s = _CurrentMessagesLocale->noexpr; |
100 |
|
|
break; |
101 |
|
|
case CRNCYSTR: /* XXX */ |
102 |
|
|
s = ""; |
103 |
|
|
break; |
104 |
|
|
case CODESET: |
105 |
|
|
s = _CurrentRuneLocale()->rl_codeset; |
106 |
|
|
if (!s) |
107 |
|
|
s = ""; |
108 |
|
|
break; |
109 |
|
|
default: |
110 |
|
|
s = ""; |
111 |
|
|
break; |
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
return (char *) s; |
115 |
|
|
} |
116 |
|
|
DEF_WEAK(nl_langinfo); |