Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | #include "includes.h" | - |
24 | | - |
25 | #include <sys/types.h> | - |
26 | #ifdef HAVE_LANGINFO_H | - |
27 | # include <langinfo.h> | - |
28 | #endif | - |
29 | #include <limits.h> | - |
30 | #include <locale.h> | - |
31 | #include <stdarg.h> | - |
32 | #include <stdio.h> | - |
33 | #include <stdlib.h> | - |
34 | #include <string.h> | - |
35 | #if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H) && !defined(BROKEN_STRNVIS) | - |
36 | # include <vis.h> | - |
37 | #endif | - |
38 | #ifdef HAVE_WCHAR_H | - |
39 | # include <wchar.h> | - |
40 | #endif | - |
41 | | - |
42 | #include "utf8.h" | - |
43 | | - |
44 | static int dangerous_locale(void); | - |
45 | static int grow_dst(char **, size_t *, size_t, char **, size_t); | - |
46 | static int vasnmprintf(char **, size_t, int *, const char *, va_list); | - |
47 | | - |
48 | | - |
49 | | - |
50 | | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | | - |
59 | | - |
60 | static int | - |
61 | dangerous_locale(void) { | - |
62 | char *loc; | - |
63 | | - |
64 | loc = nl_langinfo(CODESET); | - |
65 | return strcmp(loc, "UTF-8") != 0 &&executed 21 times by 1 test: return __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( loc ) && __builtin_constant_p ( "UTF-8" ) && (__s1_len = __builtin_strlen ( loc ), __s2_len = __builtin_strlen ( "UTF-8" ), (!((size_t)(const void *)(( loc ) + 1) - (size_t)(const ...= 0) { __result = (((const unsigned char *) (const char *) ( "" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( "" ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( loc , "" )))); }) != 0; never executed: __result = (((const unsigned char *) (const char *) ( loc ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "UTF-8" ))[3] - __s2[3]); never executed: end of block never executed: end of block TRUE | evaluated 15 times by 1 test | FALSE | evaluated 6 times by 1 test |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0-21 |
66 | strcmp(loc, "US-ASCII") != 0 && executed 21 times by 1 test: return __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( loc ) && __builtin_constant_p ( "UTF-8" ) && (__s1_len = __builtin_strlen ( loc ), __s2_len = __builtin_strlen ( "UTF-8" ), (!((size_t)(const void *)(( loc ) + 1) - (size_t)(const ...= 0) { __result = (((const unsigned char *) (const char *) ( "" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( "" ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( loc , "" )))); }) != 0; never executed: __result = (((const unsigned char *) (const char *) ( loc ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "US-ASCII" ))[3] - __s2[3]); never executed: end of block never executed: end of block TRUE | evaluated 15 times by 1 test | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0-21 |
67 | strcmp(loc, "ANSI_X3.4-1968") != 0 && executed 21 times by 1 test: return __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( loc ) && __builtin_constant_p ( "UTF-8" ) && (__s1_len = __builtin_strlen ( loc ), __s2_len = __builtin_strlen ( "UTF-8" ), (!((size_t)(const void *)(( loc ) + 1) - (size_t)(const ...= 0) { __result = (((const unsigned char *) (const char *) ( "" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( "" ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( loc , "" )))); }) != 0; never executed: __result = (((const unsigned char *) (const char *) ( loc ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "ANSI_X3.4-1968" ))[3] - __s2[3]); never executed: end of block never executed: end of block TRUE | never evaluated | FALSE | evaluated 15 times by 1 test |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0-21 |
68 | strcmp(loc, "ISO8859-1") != 0 && executed 21 times by 1 test: return __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( loc ) && __builtin_constant_p ( "UTF-8" ) && (__s1_len = __builtin_strlen ( loc ), __s2_len = __builtin_strlen ( "UTF-8" ), (!((size_t)(const void *)(( loc ) + 1) - (size_t)(const ...= 0) { __result = (((const unsigned char *) (const char *) ( "" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( "" ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( loc , "" )))); }) != 0; never executed: __result = (((const unsigned char *) (const char *) ( loc ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "ISO8859-1" ))[3] - __s2[3]); never executed: end of block never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0-21 |
69 | strcmp(loc, "646") != 0 && executed 21 times by 1 test: return __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( loc ) && __builtin_constant_p ( "UTF-8" ) && (__s1_len = __builtin_strlen ( loc ), __s2_len = __builtin_strlen ( "UTF-8" ), (!((size_t)(const void *)(( loc ) + 1) - (size_t)(const ...= 0) { __result = (((const unsigned char *) (const char *) ( "" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( "" ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( loc , "" )))); }) != 0; never executed: __result = (((const unsigned char *) (const char *) ( loc ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "646" ))[3] - __s2[3]); never executed: end of block never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0-21 |
70 | strcmp(loc, "") != 0; executed 21 times by 1 test: return __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( loc ) && __builtin_constant_p ( "UTF-8" ) && (__s1_len = __builtin_strlen ( loc ), __s2_len = __builtin_strlen ( "UTF-8" ), (!((size_t)(const void *)(( loc ) + 1) - (size_t)(const ...= 0) { __result = (((const unsigned char *) (const char *) ( "" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( "" ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( loc , "" )))); }) != 0; never executed: __result = (((const unsigned char *) (const char *) ( loc ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "" ))[3] - __s2[3]); never executed: end of block never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0-21 |
71 | } | - |
72 | | - |
73 | static int | - |
74 | grow_dst(char **dst, size_t *sz, size_t maxsz, char **dp, size_t need) | - |
75 | { | - |
76 | char *tp; | - |
77 | size_t tsz; | - |
78 | | - |
79 | if (*dp + need < *dst + *sz)TRUE | evaluated 1188 times by 2 tests | FALSE | evaluated 10 times by 1 test |
| 10-1188 |
80 | return 0;executed 1188 times by 2 tests: return 0; | 1188 |
81 | tsz = *sz + 128; | - |
82 | if (tsz > maxsz)TRUE | evaluated 10 times by 1 test | FALSE | never evaluated |
| 0-10 |
83 | tsz = maxsz;executed 10 times by 1 test: tsz = maxsz; | 10 |
84 | if ((tp = recallocarray(*dst, *sz, tsz, 1)) == NULL)TRUE | never evaluated | FALSE | evaluated 10 times by 1 test |
| 0-10 |
85 | return -1; never executed: return -1; | 0 |
86 | *dp = tp + (*dp - *dst); | - |
87 | *dst = tp; | - |
88 | *sz = tsz; | - |
89 | return 0;executed 10 times by 1 test: return 0; | 10 |
90 | } | - |
91 | | - |
92 | | - |
93 | | - |
94 | | - |
95 | | - |
96 | | - |
97 | | - |
98 | | - |
99 | | - |
100 | | - |
101 | | - |
102 | | - |
103 | | - |
104 | static int | - |
105 | vasnmprintf(char **str, size_t maxsz, int *wp, const char *fmt, va_list ap) | - |
106 | { | - |
107 | char *src; | - |
108 | char *sp; | - |
109 | char *dst; | - |
110 | char *dp; | - |
111 | char *tp; | - |
112 | size_t sz; | - |
113 | wchar_t wc; | - |
114 | int len; | - |
115 | int ret; | - |
116 | int width; | - |
117 | int total_width, max_width, print; | - |
118 | | - |
119 | src = NULL; | - |
120 | if ((ret = vasprintf(&src, fmt, ap)) <= 0)TRUE | evaluated 2 times by 1 test | FALSE | evaluated 42 times by 2 tests |
| 2-42 |
121 | goto fail;executed 2 times by 1 test: goto fail; | 2 |
122 | | - |
123 | sz = strlen(src) + 1; | - |
124 | if ((dst = malloc(sz)) == NULL) {TRUE | never evaluated | FALSE | evaluated 42 times by 2 tests |
| 0-42 |
125 | free(src); | - |
126 | ret = -1; | - |
127 | goto fail; never executed: goto fail; | 0 |
128 | } | - |
129 | | - |
130 | if (maxsz > INT_MAX)TRUE | never evaluated | FALSE | evaluated 42 times by 2 tests |
| 0-42 |
131 | maxsz = INT_MAX; never executed: maxsz = 0x7fffffff; | 0 |
132 | | - |
133 | sp = src; | - |
134 | dp = dst; | - |
135 | ret = 0; | - |
136 | print = 1; | - |
137 | total_width = 0; | - |
138 | max_width = wp == NULL ? INT_MAX : *wp;TRUE | evaluated 32 times by 2 tests | FALSE | evaluated 10 times by 1 test |
| 10-32 |
139 | while (*sp != '\0') {TRUE | evaluated 1212 times by 2 tests | FALSE | evaluated 42 times by 2 tests |
| 42-1212 |
140 | if ((len = mbtowc(&wc, sp, MB_CUR_MAX)) == -1) {TRUE | evaluated 17 times by 1 test | FALSE | evaluated 1195 times by 2 tests |
| 17-1195 |
141 | (void)mbtowc(NULL, NULL, MB_CUR_MAX); | - |
142 | if (dangerous_locale()) {TRUE | never evaluated | FALSE | evaluated 17 times by 1 test |
| 0-17 |
143 | ret = -1; | - |
144 | break; never executed: break; | 0 |
145 | } | - |
146 | len = 1; | - |
147 | width = -1; | - |
148 | } else if (wp == NULL &&executed 17 times by 1 test: end of block TRUE | evaluated 1180 times by 2 tests | FALSE | evaluated 15 times by 1 test |
| 15-1180 |
149 | (wc == L'\n' || wc == L'\r' || wc == L'\t')) {TRUE | evaluated 14 times by 2 tests | FALSE | evaluated 1166 times by 2 tests |
TRUE | evaluated 2 times by 1 test | FALSE | evaluated 1164 times by 2 tests |
TRUE | evaluated 2 times by 1 test | FALSE | evaluated 1162 times by 2 tests |
| 2-1166 |
150 | | - |
151 | | - |
152 | | - |
153 | | - |
154 | | - |
155 | width = 0; | - |
156 | } else if ((width = wcwidth(wc)) == -1 &&executed 18 times by 2 tests: end of block TRUE | evaluated 4 times by 1 test | FALSE | evaluated 1173 times by 2 tests |
| 4-1173 |
157 | dangerous_locale()) {TRUE | never evaluated | FALSE | evaluated 4 times by 1 test |
| 0-4 |
158 | ret = -1; | - |
159 | break; never executed: break; | 0 |
160 | } | - |
161 | | - |
162 | | - |
163 | | - |
164 | if (width >= 0) {TRUE | evaluated 1191 times by 2 tests | FALSE | evaluated 21 times by 1 test |
| 21-1191 |
165 | if (print && (dp - dst >= (int)maxsz - len ||TRUE | evaluated 1191 times by 2 tests | FALSE | never evaluated |
TRUE | evaluated 2 times by 1 test | FALSE | evaluated 1189 times by 2 tests |
| 0-1191 |
166 | total_width > max_width - width))TRUE | evaluated 3 times by 1 test | FALSE | evaluated 1186 times by 2 tests |
| 3-1186 |
167 | print = 0;executed 5 times by 1 test: print = 0; | 5 |
168 | if (print) {TRUE | evaluated 1186 times by 2 tests | FALSE | evaluated 5 times by 1 test |
| 5-1186 |
169 | if (grow_dst(&dst, &sz, maxsz,TRUE | never evaluated | FALSE | evaluated 1186 times by 2 tests |
| 0-1186 |
170 | &dp, len) == -1) {TRUE | never evaluated | FALSE | evaluated 1186 times by 2 tests |
| 0-1186 |
171 | ret = -1; | - |
172 | break; never executed: break; | 0 |
173 | } | - |
174 | total_width += width; | - |
175 | memcpy(dp, sp, len); | - |
176 | dp += len; | - |
177 | }executed 1186 times by 2 tests: end of block | 1186 |
178 | sp += len; | - |
179 | if (ret >= 0)TRUE | evaluated 1191 times by 2 tests | FALSE | never evaluated |
| 0-1191 |
180 | ret += len;executed 1191 times by 2 tests: ret += len; | 1191 |
181 | continue;executed 1191 times by 2 tests: continue; | 1191 |
182 | } | - |
183 | | - |
184 | | - |
185 | | - |
186 | while (len > 0) {TRUE | evaluated 21 times by 1 test | FALSE | evaluated 21 times by 1 test |
| 21 |
187 | if (print && (dp - dst >= (int)maxsz - 4 ||TRUE | evaluated 18 times by 1 test | FALSE | evaluated 3 times by 1 test |
TRUE | evaluated 2 times by 1 test | FALSE | evaluated 16 times by 1 test |
| 2-18 |
188 | total_width > max_width - 4))TRUE | evaluated 4 times by 1 test | FALSE | evaluated 12 times by 1 test |
| 4-12 |
189 | print = 0;executed 6 times by 1 test: print = 0; | 6 |
190 | if (print) {TRUE | evaluated 12 times by 1 test | FALSE | evaluated 9 times by 1 test |
| 9-12 |
191 | if (grow_dst(&dst, &sz, maxsz,TRUE | never evaluated | FALSE | evaluated 12 times by 1 test |
| 0-12 |
192 | &dp, 4) == -1) {TRUE | never evaluated | FALSE | evaluated 12 times by 1 test |
| 0-12 |
193 | ret = -1; | - |
194 | break; never executed: break; | 0 |
195 | } | - |
196 | tp = vis(dp, *sp, VIS_OCTAL | VIS_ALL, 0); | - |
197 | width = tp - dp; | - |
198 | total_width += width; | - |
199 | dp = tp; | - |
200 | } elseexecuted 12 times by 1 test: end of block | 12 |
201 | width = 4;executed 9 times by 1 test: width = 4; | 9 |
202 | len--; | - |
203 | sp++; | - |
204 | if (ret >= 0)TRUE | evaluated 21 times by 1 test | FALSE | never evaluated |
| 0-21 |
205 | ret += width;executed 21 times by 1 test: ret += width; | 21 |
206 | }executed 21 times by 1 test: end of block | 21 |
207 | if (len > 0)TRUE | never evaluated | FALSE | evaluated 21 times by 1 test |
| 0-21 |
208 | break; never executed: break; | 0 |
209 | }executed 21 times by 1 test: end of block | 21 |
210 | free(src); | - |
211 | *dp = '\0'; | - |
212 | *str = dst; | - |
213 | if (wp != NULL)TRUE | evaluated 10 times by 1 test | FALSE | evaluated 32 times by 2 tests |
| 10-32 |
214 | *wp = total_width;executed 10 times by 1 test: *wp = total_width; | 10 |
215 | | - |
216 | | - |
217 | | - |
218 | | - |
219 | | - |
220 | | - |
221 | | - |
222 | | - |
223 | | - |
224 | if (ret < (int)maxsz && !print)TRUE | evaluated 38 times by 2 tests | FALSE | evaluated 4 times by 1 test |
TRUE | evaluated 7 times by 1 test | FALSE | evaluated 31 times by 2 tests |
| 4-38 |
225 | ret = -1;executed 7 times by 1 test: ret = -1; | 7 |
226 | return ret;executed 42 times by 2 tests: return ret; | 42 |
227 | | - |
228 | fail: | - |
229 | if (wp != NULL)TRUE | evaluated 2 times by 1 test | FALSE | never evaluated |
| 0-2 |
230 | *wp = 0;executed 2 times by 1 test: *wp = 0; | 2 |
231 | if (ret == 0) {TRUE | evaluated 2 times by 1 test | FALSE | never evaluated |
| 0-2 |
232 | *str = src; | - |
233 | return 0;executed 2 times by 1 test: return 0; | 2 |
234 | } else { | - |
235 | *str = NULL; | - |
236 | return -1; never executed: return -1; | 0 |
237 | } | - |
238 | } | - |
239 | | - |
240 | int | - |
241 | snmprintf(char *str, size_t sz, int *wp, const char *fmt, ...) | - |
242 | { | - |
243 | va_list ap; | - |
244 | char *cp; | - |
245 | int ret; | - |
246 | | - |
247 | va_start(ap, fmt); | - |
248 | ret = vasnmprintf(&cp, sz, wp, fmt, ap); | - |
249 | va_end(ap); | - |
250 | if (cp != NULL) {TRUE | evaluated 32 times by 1 test | FALSE | never evaluated |
| 0-32 |
251 | (void)strlcpy(str, cp, sz); | - |
252 | free(cp); | - |
253 | } elseexecuted 32 times by 1 test: end of block | 32 |
254 | *str = '\0'; never executed: *str = '\0'; | 0 |
255 | return ret;executed 32 times by 1 test: return ret; | 32 |
256 | } | - |
257 | | - |
258 | | - |
259 | | - |
260 | | - |
261 | | - |
262 | | - |
263 | int | - |
264 | vfmprintf(FILE *stream, const char *fmt, va_list ap) | - |
265 | { | - |
266 | char *str; | - |
267 | int ret; | - |
268 | | - |
269 | if ((ret = vasnmprintf(&str, INT_MAX, NULL, fmt, ap)) < 0)TRUE | never evaluated | FALSE | evaluated 12 times by 1 test |
| 0-12 |
270 | return -1; never executed: return -1; | 0 |
271 | if (fputs(str, stream) == EOF)TRUE | never evaluated | FALSE | evaluated 12 times by 1 test |
| 0-12 |
272 | ret = -1; never executed: ret = -1; | 0 |
273 | free(str); | - |
274 | return ret;executed 12 times by 1 test: return ret; | 12 |
275 | } | - |
276 | | - |
277 | int | - |
278 | fmprintf(FILE *stream, const char *fmt, ...) | - |
279 | { | - |
280 | va_list ap; | - |
281 | int ret; | - |
282 | | - |
283 | va_start(ap, fmt); | - |
284 | ret = vfmprintf(stream, fmt, ap); | - |
285 | va_end(ap); | - |
286 | return ret; never executed: return ret; | 0 |
287 | } | - |
288 | | - |
289 | int | - |
290 | mprintf(const char *fmt, ...) | - |
291 | { | - |
292 | va_list ap; | - |
293 | int ret; | - |
294 | | - |
295 | va_start(ap, fmt); | - |
296 | ret = vfmprintf(stdout, fmt, ap); | - |
297 | va_end(ap); | - |
298 | return ret;executed 12 times by 1 test: return ret; | 12 |
299 | } | - |
300 | | - |
301 | | - |
302 | | - |
303 | | - |
304 | | - |
305 | | - |
306 | | - |
307 | | - |
308 | | - |
309 | | - |
310 | void | - |
311 | msetlocale(void) | - |
312 | { | - |
313 | const char *vars[] = { "LC_ALL", "LC_CTYPE", "LANG", NULL }; | - |
314 | char *cp; | - |
315 | int i; | - |
316 | | - |
317 | | - |
318 | | - |
319 | | - |
320 | | - |
321 | for (i = 0; vars[i] != NULL; i++) {TRUE | evaluated 84 times by 1 test | FALSE | never evaluated |
| 0-84 |
322 | if ((cp = getenv(vars[i])) == NULL)TRUE | evaluated 56 times by 1 test | FALSE | evaluated 28 times by 1 test |
| 28-56 |
323 | continue;executed 56 times by 1 test: continue; | 56 |
324 | if (strncasecmp(cp, "TR", 2) != 0)TRUE | evaluated 28 times by 1 test | FALSE | never evaluated |
| 0-28 |
325 | break;executed 28 times by 1 test: break; | 28 |
326 | | - |
327 | | - |
328 | | - |
329 | | - |
330 | if ((strcasestr(cp, "UTF-8") != NULL ||TRUE | never evaluated | FALSE | never evaluated |
| 0 |
331 | strcasestr(cp, "UTF8") != NULL) &&TRUE | never evaluated | FALSE | never evaluated |
| 0 |
332 | (setlocale(LC_CTYPE, "C.UTF-8") != NULL ||TRUE | never evaluated | FALSE | never evaluated |
| 0 |
333 | setlocale(LC_CTYPE, "POSIX.UTF-8") != NULL))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
334 | return; never executed: return; | 0 |
335 | setlocale(LC_CTYPE, "C"); | - |
336 | return; never executed: return; | 0 |
337 | } | - |
338 | | - |
339 | setlocale(LC_CTYPE, ""); | - |
340 | }executed 28 times by 1 test: end of block | 28 |
| | |