Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/localcharset.c @ 7292:17785d5bede0
Fix docstrings
author | Sergey Poznyakoff <gray@gnu.org.ua> |
---|---|
date | Sun, 10 Sep 2006 11:52:44 +0000 |
parents | 1a8d338654d5 |
children | 1c4ed7637c24 |
rev | line source |
---|---|
2303 | 1 /* Determine a canonical name for the current locale's character encoding. |
2 | |
6534 | 3 Copyright (C) 2000-2006 Free Software Foundation, Inc. |
2303 | 4 |
4440
e58a1c05a6ba
Update gettext source files from gettext automatically, using srclist-update.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4337
diff
changeset
|
5 This program is free software; you can redistribute it and/or modify |
e58a1c05a6ba
Update gettext source files from gettext automatically, using srclist-update.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4337
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
e58a1c05a6ba
Update gettext source files from gettext automatically, using srclist-update.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4337
diff
changeset
|
7 the Free Software Foundation; either version 2, or (at your option) |
2303 | 8 any later version. |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
4440
e58a1c05a6ba
Update gettext source files from gettext automatically, using srclist-update.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4337
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e58a1c05a6ba
Update gettext source files from gettext automatically, using srclist-update.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4337
diff
changeset
|
13 GNU General Public License for more details. |
2303 | 14 |
4440
e58a1c05a6ba
Update gettext source files from gettext automatically, using srclist-update.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4337
diff
changeset
|
15 You should have received a copy of the GNU General Public License along |
e58a1c05a6ba
Update gettext source files from gettext automatically, using srclist-update.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4337
diff
changeset
|
16 with this program; if not, write to the Free Software Foundation, |
5848
a48fb0e98c8c
*** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents:
5658
diff
changeset
|
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
2303 | 18 |
3963
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
19 /* Written by Bruno Haible <bruno@clisp.org>. */ |
2303 | 20 |
21 #ifdef HAVE_CONFIG_H | |
22 # include <config.h> | |
23 #endif | |
24 | |
4106 | 25 /* Specification. */ |
26 #include "localcharset.h" | |
27 | |
7085
6a24b1c63a3a
Assume the standard headers exist.
Bruno Haible <bruno@clisp.org>
parents:
7010
diff
changeset
|
28 #include <stddef.h> |
2303 | 29 #include <stdio.h> |
7085
6a24b1c63a3a
Assume the standard headers exist.
Bruno Haible <bruno@clisp.org>
parents:
7010
diff
changeset
|
30 #include <string.h> |
6a24b1c63a3a
Assume the standard headers exist.
Bruno Haible <bruno@clisp.org>
parents:
7010
diff
changeset
|
31 #include <stdlib.h> |
2303 | 32 |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
33 #if defined _WIN32 || defined __WIN32__ |
7010
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
34 # define WIN32_NATIVE |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
35 #endif |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
36 |
3737 | 37 #if defined __EMX__ |
38 /* Assume EMX program runs on OS/2, even if compiled under DOS. */ | |
39 # define OS2 | |
40 #endif | |
41 | |
7010
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
42 #if !defined WIN32_NATIVE |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
43 # if HAVE_LANGINFO_CODESET |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
44 # include <langinfo.h> |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
45 # else |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
46 # if HAVE_SETLOCALE |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
47 # include <locale.h> |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
48 # endif |
2303 | 49 # endif |
7010
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
50 # ifdef __CYGWIN__ |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
51 # define WIN32_LEAN_AND_MEAN |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
52 # include <windows.h> |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
53 # endif |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
54 #elif defined WIN32_NATIVE |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
55 # define WIN32_LEAN_AND_MEAN |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
56 # include <windows.h> |
2303 | 57 #endif |
3737 | 58 #if defined OS2 |
59 # define INCL_DOS | |
60 # include <os2.h> | |
61 #endif | |
62 | |
4337 | 63 #if ENABLE_RELOCATABLE |
64 # include "relocatable.h" | |
65 #else | |
66 # define relocate(pathname) (pathname) | |
67 #endif | |
68 | |
7230
1a8d338654d5
Prefer using configmake.h instead of augmenting DEFS.
Bruno Haible <bruno@clisp.org>
parents:
7085
diff
changeset
|
69 /* Get LIBDIR. */ |
1a8d338654d5
Prefer using configmake.h instead of augmenting DEFS.
Bruno Haible <bruno@clisp.org>
parents:
7085
diff
changeset
|
70 #ifndef LIBDIR |
1a8d338654d5
Prefer using configmake.h instead of augmenting DEFS.
Bruno Haible <bruno@clisp.org>
parents:
7085
diff
changeset
|
71 # include "configmake.h" |
1a8d338654d5
Prefer using configmake.h instead of augmenting DEFS.
Bruno Haible <bruno@clisp.org>
parents:
7085
diff
changeset
|
72 #endif |
1a8d338654d5
Prefer using configmake.h instead of augmenting DEFS.
Bruno Haible <bruno@clisp.org>
parents:
7085
diff
changeset
|
73 |
5053
eebff8c51a9b
Treat Cygwin like Windows regarding pathname syntax.
Bruno Haible <bruno@clisp.org>
parents:
5044
diff
changeset
|
74 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ |
eebff8c51a9b
Treat Cygwin like Windows regarding pathname syntax.
Bruno Haible <bruno@clisp.org>
parents:
5044
diff
changeset
|
75 /* Win32, Cygwin, OS/2, DOS */ |
3737 | 76 # define ISSLASH(C) ((C) == '/' || (C) == '\\') |
77 #endif | |
2303 | 78 |
2487
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
79 #ifndef DIRECTORY_SEPARATOR |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
80 # define DIRECTORY_SEPARATOR '/' |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
81 #endif |
2338
3dfb80bf846b
("path-concat.h"): Include.
Jim Meyering <jim@meyering.net>
parents:
2324
diff
changeset
|
82 |
2487
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
83 #ifndef ISSLASH |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
84 # define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
85 #endif |
2303 | 86 |
4897 | 87 #if HAVE_DECL_GETC_UNLOCKED |
3737 | 88 # undef getc |
89 # define getc getc_unlocked | |
90 #endif | |
91 | |
2324
056ab4fe3d27
Add Bruno's comment justifying use of volatile.
Jim Meyering <jim@meyering.net>
parents:
2304
diff
changeset
|
92 /* The following static variable is declared 'volatile' to avoid a |
056ab4fe3d27
Add Bruno's comment justifying use of volatile.
Jim Meyering <jim@meyering.net>
parents:
2304
diff
changeset
|
93 possible multithread problem in the function get_charset_aliases. If we |
056ab4fe3d27
Add Bruno's comment justifying use of volatile.
Jim Meyering <jim@meyering.net>
parents:
2304
diff
changeset
|
94 are running in a threaded environment, and if two threads initialize |
056ab4fe3d27
Add Bruno's comment justifying use of volatile.
Jim Meyering <jim@meyering.net>
parents:
2304
diff
changeset
|
95 'charset_aliases' simultaneously, both will produce the same value, |
056ab4fe3d27
Add Bruno's comment justifying use of volatile.
Jim Meyering <jim@meyering.net>
parents:
2304
diff
changeset
|
96 and everything will be ok if the two assignments to 'charset_aliases' |
056ab4fe3d27
Add Bruno's comment justifying use of volatile.
Jim Meyering <jim@meyering.net>
parents:
2304
diff
changeset
|
97 are atomic. But I don't know what will happen if the two assignments mix. */ |
3494
7605d363af46
Update from latest gettext.
Jim Meyering <jim@meyering.net>
parents:
3209
diff
changeset
|
98 #if __STDC__ != 1 |
7605d363af46
Update from latest gettext.
Jim Meyering <jim@meyering.net>
parents:
3209
diff
changeset
|
99 # define volatile /* empty */ |
7605d363af46
Update from latest gettext.
Jim Meyering <jim@meyering.net>
parents:
3209
diff
changeset
|
100 #endif |
2303 | 101 /* Pointer to the contents of the charset.alias file, if it has already been |
102 read, else NULL. Its format is: | |
103 ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */ | |
3494
7605d363af46
Update from latest gettext.
Jim Meyering <jim@meyering.net>
parents:
3209
diff
changeset
|
104 static const char * volatile charset_aliases; |
2303 | 105 |
106 /* Return a pointer to the contents of the charset.alias file. */ | |
107 static const char * | |
6534 | 108 get_charset_aliases (void) |
2303 | 109 { |
3494
7605d363af46
Update from latest gettext.
Jim Meyering <jim@meyering.net>
parents:
3209
diff
changeset
|
110 const char *cp; |
2303 | 111 |
112 cp = charset_aliases; | |
113 if (cp == NULL) | |
114 { | |
7010
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
115 #if !(defined VMS || defined WIN32_NATIVE || defined __CYGWIN__) |
2303 | 116 FILE *fp; |
5658
9d475f8488d9
Update from GNU gettext 0.14.2.
Bruno Haible <bruno@clisp.org>
parents:
5053
diff
changeset
|
117 const char *dir; |
2487
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
118 const char *base = "charset.alias"; |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
119 char *file_name; |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
120 |
5658
9d475f8488d9
Update from GNU gettext 0.14.2.
Bruno Haible <bruno@clisp.org>
parents:
5053
diff
changeset
|
121 /* Make it possible to override the charset.alias location. This is |
9d475f8488d9
Update from GNU gettext 0.14.2.
Bruno Haible <bruno@clisp.org>
parents:
5053
diff
changeset
|
122 necessary for running the testsuite before "make install". */ |
9d475f8488d9
Update from GNU gettext 0.14.2.
Bruno Haible <bruno@clisp.org>
parents:
5053
diff
changeset
|
123 dir = getenv ("CHARSETALIASDIR"); |
9d475f8488d9
Update from GNU gettext 0.14.2.
Bruno Haible <bruno@clisp.org>
parents:
5053
diff
changeset
|
124 if (dir == NULL || dir[0] == '\0') |
9d475f8488d9
Update from GNU gettext 0.14.2.
Bruno Haible <bruno@clisp.org>
parents:
5053
diff
changeset
|
125 dir = relocate (LIBDIR); |
9d475f8488d9
Update from GNU gettext 0.14.2.
Bruno Haible <bruno@clisp.org>
parents:
5053
diff
changeset
|
126 |
2487
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
127 /* Concatenate dir and base into freshly allocated file_name. */ |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
128 { |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
129 size_t dir_len = strlen (dir); |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
130 size_t base_len = strlen (base); |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
131 int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1])); |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
132 file_name = (char *) malloc (dir_len + add_slash + base_len + 1); |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
133 if (file_name != NULL) |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
134 { |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
135 memcpy (file_name, dir, dir_len); |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
136 if (add_slash) |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
137 file_name[dir_len] = DIRECTORY_SEPARATOR; |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
138 memcpy (file_name + dir_len + add_slash, base, base_len + 1); |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
139 } |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
140 } |
2303 | 141 |
2338
3dfb80bf846b
("path-concat.h"): Include.
Jim Meyering <jim@meyering.net>
parents:
2324
diff
changeset
|
142 if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL) |
3dfb80bf846b
("path-concat.h"): Include.
Jim Meyering <jim@meyering.net>
parents:
2324
diff
changeset
|
143 /* Out of memory or file not found, treat it as empty. */ |
2303 | 144 cp = ""; |
145 else | |
146 { | |
147 /* Parse the file's contents. */ | |
148 char *res_ptr = NULL; | |
149 size_t res_size = 0; | |
150 | |
151 for (;;) | |
152 { | |
5044
b1006348a448
Avoid memory leak upon realloc failure.
Bruno Haible <bruno@clisp.org>
parents:
4897
diff
changeset
|
153 int c; |
b1006348a448
Avoid memory leak upon realloc failure.
Bruno Haible <bruno@clisp.org>
parents:
4897
diff
changeset
|
154 char buf1[50+1]; |
b1006348a448
Avoid memory leak upon realloc failure.
Bruno Haible <bruno@clisp.org>
parents:
4897
diff
changeset
|
155 char buf2[50+1]; |
b1006348a448
Avoid memory leak upon realloc failure.
Bruno Haible <bruno@clisp.org>
parents:
4897
diff
changeset
|
156 size_t l1, l2; |
b1006348a448
Avoid memory leak upon realloc failure.
Bruno Haible <bruno@clisp.org>
parents:
4897
diff
changeset
|
157 char *old_res_ptr; |
b1006348a448
Avoid memory leak upon realloc failure.
Bruno Haible <bruno@clisp.org>
parents:
4897
diff
changeset
|
158 |
2303 | 159 c = getc (fp); |
160 if (c == EOF) | |
161 break; | |
162 if (c == '\n' || c == ' ' || c == '\t') | |
163 continue; | |
164 if (c == '#') | |
165 { | |
166 /* Skip comment, to end of line. */ | |
167 do | |
168 c = getc (fp); | |
169 while (!(c == EOF || c == '\n')); | |
170 if (c == EOF) | |
171 break; | |
172 continue; | |
173 } | |
174 ungetc (c, fp); | |
3737 | 175 if (fscanf (fp, "%50s %50s", buf1, buf2) < 2) |
2303 | 176 break; |
177 l1 = strlen (buf1); | |
178 l2 = strlen (buf2); | |
5044
b1006348a448
Avoid memory leak upon realloc failure.
Bruno Haible <bruno@clisp.org>
parents:
4897
diff
changeset
|
179 old_res_ptr = res_ptr; |
2303 | 180 if (res_size == 0) |
181 { | |
182 res_size = l1 + 1 + l2 + 1; | |
3737 | 183 res_ptr = (char *) malloc (res_size + 1); |
2303 | 184 } |
185 else | |
186 { | |
187 res_size += l1 + 1 + l2 + 1; | |
3737 | 188 res_ptr = (char *) realloc (res_ptr, res_size + 1); |
2487
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
189 } |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
190 if (res_ptr == NULL) |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
191 { |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
192 /* Out of memory. */ |
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
193 res_size = 0; |
5044
b1006348a448
Avoid memory leak upon realloc failure.
Bruno Haible <bruno@clisp.org>
parents:
4897
diff
changeset
|
194 if (old_res_ptr != NULL) |
b1006348a448
Avoid memory leak upon realloc failure.
Bruno Haible <bruno@clisp.org>
parents:
4897
diff
changeset
|
195 free (old_res_ptr); |
2487
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
196 break; |
2303 | 197 } |
198 strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); | |
199 strcpy (res_ptr + res_size - (l2 + 1), buf2); | |
200 } | |
201 fclose (fp); | |
202 if (res_size == 0) | |
203 cp = ""; | |
204 else | |
205 { | |
206 *(res_ptr + res_size) = '\0'; | |
207 cp = res_ptr; | |
208 } | |
209 } | |
210 | |
2340
744cd17f399a
(get_charset_aliases): Don't try to free file_name
Jim Meyering <jim@meyering.net>
parents:
2338
diff
changeset
|
211 if (file_name != NULL) |
744cd17f399a
(get_charset_aliases): Don't try to free file_name
Jim Meyering <jim@meyering.net>
parents:
2338
diff
changeset
|
212 free (file_name); |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
213 |
3737 | 214 #else |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
215 |
4337 | 216 # if defined VMS |
217 /* To avoid the troubles of an extra file charset.alias_vms in the | |
218 sources of many GNU packages, simply inline the aliases here. */ | |
219 /* The list of encodings is taken from the OpenVMS 7.3-1 documentation | |
220 "Compaq C Run-Time Library Reference Manual for OpenVMS systems" | |
221 section 10.7 "Handling Different Character Sets". */ | |
222 cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" | |
223 "ISO8859-2" "\0" "ISO-8859-2" "\0" | |
224 "ISO8859-5" "\0" "ISO-8859-5" "\0" | |
225 "ISO8859-7" "\0" "ISO-8859-7" "\0" | |
226 "ISO8859-8" "\0" "ISO-8859-8" "\0" | |
227 "ISO8859-9" "\0" "ISO-8859-9" "\0" | |
228 /* Japanese */ | |
229 "eucJP" "\0" "EUC-JP" "\0" | |
230 "SJIS" "\0" "SHIFT_JIS" "\0" | |
231 "DECKANJI" "\0" "DEC-KANJI" "\0" | |
232 "SDECKANJI" "\0" "EUC-JP" "\0" | |
233 /* Chinese */ | |
234 "eucTW" "\0" "EUC-TW" "\0" | |
235 "DECHANYU" "\0" "DEC-HANYU" "\0" | |
236 "DECHANZI" "\0" "GB2312" "\0" | |
237 /* Korean */ | |
238 "DECKOREAN" "\0" "EUC-KR" "\0"; | |
239 # endif | |
240 | |
7010
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
241 # if defined WIN32_NATIVE || defined __CYGWIN__ |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
242 /* To avoid the troubles of installing a separate file in the same |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
243 directory as the DLL and of retrieving the DLL's directory at |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
244 runtime, simply inline the aliases here. */ |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
245 |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
246 cp = "CP936" "\0" "GBK" "\0" |
3963
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
247 "CP1361" "\0" "JOHAB" "\0" |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
248 "CP20127" "\0" "ASCII" "\0" |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
249 "CP20866" "\0" "KOI8-R" "\0" |
6534 | 250 "CP20936" "\0" "GB2312" "\0" |
3963
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
251 "CP21866" "\0" "KOI8-RU" "\0" |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
252 "CP28591" "\0" "ISO-8859-1" "\0" |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
253 "CP28592" "\0" "ISO-8859-2" "\0" |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
254 "CP28593" "\0" "ISO-8859-3" "\0" |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
255 "CP28594" "\0" "ISO-8859-4" "\0" |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
256 "CP28595" "\0" "ISO-8859-5" "\0" |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
257 "CP28596" "\0" "ISO-8859-6" "\0" |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
258 "CP28597" "\0" "ISO-8859-7" "\0" |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
259 "CP28598" "\0" "ISO-8859-8" "\0" |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
260 "CP28599" "\0" "ISO-8859-9" "\0" |
6534 | 261 "CP28605" "\0" "ISO-8859-15" "\0" |
262 "CP38598" "\0" "ISO-8859-8" "\0" | |
263 "CP51932" "\0" "EUC-JP" "\0" | |
264 "CP51936" "\0" "GB2312" "\0" | |
265 "CP51949" "\0" "EUC-KR" "\0" | |
266 "CP51950" "\0" "EUC-TW" "\0" | |
267 "CP54936" "\0" "GB18030" "\0" | |
268 "CP65001" "\0" "UTF-8" "\0"; | |
3737 | 269 # endif |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
270 #endif |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
271 |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
272 charset_aliases = cp; |
2303 | 273 } |
274 | |
275 return cp; | |
276 } | |
277 | |
278 /* Determine the current locale's character encoding, and canonicalize it | |
279 into one of the canonical names listed in config.charset. | |
280 The result must not be freed; it is statically allocated. | |
281 If the canonical name cannot be determined, the result is a non-canonical | |
3203
3b920adfcea5
(locale_charset): Don't use setlocale(LC_CTYPE,NULL).
Jim Meyering <jim@meyering.net>
parents:
3062
diff
changeset
|
282 name. */ |
2303 | 283 |
284 #ifdef STATIC | |
285 STATIC | |
286 #endif | |
287 const char * | |
6534 | 288 locale_charset (void) |
2303 | 289 { |
290 const char *codeset; | |
291 const char *aliases; | |
292 | |
7010
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
293 #if !(defined WIN32_NATIVE || defined OS2) |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
294 |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
295 # if HAVE_LANGINFO_CODESET |
2303 | 296 |
297 /* Most systems support nl_langinfo (CODESET) nowadays. */ | |
298 codeset = nl_langinfo (CODESET); | |
299 | |
7010
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
300 # ifdef __CYGWIN__ |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
301 /* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
302 returns "US-ASCII". As long as this is not fixed, return the suffix |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
303 of the locale name from the environment variables (if present) or |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
304 the codepage as a number. */ |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
305 if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
306 { |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
307 const char *locale; |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
308 static char buf[2 + 10 + 1]; |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
309 |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
310 locale = getenv ("LC_ALL"); |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
311 if (locale == NULL || locale[0] == '\0') |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
312 { |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
313 locale = getenv ("LC_CTYPE"); |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
314 if (locale == NULL || locale[0] == '\0') |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
315 locale = getenv ("LANG"); |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
316 } |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
317 if (locale != NULL && locale[0] != '\0') |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
318 { |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
319 /* If the locale name contains an encoding after the dot, return |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
320 it. */ |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
321 const char *dot = strchr (locale, '.'); |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
322 |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
323 if (dot != NULL) |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
324 { |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
325 const char *modifier; |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
326 |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
327 dot++; |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
328 /* Look for the possible @... trailer and remove it, if any. */ |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
329 modifier = strchr (dot, '@'); |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
330 if (modifier == NULL) |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
331 return dot; |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
332 if (modifier - dot < sizeof (buf)) |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
333 { |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
334 memcpy (buf, dot, modifier - dot); |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
335 buf [modifier - dot] = '\0'; |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
336 return buf; |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
337 } |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
338 } |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
339 } |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
340 |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
341 /* Woe32 has a function returning the locale's codepage as a number. */ |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
342 sprintf (buf, "CP%u", GetACP ()); |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
343 codeset = buf; |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
344 } |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
345 # endif |
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
346 |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
347 # else |
2303 | 348 |
3203
3b920adfcea5
(locale_charset): Don't use setlocale(LC_CTYPE,NULL).
Jim Meyering <jim@meyering.net>
parents:
3062
diff
changeset
|
349 /* On old systems which lack it, use setlocale or getenv. */ |
2303 | 350 const char *locale = NULL; |
351 | |
3203
3b920adfcea5
(locale_charset): Don't use setlocale(LC_CTYPE,NULL).
Jim Meyering <jim@meyering.net>
parents:
3062
diff
changeset
|
352 /* But most old systems don't have a complete set of locales. Some |
3b920adfcea5
(locale_charset): Don't use setlocale(LC_CTYPE,NULL).
Jim Meyering <jim@meyering.net>
parents:
3062
diff
changeset
|
353 (like SunOS 4 or DJGPP) have only the C locale. Therefore we don't |
3b920adfcea5
(locale_charset): Don't use setlocale(LC_CTYPE,NULL).
Jim Meyering <jim@meyering.net>
parents:
3062
diff
changeset
|
354 use setlocale here; it would return "C" when it doesn't support the |
3b920adfcea5
(locale_charset): Don't use setlocale(LC_CTYPE,NULL).
Jim Meyering <jim@meyering.net>
parents:
3062
diff
changeset
|
355 locale name the user has set. */ |
3b920adfcea5
(locale_charset): Don't use setlocale(LC_CTYPE,NULL).
Jim Meyering <jim@meyering.net>
parents:
3062
diff
changeset
|
356 # if HAVE_SETLOCALE && 0 |
2303 | 357 locale = setlocale (LC_CTYPE, NULL); |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
358 # endif |
2487
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
359 if (locale == NULL || locale[0] == '\0') |
2303 | 360 { |
361 locale = getenv ("LC_ALL"); | |
2487
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
362 if (locale == NULL || locale[0] == '\0') |
2303 | 363 { |
364 locale = getenv ("LC_CTYPE"); | |
2487
6163322e2d48
(get_charset_aliases): Use malloc, realloc and memcpy
Jim Meyering <jim@meyering.net>
parents:
2340
diff
changeset
|
365 if (locale == NULL || locale[0] == '\0') |
2303 | 366 locale = getenv ("LANG"); |
367 } | |
368 } | |
369 | |
370 /* On some old systems, one used to set locale = "iso8859_1". On others, | |
371 you set it to "language_COUNTRY.charset". In any case, we resolve it | |
372 through the charset.alias file. */ | |
373 codeset = locale; | |
374 | |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
375 # endif |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
376 |
7010
2c3480d62b64
Update localcharset module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
6534
diff
changeset
|
377 #elif defined WIN32_NATIVE |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
378 |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
379 static char buf[2 + 10 + 1]; |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
380 |
3963
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
381 /* Woe32 has a function returning the locale's codepage as a number. */ |
3062
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
382 sprintf (buf, "CP%u", GetACP ()); |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
383 codeset = buf; |
e9f1d0258cae
(locale_charset): Add support for Win32.
Jim Meyering <jim@meyering.net>
parents:
2487
diff
changeset
|
384 |
3737 | 385 #elif defined OS2 |
386 | |
387 const char *locale; | |
388 static char buf[2 + 10 + 1]; | |
389 ULONG cp[3]; | |
390 ULONG cplen; | |
391 | |
392 /* Allow user to override the codeset, as set in the operating system, | |
393 with standard language environment variables. */ | |
394 locale = getenv ("LC_ALL"); | |
395 if (locale == NULL || locale[0] == '\0') | |
396 { | |
397 locale = getenv ("LC_CTYPE"); | |
398 if (locale == NULL || locale[0] == '\0') | |
399 locale = getenv ("LANG"); | |
400 } | |
401 if (locale != NULL && locale[0] != '\0') | |
402 { | |
403 /* If the locale name contains an encoding after the dot, return it. */ | |
404 const char *dot = strchr (locale, '.'); | |
405 | |
406 if (dot != NULL) | |
407 { | |
408 const char *modifier; | |
409 | |
410 dot++; | |
411 /* Look for the possible @... trailer and remove it, if any. */ | |
412 modifier = strchr (dot, '@'); | |
413 if (modifier == NULL) | |
414 return dot; | |
415 if (modifier - dot < sizeof (buf)) | |
416 { | |
417 memcpy (buf, dot, modifier - dot); | |
418 buf [modifier - dot] = '\0'; | |
419 return buf; | |
420 } | |
421 } | |
422 | |
423 /* Resolve through the charset.alias file. */ | |
424 codeset = locale; | |
425 } | |
426 else | |
427 { | |
428 /* OS/2 has a function returning the locale's codepage as a number. */ | |
429 if (DosQueryCp (sizeof (cp), cp, &cplen)) | |
430 codeset = ""; | |
431 else | |
432 { | |
433 sprintf (buf, "CP%u", cp[0]); | |
434 codeset = buf; | |
435 } | |
436 } | |
437 | |
2303 | 438 #endif |
439 | |
3203
3b920adfcea5
(locale_charset): Don't use setlocale(LC_CTYPE,NULL).
Jim Meyering <jim@meyering.net>
parents:
3062
diff
changeset
|
440 if (codeset == NULL) |
3b920adfcea5
(locale_charset): Don't use setlocale(LC_CTYPE,NULL).
Jim Meyering <jim@meyering.net>
parents:
3062
diff
changeset
|
441 /* The canonical name cannot be determined. */ |
3b920adfcea5
(locale_charset): Don't use setlocale(LC_CTYPE,NULL).
Jim Meyering <jim@meyering.net>
parents:
3062
diff
changeset
|
442 codeset = ""; |
3209
5416525015e5
(locale_charset): Allow wildcard syntax. Also resolve
Jim Meyering <jim@meyering.net>
parents:
3203
diff
changeset
|
443 |
5416525015e5
(locale_charset): Allow wildcard syntax. Also resolve
Jim Meyering <jim@meyering.net>
parents:
3203
diff
changeset
|
444 /* Resolve alias. */ |
5416525015e5
(locale_charset): Allow wildcard syntax. Also resolve
Jim Meyering <jim@meyering.net>
parents:
3203
diff
changeset
|
445 for (aliases = get_charset_aliases (); |
5416525015e5
(locale_charset): Allow wildcard syntax. Also resolve
Jim Meyering <jim@meyering.net>
parents:
3203
diff
changeset
|
446 *aliases != '\0'; |
5416525015e5
(locale_charset): Allow wildcard syntax. Also resolve
Jim Meyering <jim@meyering.net>
parents:
3203
diff
changeset
|
447 aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) |
5416525015e5
(locale_charset): Allow wildcard syntax. Also resolve
Jim Meyering <jim@meyering.net>
parents:
3203
diff
changeset
|
448 if (strcmp (codeset, aliases) == 0 |
5416525015e5
(locale_charset): Allow wildcard syntax. Also resolve
Jim Meyering <jim@meyering.net>
parents:
3203
diff
changeset
|
449 || (aliases[0] == '*' && aliases[1] == '\0')) |
5416525015e5
(locale_charset): Allow wildcard syntax. Also resolve
Jim Meyering <jim@meyering.net>
parents:
3203
diff
changeset
|
450 { |
5416525015e5
(locale_charset): Allow wildcard syntax. Also resolve
Jim Meyering <jim@meyering.net>
parents:
3203
diff
changeset
|
451 codeset = aliases + strlen (aliases) + 1; |
5416525015e5
(locale_charset): Allow wildcard syntax. Also resolve
Jim Meyering <jim@meyering.net>
parents:
3203
diff
changeset
|
452 break; |
5416525015e5
(locale_charset): Allow wildcard syntax. Also resolve
Jim Meyering <jim@meyering.net>
parents:
3203
diff
changeset
|
453 } |
2303 | 454 |
3963
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
455 /* Don't return an empty string. GNU libc and GNU libiconv interpret |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
456 the empty string as denoting "the locale's character encoding", |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
457 thus GNU libiconv would call this function a second time. */ |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
458 if (codeset[0] == '\0') |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
459 codeset = "ASCII"; |
ed9b8c0441b5
Update config.charset and localcharset.c to current gettext version.
Bruno Haible <bruno@clisp.org>
parents:
3737
diff
changeset
|
460 |
2303 | 461 return codeset; |
462 } |