mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-04 08:40:15 +00:00
2f6d1f1be9
1997-02-24 23:05 Wolfram Gloger <wmglo@dent.med.uni-muenchen.de> * malloc/malloc.c (malloc_get_state): New function. Saves global malloc state to an opaque data structure which is dynamically allocated in the heap. * malloc/malloc.c (malloc_set_state): New function. Restore previously obtained state. * malloc/malloc.h: Add declaration of malloc_get_state() and malloc_set_state(). 1997-02-24 23:27 Ulrich Drepper <drepper@cygnus.com> * sysdeps/libm-ieee754/s_cbrtl.c: Shift B1_EXP value to right position. 1997-02-24 17:38 Ulrich Drepper <drepper@cygnus.com> * misc/error.c: Make error and error_at_line weak aliases of __error and __error_at_line respectively. Suggested by David Mosberger-Tang <davidm@AZStarNet.COM>. * sysdeps/unix/sysv/linux/i386/socket.S: Update copyright. 1997-02-22 11:30 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * elf/ldd.bash.in: Run the program directly, not as argument to the dynamic linker, if it contains an interpreter segment. * elf/ldd.sh.in: Likewise. * elf/rtld.c (dl_main): In verify mode check whether the dynamic object contains an interpreter segment and exit with 2 if not. 1997-02-23 01:23 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makefile (distribute): Remove nsswitch.h, netgroup.h, mcheck.h and xlocale.h. Make-dist adds them automagically. 1997-02-22 12:25 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * locale/C-time.c (_nl_C_LC_TIME): Add missing entry for time-era-num-entries. 1997-02-06 13:49 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * rellns-sh: No need to check for existance of first parameter. 1997-02-24 15:20 Jonathan T. Agnew <jtagnew@amherst.edu> * glibcbug.in: Don't mention destination on MAIL_AGENT command line to avoid duplicate mail. 1997-02-24 03:51 Ulrich Drepper <drepper@cygnus.com> * Makefile (distribute): Add isomac.c. (tests): Run isomac test. * features.h (__USE_ISOC9X): New macro. * catgets/catgets.c: Don't use global variable `optind'. Instead use result computed by argp_parse. * db/makedb: Likewise. * locale/programs/locale.c: Likewise. * locale/programs/localedef.c: Likewise. * libio/stdio.h: Rewrite. Make it more readable and add comments. * libio/clearerr.c: Remove clearerr_locked alias. * libio/feof.c: Remove feof_locked alias. * libio/ferror.c: Remove feof_locked alias. * libio/fileno.c: Remove fileno_locked alias. * libio/fputc.c: Remove fputc_locked alias. * libio/getc.c: Remove getc_locked alias. * libio/getchar.c: Remove getchar_locked alias. * libio/iofflush.c: Remove fflush_locked alias. * libio/putc.c: Remove putc_locked alias. * libio/putc.c: Remove putchar_locked alias. * stdio-common/printf_fp.c: When number is inifinity print INF or inf depending on case of specifier. Same for NaN where NAN or nan is printed. Specified in ISO C 9X. * misc/sys/cdefs.h (__restrict): Define to empty string for now. * stdio/stdio.h: Add __restrict to prototypes where necessary. * libio/stdio.h: Likewise. * stdlib/stdlib.h: Likewise. * string/string.h: Likewise. * time/time.h: Likewise. * wcsmbs/wchar.h: Likewise. * stdlib/strtod.c: Change to recognize INF, INFINITY, NAN, and NAN(...). * sysdeps/ieee754/huge_val.h: Define HUGE_VALF and HUGE_VALL instead of HUGE_VALf and HUGE_VALL. * stdlib/strtof.c (FLOAT_HUGE_VAL): Use standard name HUGE_VALF instead of HUGE_VALf. * wcsmbs/wcstof.c: Likewise. * stdlib/strtold.c (FLOAT_HUGE_VAL): Use standard name HUGE_VALL instead of HUGE_VALl. * wcsmbs/wcstold.c: Likewise. * sysdeps/posix/gai_strerror.c: Use size_t for counter variable to avoid warning. * wcsmbs/Makefile (routines): Add wcscasecmp and wcsncase. * wcsmbs/wchar.h: Add prototypes for wcscasecmp and wcsncase. * wcsmbs/wcscasecmp.c: New file. * wcsmbs/wcsncase.c: New file. * stdlib/strtol.c: Define wide character quad word functions as wcstoll and wcstoull and normal versions as strtoll and strtoull. * wcsmbs/wchar.h: Add prototypes for wcstoll and wcstoull. * wcsmbs/wcstoq: Renamed to wcstoll.c. * wcsmbs/wcstouq: Renamed to wcstoull.c. * wcsmbs/wcstoll.c: Renamed from wcstoq.c. Make wcstoq a weak alias of wcstoll. * wcsmbs/wcstoull.c: Renamed from wcstouq.c. Make wcstouq a weak alias of wcstoull. * wcsmbs/Makefile (routines): Replace wcstoq and wcstouq by wcstoll and wcstoull respectively. * stdlib/strtoq.c: Rename to strtoll.c. * stdlib/strtouq.c: Rename to strtoull.c. * stdlib/strtoll.c: Renamed from strtoq.c. Make strtoq a weak alias of strtoll. * stdlib/strtoll.c: Renamed from strtouq.c. Make strtouq a weak alias of strtoull. * stdlib/Makefile (routines): Replace strtoq and strtouq by strtoll and strtoull respectively. * stdio-common/vfscanf.c: Don't use __strtoq_internal and __strtouq_internal but instead __strtoll_internal and __strtoull_internal respectively. * stdlib/stdlib.h (strtoq): Use __internal_strtoll in inline version. (strtouq): Similar with __internal_strtoull. * wcsmbs/wchar.h (wcstoq): Use __internal_wcstoll in inline version. (wcstouq): Similar with __internal_wcstoull. 1997-02-23 04:38 Ulrich Drepper <drepper@cygnus.com> * stdlib/strtol.c (STRTOL): It is not illegal to parse a minus sign in the strtouXX functions. The results gets simply negated. * stdio-common/tstscanf.c: Add testcase for above case. * stdlib/tst-strtol.c: Correct tests. * manual/stdio-fp.c: New file. Generate output for example program in stdio.texi. * stdio-common/Makefile (routines): Add printf_fphex. * stdio-common/vfprintf.c: Add handling of %a and %A specifier. * stdio-common/printf_fphex.c: New file. Implement %a and %A specifier. 1997-02-22 03:01 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/timebits.h (CLK_TCK): Don't defined if __STRICT_ANSI__. * math/math.h: Prevent definition of struct exception when using C++. 1997-02-22 01:45 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/syscalls.list: Dup takes only one argument. Reported by Greg McGary. 1997-02-21 00:22 Miles Bader <miles@gnu.ai.mit.edu> 1997-02-20 01:28 Miles Bader <miles@gnu.ai.mit.edu> 1997-02-19 13:56 Miles Bader <miles@gnu.ai.mit.edu> 1997-02-18 15:39 Miles Bader <miles@gnu.ai.mit.edu> 1997-02-17 10:58 Miles Bader <miles@gnu.ai.mit.edu> 1997-02-15 10:23 Miles Bader <miles@gnu.ai.mit.edu> (mutex_lock, mutex_unlock, mutex_trylock): Defined in terms of __mutex_*. (mutex_t): Type removed & replaced by new macro. (tsd_key_t): Typedef to int instead of pthread_key_t. (tsd_key_create, tsd_setspecific, tsd_getspecific): New macros. (__pthread_initialize): New macro, work around assumption of pthreads. * sysdeps/mach/hurd/i386/init-first.c (__libc_argv, __libc_argc): __hurd_sigthread_stack_end, __hurd_sigthread_stack_variables, __hurd_threadvar_max, __hurd_threadvar_stack_offset, __hurd_threadvar_stack_mask): Variables removed. 1997-02-14 14:07 Miles Bader <miles@gnu.ai.mit.edu> * hurd/hurd.h (_hurd_pids_changed_stamp, _hurd_pids_changed_sync): 1997-02-24 17:06 Geoffrey Keating <geoffk@discus.anu.edu.au> * sysdeps/unix/sysv/linux/accept.S (NARGS): Describe number of arguments taken, for sysdeps/unix/sysv/linux/powerpc/socket.S. * sysdeps/unix/sysv/linux/bind.S: Likewise. * sysdeps/unix/sysv/linux/connect.S: Likewise. * sysdeps/unix/sysv/linux/getpeername.S: Likewise. * sysdeps/unix/sysv/linux/getsockname.S: Likewise. * sysdeps/unix/sysv/linux/getsockopt.S: Likewise. * sysdeps/unix/sysv/linux/listen.S: Likewise. * sysdeps/unix/sysv/linux/recv.S: Likewise. * sysdeps/unix/sysv/linux/recvfrom.S: Likewise. * sysdeps/unix/sysv/linux/recvmsg.S: Likewise. * sysdeps/unix/sysv/linux/send.S: Likewise. * sysdeps/unix/sysv/linux/sendmsg.S: Likewise. * sysdeps/unix/sysv/linux/sendto.S: Likewise. * sysdeps/unix/sysv/linux/setsockopt.S: Likewise. * sysdeps/unix/sysv/linux/shutdown.S: Likewise. * sysdeps/unix/sysv/linux/socketpair.S: Likewise. 1997-02-15 04:51 Ulrich Drepper <drepper@cygnus.com>
518 lines
14 KiB
C
518 lines
14 KiB
C
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Library General Public License as
|
|
published by the Free Software Foundation; either version 2 of the
|
|
License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Library General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
# include <config.h>
|
|
#endif
|
|
|
|
#include <argp.h>
|
|
#include <errno.h>
|
|
#include <fcntl.h>
|
|
#include <libintl.h>
|
|
#include <locale.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
#include <sys/mman.h>
|
|
#include <sys/stat.h>
|
|
|
|
#include "error.h"
|
|
#include "charset.h"
|
|
#include "locfile.h"
|
|
#include "../intl/loadinfo.h"
|
|
|
|
/* Undefine the following line in the production version. */
|
|
/* #define NDEBUG 1 */
|
|
#include <assert.h>
|
|
|
|
|
|
/* List of locale definition files which are used in `copy' instructions. */
|
|
struct copy_def_list_t
|
|
{
|
|
struct copy_def_list_t *next;
|
|
|
|
const char *name;
|
|
int mask;
|
|
|
|
struct localedef_t *locale;
|
|
|
|
struct
|
|
{
|
|
void *data;
|
|
size_t len;
|
|
} binary[6];
|
|
};
|
|
|
|
|
|
/* List of copied locales. */
|
|
struct copy_def_list_t *copy_list;
|
|
|
|
/* If this is defined be POSIX conform. */
|
|
int posix_conformance;
|
|
|
|
/* If not zero give a lot more messages. */
|
|
int verbose;
|
|
|
|
/* If not zero suppress warnings and information messages. */
|
|
int be_quiet;
|
|
|
|
/* If not zero force output even if warning were issued. */
|
|
static int force_output;
|
|
|
|
/* Name of the character map file. */
|
|
static const char *charmap_file;
|
|
|
|
/* Name of the locale definition file. */
|
|
static const char *input_file;
|
|
|
|
/* Name of the UCS file. */
|
|
static const char *ucs_csn;
|
|
|
|
|
|
/* Name and version of program. */
|
|
static void print_version (FILE *stream, struct argp_state *state);
|
|
void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
|
|
|
|
#define OPT_POSIX 1
|
|
#define OPT_QUIET 2
|
|
|
|
/* Definitions of arguments for argp functions. */
|
|
static const struct argp_option options[] =
|
|
{
|
|
{ NULL, 0, NULL, 0, N_("Input Files:") },
|
|
{ "charmap", 'f', "FILE", 0,
|
|
N_("Symbolic character names defined in FILE") },
|
|
{ "inputfile", 'i', "FILE", 0, N_("Source definitions are found in FILE") },
|
|
{ "code-set-name", 'u', "NAME", OPTION_HIDDEN,
|
|
N_("Specify code set for mapping ISO 10646 elements") },
|
|
|
|
{ NULL, 0, NULL, 0, N_("Output control:") },
|
|
{ "force", 'c', NULL, 0,
|
|
N_("Create output even if warning messages were issued") },
|
|
{ "posix", OPT_POSIX, NULL, 0, N_("Be strictly POSIX conform") },
|
|
{ "quiet", OPT_QUIET, NULL, 0,
|
|
N_("Suppress warnings and information messages") },
|
|
{ "verbose", 'V', NULL, 0, N_("print more messages") },
|
|
{ NULL, 0, NULL, 0, NULL }
|
|
};
|
|
|
|
/* Short description of program. */
|
|
static const char doc[] = N_("Compile locale specification");
|
|
|
|
/* Strings for arguments in help texts. */
|
|
static const char args_doc[] = N_("NAME");
|
|
|
|
/* Prototype for option handler. */
|
|
static error_t parse_opt (int key, char *arg, struct argp_state *state);
|
|
|
|
/* Function to print some extra text in the help message. */
|
|
static char *more_help (int key, const char *text, void *input);
|
|
|
|
/* Data structure to communicate with argp functions. */
|
|
static struct argp argp =
|
|
{
|
|
options, parse_opt, args_doc, doc, NULL, more_help
|
|
};
|
|
|
|
|
|
/* Prototypes for global functions. */
|
|
void *xmalloc (size_t __n);
|
|
|
|
/* Prototypes for local functions. */
|
|
static void error_print (void);
|
|
static const char *construct_output_path (char *path);
|
|
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
const char *output_path;
|
|
int cannot_write_why;
|
|
struct charset_t *charset;
|
|
struct localedef_t *localedef;
|
|
struct copy_def_list_t *act_add_locdef;
|
|
int remaining;
|
|
|
|
/* Set initial values for global variables. */
|
|
copy_list = NULL;
|
|
posix_conformance = getenv ("POSIXLY_CORRECT") != NULL;
|
|
error_print_progname = error_print;
|
|
|
|
/* Set locale. Do not set LC_ALL because the other categories must
|
|
not be affected (according to POSIX.2). */
|
|
setlocale (LC_MESSAGES, "");
|
|
setlocale (LC_CTYPE, "");
|
|
|
|
/* Initialize the message catalog. */
|
|
textdomain (_libc_intl_domainname);
|
|
|
|
/* Parse and process arguments. */
|
|
argp_parse (&argp, argc, argv, 0, &remaining, NULL);
|
|
|
|
/* XXX POSIX is violated since for unknown option a exit value > 3
|
|
must be used. */
|
|
|
|
/* POSIX.2 requires to be verbose about missing characters in the
|
|
character map. */
|
|
verbose |= posix_conformance;
|
|
|
|
if (argc - remaining != 1)
|
|
{
|
|
/* We need exactly one non-option parameter. */
|
|
argp_help (&argp, stdout, ARGP_HELP_SEE,
|
|
program_invocation_short_name);
|
|
|
|
/* XXX Currently POSIX is violated. We must exit with code 4
|
|
but the argp_help function currently does not allow this. */
|
|
exit (4);
|
|
}
|
|
|
|
/* The parameter describes the output path of the constructed files.
|
|
If the described files cannot be written return a NULL pointer. */
|
|
output_path = construct_output_path (argv[remaining]);
|
|
cannot_write_why = errno;
|
|
|
|
/* Now that the parameters are processed we have to reset the local
|
|
ctype locale. (P1003.2 4.35.5.2) */
|
|
setlocale (LC_CTYPE, "POSIX");
|
|
|
|
/* Look whether the system really allows locale definitions. POSIX
|
|
defines error code 3 for this situation so I think it must be
|
|
a fatal error (see P1003.2 4.35.8). */
|
|
if (sysconf (_SC_2_LOCALEDEF) < 0)
|
|
error (3, 0, _("FATAL: system does not define `_POSIX2_LOCALEDEF'"));
|
|
|
|
/* Process charmap file. */
|
|
charset = charmap_read (charmap_file);
|
|
|
|
/* Now read the locale file. */
|
|
localedef = locfile_read (input_file, charset);
|
|
if (localedef->failed != 0)
|
|
error (4, errno, _("cannot open locale definition file `%s'"), input_file);
|
|
|
|
/* Perhaps we saw some `copy' instructions. Process the given list.
|
|
We use a very simple algorithm: we look up the list from the
|
|
beginning every time. */
|
|
do
|
|
{
|
|
int cat;
|
|
|
|
for (act_add_locdef = copy_list; act_add_locdef != NULL;
|
|
act_add_locdef = act_add_locdef->next)
|
|
{
|
|
for (cat = LC_CTYPE; cat <= LC_MESSAGES; ++cat)
|
|
if ((act_add_locdef->mask & (1 << cat)) != 0)
|
|
{
|
|
act_add_locdef->mask &= ~(1 << cat);
|
|
break;
|
|
}
|
|
if (cat <= LC_MESSAGES)
|
|
break;
|
|
}
|
|
|
|
if (act_add_locdef != NULL)
|
|
{
|
|
int avail = 0;
|
|
|
|
if (act_add_locdef->locale == NULL)
|
|
act_add_locdef->locale = locfile_read (act_add_locdef->name,
|
|
charset);
|
|
|
|
if (! act_add_locdef->locale->failed)
|
|
{
|
|
avail = act_add_locdef->locale->categories[cat].generic != NULL;
|
|
if (avail)
|
|
localedef->categories[cat].generic
|
|
= act_add_locdef->locale->categories[cat].generic;
|
|
}
|
|
|
|
if (! avail)
|
|
{
|
|
const char *locale_names[] = { "LC_COLLATE", "LC_CTYPE",
|
|
"LC_MONETARY", "LC_NUMERIC",
|
|
"LC_TIME", "LC_MESSAGES" };
|
|
char *fname;
|
|
int fd;
|
|
struct stat st;
|
|
|
|
asprintf (&fname, LOCALE_PATH "/%s/%s", act_add_locdef->name,
|
|
locale_names[cat]);
|
|
fd = open (fname, O_RDONLY);
|
|
if (fd == -1)
|
|
{
|
|
free (fname);
|
|
|
|
asprintf (&fname, LOCALE_PATH "/%s/%s/SYS_%s",
|
|
act_add_locdef->name, locale_names[cat],
|
|
locale_names[cat]);
|
|
|
|
fd = open (fname, O_RDONLY);
|
|
if (fd == -1)
|
|
error (5, 0, _("\
|
|
locale file `%s', used in `copy' statement, not found"),
|
|
act_add_locdef->name);
|
|
}
|
|
|
|
if (fstat (fd, &st) < 0)
|
|
error (5, errno, _("\
|
|
cannot `stat' locale file `%s'"),
|
|
fname);
|
|
|
|
localedef->len[cat] = st.st_size;
|
|
localedef->categories[cat].generic
|
|
= mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
|
|
|
if (localedef->categories[cat].generic == (void *) -1)
|
|
{
|
|
size_t left = st.st_size;
|
|
void *read_ptr;
|
|
|
|
localedef->categories[cat].generic
|
|
= xmalloc (st.st_size);
|
|
read_ptr = localedef->categories[cat].generic;
|
|
|
|
do
|
|
{
|
|
long int n;
|
|
n = read (fd, read_ptr, left);
|
|
if (n == -1)
|
|
error (5, errno, _("cannot read locale file `%s'"),
|
|
fname);
|
|
read_ptr += n;
|
|
left -= n;
|
|
}
|
|
while (left > 0);
|
|
}
|
|
|
|
close (fd);
|
|
free (fname);
|
|
|
|
localedef->binary |= 1 << cat;
|
|
}
|
|
}
|
|
}
|
|
while (act_add_locdef != NULL);
|
|
|
|
/* Check the categories we processed in source form. */
|
|
check_all_categories (localedef, charset);
|
|
|
|
/* We are now able to write the data files. If warning were given we
|
|
do it only if it is explicitly requested (--force). */
|
|
if (error_message_count == 0 || force_output != 0)
|
|
{
|
|
if (cannot_write_why != 0)
|
|
error (4, cannot_write_why, _("cannot write output files to `%s'"),
|
|
output_path);
|
|
else
|
|
write_all_categories (localedef, charset, output_path);
|
|
}
|
|
else
|
|
error (4, 0, _("no output file produced because warning were issued"));
|
|
|
|
/* This exit status is prescribed by POSIX.2 4.35.7. */
|
|
exit (error_message_count != 0);
|
|
}
|
|
|
|
|
|
/* Handle program arguments. */
|
|
static error_t
|
|
parse_opt (int key, char *arg, struct argp_state *state)
|
|
{
|
|
switch (key)
|
|
{
|
|
case OPT_QUIET:
|
|
be_quiet = 1;
|
|
break;
|
|
case OPT_POSIX:
|
|
posix_conformance = 1;
|
|
break;
|
|
case 'c':
|
|
force_output = 1;
|
|
break;
|
|
case 'f':
|
|
charmap_file = arg;
|
|
break;
|
|
case 'i':
|
|
input_file = arg;
|
|
break;
|
|
case 'u':
|
|
ucs_csn = arg;
|
|
break;
|
|
case 'v':
|
|
verbose = 1;
|
|
break;
|
|
default:
|
|
return ARGP_ERR_UNKNOWN;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
static char *
|
|
more_help (int key, const char *text, void *input)
|
|
{
|
|
char *cp;
|
|
|
|
switch (key)
|
|
{
|
|
case ARGP_KEY_HELP_EXTRA:
|
|
/* We print some extra information. */
|
|
asprintf (&cp, gettext ("\
|
|
System's directory for character maps: %s\n\
|
|
locale files : %s\n\
|
|
%s"),
|
|
CHARMAP_PATH, LOCALE_PATH, gettext ("\
|
|
Report bugs using the `glibcbug' script to <bugs@gnu.ai.mit.edu>.\n"));
|
|
return cp;
|
|
default:
|
|
break;
|
|
}
|
|
return (char *) text;
|
|
}
|
|
|
|
/* Print the version information. */
|
|
static void
|
|
print_version (FILE *stream, struct argp_state *state)
|
|
{
|
|
fprintf (stream, "localedef (GNU %s) %s\n", PACKAGE, VERSION);
|
|
fprintf (stream, gettext ("\
|
|
Copyright (C) %s Free Software Foundation, Inc.\n\
|
|
This is free software; see the source for copying conditions. There is NO\n\
|
|
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
|
|
"), "1995, 1996, 1997");
|
|
fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper");
|
|
}
|
|
|
|
|
|
void
|
|
def_to_process (const char *name, int category)
|
|
{
|
|
struct copy_def_list_t *new, **rp;
|
|
|
|
for (rp = ©_list; *rp != NULL; rp = &(*rp)->next)
|
|
if (strcmp (name, (*rp)->name) == 0)
|
|
break;
|
|
|
|
if (*rp == NULL)
|
|
{
|
|
size_t cnt;
|
|
|
|
*rp = (struct copy_def_list_t *) xmalloc (sizeof (**rp));
|
|
|
|
(*rp)->next = NULL;
|
|
(*rp)->name = name;
|
|
(*rp)->mask = 0;
|
|
(*rp)->locale = NULL;
|
|
|
|
for (cnt = 0; cnt < 6; ++cnt)
|
|
{
|
|
(*rp)->binary[cnt].data = NULL;
|
|
(*rp)->binary[cnt].len = 0;
|
|
}
|
|
}
|
|
new = *rp;
|
|
|
|
if ((new->mask & category) != 0)
|
|
/* We already have the information. This cannot happen. */
|
|
error (5, 0, _("\
|
|
category data requested more than once: should not happen"));
|
|
|
|
new->mask |= category;
|
|
}
|
|
|
|
|
|
/* The address of this function will be assigned to the hook in the error
|
|
functions. */
|
|
static void
|
|
error_print ()
|
|
{
|
|
/* We don't want the program name to be printed in messages. Emacs'
|
|
compile.el does not like this. */
|
|
}
|
|
|
|
|
|
/* The parameter to localedef describes the output path. If it does
|
|
contain a '/' character it is a relative path. Otherwise it names the
|
|
locale this definition is for. */
|
|
static const char *
|
|
construct_output_path (char *path)
|
|
{
|
|
const char *normal = NULL;
|
|
char *result;
|
|
|
|
if (strchr (path, '/') == NULL)
|
|
{
|
|
/* This is a system path. First examine whether the locale name
|
|
contains a reference to the codeset. This should be
|
|
normalized. */
|
|
char *startp, *endp;
|
|
|
|
startp = path;
|
|
/* We must be prepared for finding a CEN name or a location of
|
|
the introducing `.' where it is not possible anymore. */
|
|
while (*startp != '\0' && *startp != '@' && *startp != '.'
|
|
&& *startp != '+' && *startp != ',')
|
|
++startp;
|
|
if (*startp == '.')
|
|
{
|
|
/* We found a codeset specification. Now find the end. */
|
|
endp = ++startp;
|
|
while (*endp != '\0' && *endp != '@')
|
|
++endp;
|
|
|
|
if (endp > startp)
|
|
normal = _nl_normalize_codeset (startp, endp - startp);
|
|
}
|
|
else
|
|
/* This is to keep gcc quiet. */
|
|
endp = NULL;
|
|
|
|
/* We put an additional '\0' at the end of the string because at
|
|
the end of the function we need another byte for the trailing
|
|
'/'. */
|
|
if (normal == NULL)
|
|
asprintf (&result, "%s/%s%c", LOCALEDIR, path, '\0');
|
|
else
|
|
asprintf (&result, "%s/%.*s%s%s%c", LOCALEDIR, startp - path, path,
|
|
normal, endp, '\0');
|
|
}
|
|
else
|
|
{
|
|
/* This is a user path. Please note the additional byte in the
|
|
memory allocation. */
|
|
result = xmalloc (strlen (path) + 2);
|
|
strcpy (result, path);
|
|
}
|
|
|
|
errno = 0;
|
|
|
|
if (euidaccess (result, W_OK) == -1)
|
|
/* Perhaps the directory does not exist now. Try to create it. */
|
|
if (errno == ENOENT)
|
|
{
|
|
errno = 0;
|
|
mkdir (result, 0777);
|
|
}
|
|
|
|
strcat (result, "/");
|
|
|
|
return result;
|
|
}
|