File Coverage

ext/I18N-Langinfo/const-xs.inc
Criterion Covered Total %
statement 5 10 50.0
branch n/a
condition n/a
subroutine n/a
total 5 10 50.0


line stmt bran cond sub time code
1           BOOT:
2           {
3           #ifdef dTHX
4           dTHX;
5           #endif
6 4         HV *symbol_table = get_hv("I18N::Langinfo::", GV_ADD);
7            
8           static const struct iv_s values_for_iv[] =
9           {
10           #ifdef CODESET
11           { "CODESET", 7, CODESET },
12           #endif
13           #if defined(ABDAY_1) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
14           { "ABDAY_1", 7, ABDAY_1 },
15           #endif
16           #if defined(ABDAY_2) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
17           { "ABDAY_2", 7, ABDAY_2 },
18           #endif
19           #if defined(ABDAY_3) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
20           { "ABDAY_3", 7, ABDAY_3 },
21           #endif
22           #if defined(ABDAY_4) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
23           { "ABDAY_4", 7, ABDAY_4 },
24           #endif
25           #if defined(ABDAY_5) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
26           { "ABDAY_5", 7, ABDAY_5 },
27           #endif
28           #if defined(ABDAY_6) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
29           { "ABDAY_6", 7, ABDAY_6 },
30           #endif
31           #if defined(ABDAY_7) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
32           { "ABDAY_7", 7, ABDAY_7 },
33           #endif
34           #if defined(ABMON_1) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
35           { "ABMON_1", 7, ABMON_1 },
36           #endif
37           #if defined(ABMON_10) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
38           { "ABMON_10", 8, ABMON_10 },
39           #endif
40           #if defined(ABMON_11) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
41           { "ABMON_11", 8, ABMON_11 },
42           #endif
43           #if defined(ABMON_12) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
44           { "ABMON_12", 8, ABMON_12 },
45           #endif
46           #if defined(ABMON_2) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
47           { "ABMON_2", 7, ABMON_2 },
48           #endif
49           #if defined(ABMON_3) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
50           { "ABMON_3", 7, ABMON_3 },
51           #endif
52           #if defined(ABMON_4) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
53           { "ABMON_4", 7, ABMON_4 },
54           #endif
55           #if defined(ABMON_5) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
56           { "ABMON_5", 7, ABMON_5 },
57           #endif
58           #if defined(ABMON_6) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
59           { "ABMON_6", 7, ABMON_6 },
60           #endif
61           #if defined(ABMON_7) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
62           { "ABMON_7", 7, ABMON_7 },
63           #endif
64           #if defined(ABMON_8) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
65           { "ABMON_8", 7, ABMON_8 },
66           #endif
67           #if defined(ABMON_9) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
68           { "ABMON_9", 7, ABMON_9 },
69           #endif
70           #if defined(ALT_DIGITS) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
71           { "ALT_DIGITS", 10, ALT_DIGITS },
72           #endif
73           #if defined(AM_STR) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
74           { "AM_STR", 6, AM_STR },
75           #endif
76           #if defined(DAY_1) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
77           { "DAY_1", 5, DAY_1 },
78           #endif
79           #if defined(DAY_2) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
80           { "DAY_2", 5, DAY_2 },
81           #endif
82           #if defined(DAY_3) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
83           { "DAY_3", 5, DAY_3 },
84           #endif
85           #if defined(DAY_4) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
86           { "DAY_4", 5, DAY_4 },
87           #endif
88           #if defined(DAY_5) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
89           { "DAY_5", 5, DAY_5 },
90           #endif
91           #if defined(DAY_6) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
92           { "DAY_6", 5, DAY_6 },
93           #endif
94           #if defined(DAY_7) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
95           { "DAY_7", 5, DAY_7 },
96           #endif
97           #if defined(D_FMT) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
98           { "D_FMT", 5, D_FMT },
99           #endif
100           #if defined(D_T_FMT) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
101           { "D_T_FMT", 7, D_T_FMT },
102           #endif
103           #if defined(ERA) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
104           { "ERA", 3, ERA },
105           #endif
106           #if defined(ERA_D_FMT) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
107           { "ERA_D_FMT", 9, ERA_D_FMT },
108           #endif
109           #if defined(ERA_D_T_FMT) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
110           { "ERA_D_T_FMT", 11, ERA_D_T_FMT },
111           #endif
112           #if defined(ERA_T_FMT) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
113           { "ERA_T_FMT", 9, ERA_T_FMT },
114           #endif
115           #if defined(MON_1) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
116           { "MON_1", 5, MON_1 },
117           #endif
118           #if defined(MON_10) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
119           { "MON_10", 6, MON_10 },
120           #endif
121           #if defined(MON_11) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
122           { "MON_11", 6, MON_11 },
123           #endif
124           #if defined(MON_12) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
125           { "MON_12", 6, MON_12 },
126           #endif
127           #if defined(MON_2) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
128           { "MON_2", 5, MON_2 },
129           #endif
130           #if defined(MON_3) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
131           { "MON_3", 5, MON_3 },
132           #endif
133           #if defined(MON_4) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
134           { "MON_4", 5, MON_4 },
135           #endif
136           #if defined(MON_5) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
137           { "MON_5", 5, MON_5 },
138           #endif
139           #if defined(MON_6) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
140           { "MON_6", 5, MON_6 },
141           #endif
142           #if defined(MON_7) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
143           { "MON_7", 5, MON_7 },
144           #endif
145           #if defined(MON_8) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
146           { "MON_8", 5, MON_8 },
147           #endif
148           #if defined(MON_9) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
149           { "MON_9", 5, MON_9 },
150           #endif
151           #if defined(NOEXPR) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
152           { "NOEXPR", 6, NOEXPR },
153           #endif
154           #if defined(NOSTR) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
155           { "NOSTR", 5, NOSTR },
156           #endif
157           #if defined(PM_STR) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
158           { "PM_STR", 6, PM_STR },
159           #endif
160           #if defined(T_FMT) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
161           { "T_FMT", 5, T_FMT },
162           #endif
163           #if defined(T_FMT_AMPM) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
164           { "T_FMT_AMPM", 10, T_FMT_AMPM },
165           #endif
166           #if defined(YESEXPR) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
167           { "YESEXPR", 7, YESEXPR },
168           #endif
169           #if defined(YESSTR) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))
170           { "YESSTR", 6, YESSTR },
171           #endif
172           #if defined(CRNCYSTR) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM) && defined(__SVR4_I386_ABI_L1__))
173           { "CRNCYSTR", 8, CRNCYSTR },
174           #endif
175           #if defined(THOUSEP) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM) && defined(__SVR4_I386_ABI_L1__))
176           { "THOUSEP", 7, THOUSEP },
177           #endif
178           #if defined(RADIXCHAR) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM) && defined(__SVR4_I386_ABI_L1__))
179           { "RADIXCHAR", 9, RADIXCHAR },
180           #endif
181           { NULL, 0, 0 } };
182           const struct iv_s *value_for_iv = values_for_iv;
183 236         while (value_for_iv->name) {
184 228         constant_add_symbol(aTHX_ symbol_table, value_for_iv->name,
185           value_for_iv->namelen, newSViv(value_for_iv->value));
186 228         ++value_for_iv;
187           }
188           if (C_ARRAY_LENGTH(values_for_notfound) > 1) {
189           #ifndef SYMBIAN
190           HV *const constant_missing = get_missing_hash(aTHX);
191           #endif
192           const struct notfound_s *value_for_notfound = values_for_notfound;
193           do {
194            
195           /* Need to add prototypes, else parsing will vary by platform. */
196           HE *he = (HE*) hv_common_key_len(symbol_table,
197           value_for_notfound->name,
198           value_for_notfound->namelen,
199           HV_FETCH_LVALUE, NULL, 0);
200           SV *sv;
201           #ifndef SYMBIAN
202           HEK *hek;
203           #endif
204           if (!he) {
205           Perl_croak(aTHX_
206           "Couldn't add key '%s' to %%I18N::Langinfo::",
207           value_for_notfound->name);
208           }
209           sv = HeVAL(he);
210           if (!SvOK(sv) && SvTYPE(sv) != SVt_PVGV) {
211           /* Nothing was here before, so mark a prototype of "" */
212           sv_setpvn(sv, "", 0);
213           } else if (SvPOK(sv) && SvCUR(sv) == 0) {
214           /* There is already a prototype of "" - do nothing */
215           } else {
216           /* Someone has been here before us - have to make a real
217           typeglob. */
218           /* It turns out to be incredibly hard to deal with all the
219           corner cases of sub foo (); and reporting errors correctly,
220           so lets cheat a bit. Start with a constant subroutine */
221           CV *cv = newCONSTSUB(symbol_table,
222           value_for_notfound->name,
223           &PL_sv_yes);
224           /* and then turn it into a non constant declaration only. */
225           SvREFCNT_dec(CvXSUBANY(cv).any_ptr);
226           CvCONST_off(cv);
227           CvXSUB(cv) = NULL;
228           CvXSUBANY(cv).any_ptr = NULL;
229           }
230           #ifndef SYMBIAN
231           hek = HeKEY_hek(he);
232           if (!hv_common(constant_missing, NULL, HEK_KEY(hek),
233           HEK_LEN(hek), HEK_FLAGS(hek), HV_FETCH_ISSTORE,
234           &PL_sv_yes, HEK_HASH(hek)))
235           Perl_croak(aTHX_ "Couldn't add key '%s' to missing_hash",
236           value_for_notfound->name);
237           #endif
238           } while ((++value_for_notfound)->name);
239           }
240           /* As we've been creating subroutines, we better invalidate any cached
241           methods */
242 4         mro_method_changed_in(symbol_table);
243           }
244            
245           void
246           AUTOLOAD()
247           PROTOTYPE: DISABLE
248           PREINIT:
249 0         SV *sv = newSVpvn_flags(SvPVX(cv), SvCUR(cv), SVs_TEMP | SvUTF8(cv));
250 0         const COP *cop = PL_curcop;
251           PPCODE:
252           #ifndef SYMBIAN
253           /* It's not obvious how to calculate this at C pre-processor time.
254           However, any compiler optimiser worth its salt should be able to
255           remove the dead code, and hopefully the now-obviously-unused static
256           function too. */
257           HV *constant_missing = (C_ARRAY_LENGTH(values_for_notfound) > 1)
258           ? get_missing_hash(aTHX) : NULL;
259           if ((C_ARRAY_LENGTH(values_for_notfound) > 1)
260           ? hv_exists_ent(constant_missing, sv, 0) : 0) {
261           sv = newSVpvf("Your vendor has not defined I18N::Langinfo macro %" SVf
262           ", used at %" COP_FILE_F " line %d\n", sv,
263           COP_FILE(cop), CopLINE(cop));
264           } else
265           #endif
266           {
267 0         sv = newSVpvf("%"SVf" is not a valid I18N::Langinfo macro at %"
268 0         COP_FILE_F " line %d\n", sv, COP_FILE(cop), CopLINE(cop));
269           }
270 0         croak_sv(sv_2mortal(sv));