1
1
/* Handle aliases for locale names.
2
Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc.
2
Copyright (C) 1995-1999, 2000-2001, 2003, 2005 Free Software Foundation, Inc.
4
4
This program is free software; you can redistribute it and/or modify it
5
5
under the terms of the GNU Library General Public License as published
14
14
You should have received a copy of the GNU Library General Public
15
15
License along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
19
/* Tell glibc's <string.h> to provide a prototype for mempcpy().
298
306
else if (cp[0] != '\0')
302
if (__builtin_expect (extend_alias_table (), 0))
305
alias_len = strlen (alias) + 1;
306
value_len = strlen (value) + 1;
308
if (string_space_act + alias_len + value_len > string_space_max)
310
/* glibc's locale.alias contains entries for ja_JP and ko_KR
311
that make it impossible to use a Japanese or Korean UTF-8
312
locale under the name "ja_JP" or "ko_KR". Ignore these
314
if (strchr (alias, '_') == NULL)
310
/* Increase size of memory pool. */
311
size_t new_size = (string_space_max
312
+ (alias_len + value_len > 1024
313
? alias_len + value_len : 1024));
314
char *new_pool = (char *) realloc (string_space, new_size);
315
if (new_pool == NULL)
318
if (__builtin_expect (string_space != new_pool, 0))
321
if (__builtin_expect (extend_alias_table (), 0))
324
alias_len = strlen (alias) + 1;
325
value_len = strlen (value) + 1;
327
if (string_space_act + alias_len + value_len > string_space_max)
329
/* Increase size of memory pool. */
330
size_t new_size = (string_space_max
331
+ (alias_len + value_len > 1024
332
? alias_len + value_len : 1024));
333
char *new_pool = (char *) realloc (string_space, new_size);
334
if (new_pool == NULL)
322
for (i = 0; i < nmap; i++)
337
if (__builtin_expect (string_space != new_pool, 0))
324
map[i].alias += new_pool - string_space;
325
map[i].value += new_pool - string_space;
341
for (i = 0; i < nmap; i++)
343
map[i].alias += new_pool - string_space;
344
map[i].value += new_pool - string_space;
348
string_space = new_pool;
349
string_space_max = new_size;
329
string_space = new_pool;
330
string_space_max = new_size;
352
map[nmap].alias = memcpy (&string_space[string_space_act],
354
string_space_act += alias_len;
356
map[nmap].value = memcpy (&string_space[string_space_act],
358
string_space_act += value_len;
333
map[nmap].alias = memcpy (&string_space[string_space_act],
335
string_space_act += alias_len;
337
map[nmap].value = memcpy (&string_space[string_space_act],
339
string_space_act += value_len;
346
366
/* Possibly not the whole line fits into the buffer. Ignore
347
367
the rest of the line. */
348
while (strchr (buf, '\n') == NULL)
349
if (FGETS (buf, sizeof buf, fp) == NULL)
350
/* Make sure the inner loop will be left. The outer loop
351
will exit at the `feof' test. */
370
if (FGETS (buf, sizeof buf, fp) == NULL)
371
/* Make sure the inner loop will be left. The outer loop
372
will exit at the `feof' test. */
374
while (strchr (buf, '\n') == NULL);
355
378
/* Should we test for ferror()? I think we have to silently ignore
356
379
errors. --drepper */