Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | #include <config.h> | - |
21 | | - |
22 | | - |
23 | #include "localcharset.h" | - |
24 | | - |
25 | #include <fcntl.h> | - |
26 | #include <stddef.h> | - |
27 | #include <stdio.h> | - |
28 | #include <string.h> | - |
29 | #include <stdlib.h> | - |
30 | | - |
31 | #if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET | - |
32 | # define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */ | - |
33 | #endif | - |
34 | | - |
35 | #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ | - |
36 | # define WINDOWS_NATIVE | - |
37 | # include <locale.h> | - |
38 | #endif | - |
39 | | - |
40 | #if defined __EMX__ | - |
41 | | - |
42 | # ifndef OS2 | - |
43 | # define OS2 | - |
44 | # endif | - |
45 | #endif | - |
46 | | - |
47 | #if !defined WINDOWS_NATIVE | - |
48 | # include <unistd.h> | - |
49 | # if HAVE_LANGINFO_CODESET | - |
50 | # include <langinfo.h> | - |
51 | # else | - |
52 | # if 0 /* see comment below */ | - |
53 | # include <locale.h> | - |
54 | # endif | - |
55 | # endif | - |
56 | # ifdef __CYGWIN__ | - |
57 | # define WIN32_LEAN_AND_MEAN | - |
58 | # include <windows.h> | - |
59 | # endif | - |
60 | #elif defined WINDOWS_NATIVE | - |
61 | # define WIN32_LEAN_AND_MEAN | - |
62 | # include <windows.h> | - |
63 | #endif | - |
64 | #if defined OS2 | - |
65 | # define INCL_DOS | - |
66 | # include <os2.h> | - |
67 | #endif | - |
68 | | - |
69 | | - |
70 | #if defined DARWIN7 | - |
71 | # include <xlocale.h> | - |
72 | #endif | - |
73 | | - |
74 | #if ENABLE_RELOCATABLE | - |
75 | # include "relocatable.h" | - |
76 | #else | - |
77 | # define relocate(pathname) (pathname) | - |
78 | # define relocate2(pathname,allocatedp) (*(allocatedp) = NULL, (pathname)) | - |
79 | #endif | - |
80 | | - |
81 | | - |
82 | #ifndef LIBDIR | - |
83 | # include "configmake.h" | - |
84 | #endif | - |
85 | | - |
86 | | - |
87 | #ifndef O_NOFOLLOW | - |
88 | # define O_NOFOLLOW 0 | - |
89 | #endif | - |
90 | | - |
91 | #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ | - |
92 | | - |
93 | # define ISSLASH(C) ((C) == '/' || (C) == '\\') | - |
94 | #endif | - |
95 | | - |
96 | #ifndef DIRECTORY_SEPARATOR | - |
97 | # define DIRECTORY_SEPARATOR '/' | - |
98 | #endif | - |
99 | | - |
100 | #ifndef ISSLASH | - |
101 | # define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) | - |
102 | #endif | - |
103 | | - |
104 | #if HAVE_DECL_GETC_UNLOCKED | - |
105 | # undef getc | - |
106 | # define getc getc_unlocked | - |
107 | #endif | - |
108 | | - |
109 | | - |
110 | | - |
111 | | - |
112 | | - |
113 | | - |
114 | | - |
115 | #if __STDC__ != 1 | - |
116 | # define volatile /* empty */ | - |
117 | #endif | - |
118 | | - |
119 | | - |
120 | | - |
121 | static const char * volatile charset_aliases; | - |
122 | | - |
123 | | - |
124 | static const char * | - |
125 | get_charset_aliases (void) | - |
126 | { | - |
127 | const char *cp; | - |
128 | | - |
129 | cp = charset_aliases; | - |
130 | if (cp == NULL)TRUE | evaluated 501 times by 58 testsEvaluated by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| FALSE | evaluated 1152 times by 58 testsEvaluated by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
|
| 501-1152 |
131 | { | - |
132 | #if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__ || defined OS2) | - |
133 | char *malloc_dir = NULL; | - |
134 | const char *dir; | - |
135 | const char *base = "charset.alias"; | - |
136 | char *file_name; | - |
137 | | - |
138 | | - |
139 | | - |
140 | dir = getenv ("CHARSETALIASDIR"); | - |
141 | if (dir == NULL || dir[0] == '\0')TRUE | evaluated 501 times by 58 testsEvaluated by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0-501 |
142 | dir = relocate2 (LIBDIR, &malloc_dir);executed 501 times by 58 tests: dir = (*(&malloc_dir) = ((void *)0) , ("/usr/local/lib")); Executed by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| 501 |
143 | | - |
144 | | - |
145 | { | - |
146 | size_t dir_len = strlen (dir); | - |
147 | size_t base_len = strlen (base); | - |
148 | int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));TRUE | evaluated 501 times by 58 testsEvaluated by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| FALSE | never evaluated |
TRUE | evaluated 501 times by 58 testsEvaluated by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| FALSE | never evaluated |
| 0-501 |
149 | file_name = (char *) malloc (dir_len + add_slash + base_len + 1); | - |
150 | if (file_name != NULL)TRUE | evaluated 501 times by 58 testsEvaluated by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| FALSE | never evaluated |
| 0-501 |
151 | { | - |
152 | memcpy (file_name, dir, dir_len); | - |
153 | if (add_slash)TRUE | evaluated 501 times by 58 testsEvaluated by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| FALSE | never evaluated |
| 0-501 |
154 | file_name[dir_len] = DIRECTORY_SEPARATOR;executed 501 times by 58 tests: file_name[dir_len] = '/'; Executed by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| 501 |
155 | memcpy (file_name + dir_len + add_slash, base, base_len + 1); | - |
156 | }executed 501 times by 58 tests: end of block Executed by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| 501 |
157 | } | - |
158 | | - |
159 | free (malloc_dir); | - |
160 | | - |
161 | if (file_name == NULL)TRUE | never evaluated | FALSE | evaluated 501 times by 58 testsEvaluated by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
|
| 0-501 |
162 | | - |
163 | cp = ""; never executed: cp = ""; | 0 |
164 | else | - |
165 | { | - |
166 | int fd; | - |
167 | | - |
168 | | - |
169 | | - |
170 | | - |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
175 | fd = open (file_name, | - |
176 | O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0)); | - |
177 | if (fd < 0)TRUE | evaluated 501 times by 58 testsEvaluated by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| FALSE | never evaluated |
| 0-501 |
178 | | - |
179 | cp = "";executed 501 times by 58 tests: cp = ""; Executed by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| 501 |
180 | else | - |
181 | { | - |
182 | FILE *fp; | - |
183 | | - |
184 | fp = fdopen (fd, "r"); | - |
185 | if (fp == NULL)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
186 | { | - |
187 | | - |
188 | close (fd); | - |
189 | cp = ""; | - |
190 | } never executed: end of block | 0 |
191 | else | - |
192 | { | - |
193 | | - |
194 | char *res_ptr = NULL; | - |
195 | size_t res_size = 0; | - |
196 | | - |
197 | for (;;) | - |
198 | { | - |
199 | int c; | - |
200 | char buf1[50+1]; | - |
201 | char buf2[50+1]; | - |
202 | size_t l1, l2; | - |
203 | char *old_res_ptr; | - |
204 | | - |
205 | c = getc (fp); | - |
206 | if (c == EOF)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
207 | break; never executed: break; | 0 |
208 | if (c == '\n' || c == ' ' || c == '\t')TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
209 | continue; never executed: continue; | 0 |
210 | if (c == '#')TRUE | never evaluated | FALSE | never evaluated |
| 0 |
211 | { | - |
212 | | - |
213 | do | - |
214 | c = getc (fp); never executed: c = getc_unlocked (fp); | 0 |
215 | while (!(c == EOF || c == '\n'));TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
216 | if (c == EOF)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
217 | break; never executed: break; | 0 |
218 | continue; never executed: continue; | 0 |
219 | } | - |
220 | ungetc (c, fp); | - |
221 | if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
222 | break; never executed: break; | 0 |
223 | l1 = strlen (buf1); | - |
224 | l2 = strlen (buf2); | - |
225 | old_res_ptr = res_ptr; | - |
226 | if (res_size == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
227 | { | - |
228 | res_size = l1 + 1 + l2 + 1; | - |
229 | res_ptr = (char *) malloc (res_size + 1); | - |
230 | } never executed: end of block | 0 |
231 | else | - |
232 | { | - |
233 | res_size += l1 + 1 + l2 + 1; | - |
234 | res_ptr = (char *) realloc (res_ptr, res_size + 1); | - |
235 | } never executed: end of block | 0 |
236 | if (res_ptr == NULL)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
237 | { | - |
238 | | - |
239 | res_size = 0; | - |
240 | free (old_res_ptr); | - |
241 | break; never executed: break; | 0 |
242 | } | - |
243 | strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); | - |
244 | strcpy (res_ptr + res_size - (l2 + 1), buf2); | - |
245 | } never executed: end of block | 0 |
246 | fclose (fp); | - |
247 | if (res_size == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
248 | cp = ""; never executed: cp = ""; | 0 |
249 | else | - |
250 | { | - |
251 | *(res_ptr + res_size) = '\0'; | - |
252 | cp = res_ptr; | - |
253 | } never executed: end of block | 0 |
254 | } | - |
255 | } | - |
256 | | - |
257 | free (file_name); | - |
258 | }executed 501 times by 58 tests: end of block Executed by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| 501 |
259 | | - |
260 | #else | - |
261 | | - |
262 | # if defined DARWIN7 | - |
263 | | - |
264 | | - |
265 | | - |
266 | cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" | - |
267 | "ISO8859-2" "\0" "ISO-8859-2" "\0" | - |
268 | "ISO8859-4" "\0" "ISO-8859-4" "\0" | - |
269 | "ISO8859-5" "\0" "ISO-8859-5" "\0" | - |
270 | "ISO8859-7" "\0" "ISO-8859-7" "\0" | - |
271 | "ISO8859-9" "\0" "ISO-8859-9" "\0" | - |
272 | "ISO8859-13" "\0" "ISO-8859-13" "\0" | - |
273 | "ISO8859-15" "\0" "ISO-8859-15" "\0" | - |
274 | "KOI8-R" "\0" "KOI8-R" "\0" | - |
275 | "KOI8-U" "\0" "KOI8-U" "\0" | - |
276 | "CP866" "\0" "CP866" "\0" | - |
277 | "CP949" "\0" "CP949" "\0" | - |
278 | "CP1131" "\0" "CP1131" "\0" | - |
279 | "CP1251" "\0" "CP1251" "\0" | - |
280 | "eucCN" "\0" "GB2312" "\0" | - |
281 | "GB2312" "\0" "GB2312" "\0" | - |
282 | "eucJP" "\0" "EUC-JP" "\0" | - |
283 | "eucKR" "\0" "EUC-KR" "\0" | - |
284 | "Big5" "\0" "BIG5" "\0" | - |
285 | "Big5HKSCS" "\0" "BIG5-HKSCS" "\0" | - |
286 | "GBK" "\0" "GBK" "\0" | - |
287 | "GB18030" "\0" "GB18030" "\0" | - |
288 | "SJIS" "\0" "SHIFT_JIS" "\0" | - |
289 | "ARMSCII-8" "\0" "ARMSCII-8" "\0" | - |
290 | "PT154" "\0" "PT154" "\0" | - |
291 | | - |
292 | "*" "\0" "UTF-8" "\0"; | - |
293 | # endif | - |
294 | | - |
295 | # if defined VMS | - |
296 | | - |
297 | | - |
298 | | - |
299 | | - |
300 | | - |
301 | cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" | - |
302 | "ISO8859-2" "\0" "ISO-8859-2" "\0" | - |
303 | "ISO8859-5" "\0" "ISO-8859-5" "\0" | - |
304 | "ISO8859-7" "\0" "ISO-8859-7" "\0" | - |
305 | "ISO8859-8" "\0" "ISO-8859-8" "\0" | - |
306 | "ISO8859-9" "\0" "ISO-8859-9" "\0" | - |
307 | | - |
308 | "eucJP" "\0" "EUC-JP" "\0" | - |
309 | "SJIS" "\0" "SHIFT_JIS" "\0" | - |
310 | "DECKANJI" "\0" "DEC-KANJI" "\0" | - |
311 | "SDECKANJI" "\0" "EUC-JP" "\0" | - |
312 | | - |
313 | "eucTW" "\0" "EUC-TW" "\0" | - |
314 | "DECHANYU" "\0" "DEC-HANYU" "\0" | - |
315 | "DECHANZI" "\0" "GB2312" "\0" | - |
316 | | - |
317 | "DECKOREAN" "\0" "EUC-KR" "\0"; | - |
318 | # endif | - |
319 | | - |
320 | # if defined WINDOWS_NATIVE || defined __CYGWIN__ | - |
321 | | - |
322 | | - |
323 | | - |
324 | | - |
325 | cp = "CP936" "\0" "GBK" "\0" | - |
326 | "CP1361" "\0" "JOHAB" "\0" | - |
327 | "CP20127" "\0" "ASCII" "\0" | - |
328 | "CP20866" "\0" "KOI8-R" "\0" | - |
329 | "CP20936" "\0" "GB2312" "\0" | - |
330 | "CP21866" "\0" "KOI8-RU" "\0" | - |
331 | "CP28591" "\0" "ISO-8859-1" "\0" | - |
332 | "CP28592" "\0" "ISO-8859-2" "\0" | - |
333 | "CP28593" "\0" "ISO-8859-3" "\0" | - |
334 | "CP28594" "\0" "ISO-8859-4" "\0" | - |
335 | "CP28595" "\0" "ISO-8859-5" "\0" | - |
336 | "CP28596" "\0" "ISO-8859-6" "\0" | - |
337 | "CP28597" "\0" "ISO-8859-7" "\0" | - |
338 | "CP28598" "\0" "ISO-8859-8" "\0" | - |
339 | "CP28599" "\0" "ISO-8859-9" "\0" | - |
340 | "CP28605" "\0" "ISO-8859-15" "\0" | - |
341 | "CP38598" "\0" "ISO-8859-8" "\0" | - |
342 | "CP51932" "\0" "EUC-JP" "\0" | - |
343 | "CP51936" "\0" "GB2312" "\0" | - |
344 | "CP51949" "\0" "EUC-KR" "\0" | - |
345 | "CP51950" "\0" "EUC-TW" "\0" | - |
346 | "CP54936" "\0" "GB18030" "\0" | - |
347 | "CP65001" "\0" "UTF-8" "\0"; | - |
348 | # endif | - |
349 | # if defined OS2 | - |
350 | | - |
351 | | - |
352 | | - |
353 | | - |
354 | | - |
355 | | - |
356 | | - |
357 | | - |
358 | | - |
359 | cp = "CP813" "\0" "ISO-8859-7" "\0" | - |
360 | "CP878" "\0" "KOI8-R" "\0" | - |
361 | "CP819" "\0" "ISO-8859-1" "\0" | - |
362 | "CP912" "\0" "ISO-8859-2" "\0" | - |
363 | "CP913" "\0" "ISO-8859-3" "\0" | - |
364 | "CP914" "\0" "ISO-8859-4" "\0" | - |
365 | "CP915" "\0" "ISO-8859-5" "\0" | - |
366 | "CP916" "\0" "ISO-8859-8" "\0" | - |
367 | "CP920" "\0" "ISO-8859-9" "\0" | - |
368 | "CP921" "\0" "ISO-8859-13" "\0" | - |
369 | "CP923" "\0" "ISO-8859-15" "\0" | - |
370 | "CP954" "\0" "EUC-JP" "\0" | - |
371 | "CP964" "\0" "EUC-TW" "\0" | - |
372 | "CP970" "\0" "EUC-KR" "\0" | - |
373 | "CP1089" "\0" "ISO-8859-6" "\0" | - |
374 | "CP1208" "\0" "UTF-8" "\0" | - |
375 | "CP1381" "\0" "GB2312" "\0" | - |
376 | "CP1386" "\0" "GBK" "\0" | - |
377 | "CP3372" "\0" "EUC-JP" "\0"; | - |
378 | # endif | - |
379 | #endif | - |
380 | | - |
381 | charset_aliases = cp; | - |
382 | }executed 501 times by 58 tests: end of block Executed by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| 501 |
383 | | - |
384 | return cp;executed 1653 times by 58 tests: return cp; Executed by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| 1653 |
385 | } | - |
386 | | - |
387 | | - |
388 | | - |
389 | | - |
390 | | - |
391 | | - |
392 | | - |
393 | #ifdef STATIC | - |
394 | STATIC | - |
395 | #endif | - |
396 | const char * | - |
397 | locale_charset (void) | - |
398 | { | - |
399 | const char *codeset; | - |
400 | const char *aliases; | - |
401 | | - |
402 | #if !(defined WINDOWS_NATIVE || defined OS2) | - |
403 | | - |
404 | # if HAVE_LANGINFO_CODESET | - |
405 | | - |
406 | | - |
407 | codeset = nl_langinfo (CODESET); | - |
408 | | - |
409 | # ifdef __CYGWIN__ | - |
410 | | - |
411 | | - |
412 | | - |
413 | if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) | - |
414 | { | - |
415 | const char *locale; | - |
416 | static char buf[2 + 10 + 1]; | - |
417 | | - |
418 | locale = getenv ("LC_ALL"); | - |
419 | if (locale == NULL || locale[0] == '\0') | - |
420 | { | - |
421 | locale = getenv ("LC_CTYPE"); | - |
422 | if (locale == NULL || locale[0] == '\0') | - |
423 | locale = getenv ("LANG"); | - |
424 | } | - |
425 | if (locale != NULL && locale[0] != '\0') | - |
426 | { | - |
427 | | - |
428 | | - |
429 | const char *dot = strchr (locale, '.'); | - |
430 | | - |
431 | if (dot != NULL) | - |
432 | { | - |
433 | const char *modifier; | - |
434 | | - |
435 | dot++; | - |
436 | | - |
437 | modifier = strchr (dot, '@'); | - |
438 | if (modifier == NULL) | - |
439 | return dot; | - |
440 | if (modifier - dot < sizeof (buf)) | - |
441 | { | - |
442 | memcpy (buf, dot, modifier - dot); | - |
443 | buf [modifier - dot] = '\0'; | - |
444 | return buf; | - |
445 | } | - |
446 | } | - |
447 | } | - |
448 | | - |
449 | | - |
450 | | - |
451 | | - |
452 | | - |
453 | | - |
454 | | - |
455 | | - |
456 | | - |
457 | | - |
458 | | - |
459 | | - |
460 | sprintf (buf, "CP%u", GetACP ()); | - |
461 | codeset = buf; | - |
462 | } | - |
463 | # endif | - |
464 | | - |
465 | # else | - |
466 | | - |
467 | | - |
468 | const char *locale = NULL; | - |
469 | | - |
470 | | - |
471 | | - |
472 | | - |
473 | | - |
474 | # if 0 | - |
475 | locale = setlocale (LC_CTYPE, NULL); | - |
476 | # endif | - |
477 | if (locale == NULL || locale[0] == '\0') | - |
478 | { | - |
479 | locale = getenv ("LC_ALL"); | - |
480 | if (locale == NULL || locale[0] == '\0') | - |
481 | { | - |
482 | locale = getenv ("LC_CTYPE"); | - |
483 | if (locale == NULL || locale[0] == '\0') | - |
484 | locale = getenv ("LANG"); | - |
485 | } | - |
486 | } | - |
487 | | - |
488 | | - |
489 | | - |
490 | | - |
491 | codeset = locale; | - |
492 | | - |
493 | # endif | - |
494 | | - |
495 | #elif defined WINDOWS_NATIVE | - |
496 | | - |
497 | static char buf[2 + 10 + 1]; | - |
498 | | - |
499 | | - |
500 | | - |
501 | | - |
502 | | - |
503 | | - |
504 | char *current_locale = setlocale (LC_ALL, NULL); | - |
505 | char *pdot; | - |
506 | | - |
507 | | - |
508 | | - |
509 | | - |
510 | if (strchr (current_locale, ';')) | - |
511 | current_locale = setlocale (LC_CTYPE, NULL); | - |
512 | | - |
513 | pdot = strrchr (current_locale, '.'); | - |
514 | if (pdot && 2 + strlen (pdot + 1) + 1 <= sizeof (buf)) | - |
515 | sprintf (buf, "CP%s", pdot + 1); | - |
516 | else | - |
517 | { | - |
518 | | - |
519 | | - |
520 | | - |
521 | | - |
522 | | - |
523 | | - |
524 | | - |
525 | sprintf (buf, "CP%u", GetACP ()); | - |
526 | } | - |
527 | codeset = buf; | - |
528 | | - |
529 | #elif defined OS2 | - |
530 | | - |
531 | const char *locale; | - |
532 | static char buf[2 + 10 + 1]; | - |
533 | ULONG cp[3]; | - |
534 | ULONG cplen; | - |
535 | | - |
536 | codeset = NULL; | - |
537 | | - |
538 | | - |
539 | | - |
540 | locale = getenv ("LC_ALL"); | - |
541 | if (locale == NULL || locale[0] == '\0') | - |
542 | { | - |
543 | locale = getenv ("LC_CTYPE"); | - |
544 | if (locale == NULL || locale[0] == '\0') | - |
545 | locale = getenv ("LANG"); | - |
546 | } | - |
547 | if (locale != NULL && locale[0] != '\0') | - |
548 | { | - |
549 | | - |
550 | const char *dot = strchr (locale, '.'); | - |
551 | | - |
552 | if (dot != NULL) | - |
553 | { | - |
554 | const char *modifier; | - |
555 | | - |
556 | dot++; | - |
557 | | - |
558 | modifier = strchr (dot, '@'); | - |
559 | if (modifier == NULL) | - |
560 | return dot; | - |
561 | if (modifier - dot < sizeof (buf)) | - |
562 | { | - |
563 | memcpy (buf, dot, modifier - dot); | - |
564 | buf [modifier - dot] = '\0'; | - |
565 | return buf; | - |
566 | } | - |
567 | } | - |
568 | | - |
569 | | - |
570 | if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0) | - |
571 | codeset = ""; | - |
572 | } | - |
573 | | - |
574 | if (codeset == NULL) | - |
575 | { | - |
576 | | - |
577 | if (DosQueryCp (sizeof (cp), cp, &cplen)) | - |
578 | codeset = ""; | - |
579 | else | - |
580 | { | - |
581 | sprintf (buf, "CP%u", cp[0]); | - |
582 | codeset = buf; | - |
583 | } | - |
584 | } | - |
585 | | - |
586 | #endif | - |
587 | | - |
588 | if (codeset == NULL)TRUE | never evaluated | FALSE | evaluated 1653 times by 58 testsEvaluated by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
|
| 0-1653 |
589 | | - |
590 | codeset = ""; never executed: codeset = ""; | 0 |
591 | | - |
592 | | - |
593 | for (aliases = get_charset_aliases (); | - |
594 | *aliases != '\0';TRUE | never evaluated | FALSE | evaluated 1653 times by 58 testsEvaluated by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
|
| 0-1653 |
595 | aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) | - |
596 | if (strcmp (codeset, aliases) == 0 never executed: __result = (((const unsigned char *) (const char *) ( codeset ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( aliases ))[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 |
597 | || (aliases[0] == '*' && aliases[1] == '\0'))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
598 | { | - |
599 | codeset = aliases + strlen (aliases) + 1; | - |
600 | break; never executed: break; | 0 |
601 | } | - |
602 | | - |
603 | | - |
604 | | - |
605 | | - |
606 | if (codeset[0] == '\0')TRUE | never evaluated | FALSE | evaluated 1653 times by 58 testsEvaluated by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
|
| 0-1653 |
607 | codeset = "ASCII"; never executed: codeset = "ASCII"; | 0 |
608 | | - |
609 | #ifdef DARWIN7 | - |
610 | | - |
611 | | - |
612 | if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX_L (uselocale (NULL)) <= 1) | - |
613 | codeset = "ASCII"; | - |
614 | #endif | - |
615 | | - |
616 | return codeset;executed 1653 times by 58 tests: return codeset; Executed by:- b2sum
- base32
- base64
- basename
- chcon
- chmod
- chown
- comm
- cp
- csplit
- cut
- date
- dd
- df
- dir
- du
- env
- expand
- expr
- factor
- fmt
- fold
- ginstall
- groups
- head
- ...
| 1653 |
617 | } | - |
| | |