diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-02-22 01:20:46 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-02-22 01:20:46 +0000 |
commit | 5a97622d5e053e935af0a9715ddd941fdaafcaf9 (patch) | |
tree | 9f703f1a0c1c4ca0ed023acd33f09d152c923426 /locale | |
parent | 1fb05e3db1891142410bc58c320dfe281749fffe (diff) | |
download | glibc-5a97622d5e053e935af0a9715ddd941fdaafcaf9.tar.gz glibc-5a97622d5e053e935af0a9715ddd941fdaafcaf9.tar.xz glibc-5a97622d5e053e935af0a9715ddd941fdaafcaf9.zip |
update from main archive 970221 cvs/libc-970223 cvs/libc-970222
1997-02-22 00:17 Ulrich Drepper <drepper@cygnus.com> * catgets/gencat.c: Change to use argp. * db/makedb: Likewise. * locale/programs/localedef.c: Likewise. * locale/programs/locale.c: Little adjustment for better usage of argp. 1997-02-20 20:07 Greg McGary <gkm@eng.ascend.com> * Makeconfig: Add rules for libc with bounded pointers. * Makerules: Likewise. * config.make.in: Likewise. * configure.in: Likewise. 1997-02-21 10:41 Miles Bader <miles@gnu.ai.mit.edu> * argp.h (OPTION_NO_USAGE): New macro. * argp-help.c (usage_long_opt, usage_argful_short_opt, add_argless_short_opt): Implement OPTION_NO_USAGE. 1997-02-20 16:41 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * malloc/obstack.h: Fix typo. 1997-02-20 15:56 Miles Bader <miles@gnu.ai.mit.edu> * argp-fmtstream.c (__argp_fmtstream_update): Account for case where NEXTLINE points one past the end of the active buffer. * argp-help.c <stddef.h>: New include. (__argp_failure): Only exit if STATE says it's ok. (print_header, hol_entry_help): Use UPARAMS fields rather than constants. (_help): Call fill_in_uparams if necessary. (struct hol_help_state): New type. (struct pentry_state): Add hhstate field. Remove prev_entry & sep_groups fields. (hol_entry_help): Add HHSTATE parameter. Remove prev_entry & sep_groups parameters. Suppress duplicate arguments if requested, and note the fact. (print_header, comma): Use PEST->hhstate fields. (hol_help): Add HHSTATE variable & pass to hol_entry_help. Remove LAST_ENTRY & SEP_GROUPS variables. If any suplicate arguments were suppressed, print explanatory note. (filter_doc): Replace PEST parameter with STATE. (struct uparams): New type. (uparams): New variable. (struct uparam_name): New type. (uparam_names): New variable. (fill_in_uparams): New function. (__argp_failure, __argp_error, __argp_state_help): Make STATE parameter const. * argp.h (argp_state_help, __argp_state_help, argp_usage, __argp_usage, argp_error, __argp_error, argp_failure, __argp_failure): Make STATE parameter const. (ARGP_KEY_HELP_DUP_ARGS_NOTE): New macro. * argp.h (argp_program_bug_address): Make const. 1997-02-20 19:20 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/mman/syscalls.list: Explain msync interface. 1997-02-19 01:37 Erik Troan <ewt@redhat.com> * shadow/sgetspent_r.c: Accept empty third, fourth and fifth fields. 1997-02-20 14:44 Andreas Jaeger <aj@arthur.pfalz.de> * stdio-common/test-fseek.c: Remove temporary file, add copyright. 1997-02-20 17:51 Ulrich Drepper <drepper@cygnus.com> * sysdeps/generic/netinet/in.h: Protect contents using __BEGIN/END_DECLS. Reported by a sun <asun@zoology.washington.edu>. * inet/net/ethernet.h: Move to sysdeps/unix/sysv/linux/net. * inet/Makefile (headers): Remove net/ethernet.h. * sysdeps/unix/sysv/linux/Makefile: Install net/ethernet.h. * sysdeps/unix/sysv/linux/Dist: Distribute net/ethernet.h. 1997-02-20 15:23 Thorsten Kukuk <kukuk@weber.uni-paderborn.de> * nss/nsswitch.c (__nss_configure_lookup): Use correct test when searching in sorted array. 1997-02-20 01:24 Philip Blundell <pjb27@cam.ac.uk> * inet/getnameinfo.c: Change to use reentrant getXXbyYY functions and protect modification of global data. 1997-02-19 18:48 Miles Bader <miles@gnu.ai.mit.edu> * argp-parse.c (argp_default_parser): Set STATE->name for OPT_PROGNAME. (parser_init): Use the basename for PARSER->state.name. * argp-help.c (__argp_error, __argp_failure, __argp_state_help): Use PROGRAM_INVOCATION_SHORT_NAME instead of PROGRAM_INVOCATION_NAME. * argp-parse.c (parser_init): Set PARSER->state.flags. Make check whether PARSER has the prog name in argv[0] at the proper place. 1997-02-19 23:34 Ulrich Drepper <drepper@cygnus.com> * locale/programs/ld-time.c (time_finish): t_fmt_ampm is optional. Use default value instead of printing a warning. * nss/XXX-lookup.c: Add misssing explanation. 1997-02-19 19:14 Andreas Jaeger <aj@arthur.pfalz.de> * inet/in6_addr.c: Add missing braces. * inet/getnameinfo.c: Include <arpa/inet.h>. * sysdeps/posix/getaddrinfo.c: Include <arpa/inet.h>. 1997-02-19 11:46 Ulrich Drepper <drepper@cygnus.com> * string/strxfrm.c (STRCOLL): Correct handling of `position' levels with no non-IGNOREd element and handling of NUL byte. * string/strcoll.c (STRXFRM): Likewise. * locale/weight.h: Likewise. * shadow/sgetspent_r.c (LINE_PARSER): Add missing ')'.
Diffstat (limited to 'locale')
-rw-r--r-- | locale/programs/ld-time.c | 7 | ||||
-rw-r--r-- | locale/programs/locale.c | 20 | ||||
-rw-r--r-- | locale/programs/localedef.c | 261 | ||||
-rw-r--r-- | locale/weight.h | 30 |
4 files changed, 168 insertions, 150 deletions
diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c index b977763433..60c54deb3a 100644 --- a/locale/programs/ld-time.c +++ b/locale/programs/ld-time.c @@ -127,7 +127,12 @@ time_finish (struct localedef_t *locale) TEST_ELEM (d_t_fmt); TEST_ELEM (d_fmt); TEST_ELEM (t_fmt); - TEST_ELEM (t_fmt_ampm); + + /* According to C.Y.Alexis Cheng <alexis@vnet.ibm.com> the T_FMT_AMPM + field is optional. */ + if (time->t_fmt_ampm == NULL) + /* Use the 24h format as default. */ + time->t_fmt_ampm = time->t_fmt; /* Now process the era entries. */ if (time->cur_num_era != 0) diff --git a/locale/programs/locale.c b/locale/programs/locale.c index 5a68c562ef..e2157311c1 100644 --- a/locale/programs/locale.c +++ b/locale/programs/locale.c @@ -58,22 +58,24 @@ static void print_version (FILE *stream, struct argp_state *state); void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version; /* Definitions of arguments for argp functions. */ -static struct argp_option options[] = +static const struct argp_option options[] = { - { NULL, 0, NULL, 0, "System information:" }, - { "all-locales", 'a', NULL, 0, "Write names of available locales" }, - { "charmaps", 'm', NULL, 0, "Write names of available charmaps" }, - { NULL, 0, NULL, 0, "Modify output format:" }, - { "category-name", 'c', NULL, 0, "Write names of selected categories" }, - { "keyword-name", 'k', NULL, 0, "Write names of selected keywords" }, + { NULL, 0, NULL, 0, N_("System information:") }, + { "all-locales", 'a', NULL, OPTION_NO_USAGE, + N_("Write names of available locales") }, + { "charmaps", 'm', NULL, OPTION_NO_USAGE, + N_("Write names of available charmaps") }, + { NULL, 0, NULL, 0, N_("Modify output format:") }, + { "category-name", 'c', NULL, 0, N_("Write names of selected categories") }, + { "keyword-name", 'k', NULL, 0, N_("Write names of selected keywords") }, { NULL, 0, NULL, 0, NULL } }; /* Short description of program. */ -static const char doc[] = "Get locale-specific information."; +static const char doc[] = N_("Get locale-specific information."); /* Strings for arguments in help texts. */ -static const char args_doc[] = "NAME\n[-a|-m]"; +static const char args_doc[] = N_("NAME\n[-a|-m]"); /* Prototype for option handler. */ static error_t parse_opt (int key, char *arg, struct argp_state *state); diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c index da01d4c974..656377f9df 100644 --- a/locale/programs/localedef.c +++ b/locale/programs/localedef.c @@ -21,9 +21,9 @@ # include <config.h> #endif +#include <argp.h> #include <errno.h> #include <fcntl.h> -#include <getopt.h> #include <libintl.h> #include <locale.h> #include <stdio.h> @@ -73,20 +73,62 @@ 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; -/* Long options. */ -static const struct option long_options[] = +/* 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 = { - { "charmap", required_argument, NULL, 'f' }, - { "code-set-name", required_argument, NULL, 'u' }, - { "help", no_argument, NULL, 'h' }, - { "force", no_argument, NULL, 'c' }, - { "inputfile", required_argument, NULL, 'i' }, - { "posix", no_argument, &posix_conformance, 1 }, - { "quiet", no_argument, NULL, 'q' }, - { "verbose", no_argument, &verbose, 1}, - { "version", no_argument, NULL, 'V' }, - { NULL, 0, NULL, 0 } + options, parse_opt, args_doc, doc, NULL, more_help }; @@ -94,7 +136,6 @@ static const struct option long_options[] = void *xmalloc (size_t __n); /* Prototypes for local functions. */ -static void usage (int status) __attribute__ ((noreturn)); static void error_print (void); static const char *construct_output_path (char *path); @@ -102,13 +143,6 @@ static const char *construct_output_path (char *path); int main (int argc, char *argv[]) { - int optchar; - int do_help = 0; - int do_version = 0; - int force_output = 0; - const char *charmap_file = NULL; - const char *input_file = NULL; - const char *ucs_csn = NULL; const char *output_path; int cannot_write_why; struct charset_t *charset; @@ -119,7 +153,6 @@ main (int argc, char *argv[]) copy_list = NULL; posix_conformance = getenv ("POSIXLY_CORRECT") != NULL; error_print_progname = error_print; - verbose = 0; /* Set locale. Do not set LC_ALL because the other categories must not be affected (according to POSIX.2). */ @@ -129,83 +162,27 @@ main (int argc, char *argv[]) /* Initialize the message catalog. */ textdomain (_libc_intl_domainname); - while ((optchar = getopt_long (argc, argv, "cf:hi:u:vV", long_options, NULL)) - != -1) - switch (optchar) - { - case '\0': /* Long option. */ - break; - - case 'c': - force_output = 1; - break; - - case 'f': - charmap_file = optarg; - break; - - case 'h': - do_help = 1; - break; - - case 'i': - input_file = optarg; - break; - - case 'q': - be_quiet = 1; - verbose = 0; - break; - - case 'u': - ucs_csn = optarg; - break; - - case 'v': - verbose = 1; - be_quiet = 0; - break; - - case 'V': - do_version = 1; - break; - - default: - usage (4); /* A value >3 is forced by POSIX. */ - break; - } + /* Parse and process arguments. */ + argp_parse (&argp, argc, argv, 0, 0, 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; - /* Version information is requested. */ - if (do_version) + if (argc - optind != 1) { - printf ("localedef (GNU %s) %s\n", PACKAGE, VERSION); - printf (_("\ -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"); - printf (_("Written by %s.\n"), "Ulrich Drepper"); + /* We need exactly one non-option parameter. */ + argp_help (&argp, stdout, ARGP_HELP_SEE, + program_invocation_short_name); - exit (0); + /* XXX Currently POSIX is violated. We must exit with code 4 + but the argp_help function currently does not allow this. */ + exit (4); } - /* Help is requested. */ - if (do_help) - /* Possible violation: POSIX.2 4.35.8 defines the return value 0 as - "No errors occurred and the locale(s) were successfully created." - But giving a other value than 0 does not make sense here. It - is perhaps not that important because POSIX does not specify the - -h option for localedef. */ - usage (0); - - if (argc - optind != 1) - /* We need exactly one non-option parameter. */ - usage (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[optind]); @@ -353,6 +330,76 @@ cannot `stat' locale file `%s'"), } +/* 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) { @@ -390,40 +437,6 @@ category data requested more than once: should not happen")); } -/* Display usage information and exit. */ -static void -usage (int status) -{ - if (status != 0) - fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_invocation_name); - else - { - printf (_("\ -Usage: %s [OPTION]... name\n\ -Mandatory arguments to long options are mandatory for short options too.\n\ - -c, --force create output even if warning messages were issued\n\ - -h, --help display this help and exit\n\ - -f, --charmap=FILE symbolic character names defined in FILE\n\ - -i, --inputfile=FILE source definitions are found in FILE\n\ - --quiet Suppress warnings and information messages\n\ - -u, --code-set-name=NAME specify code set for mapping ISO 10646 elements\n\ - -v, --verbose print more messages\n\ - -V, --version output version information and exit\n\ - --posix be strictly POSIX conform\n\ -\n\ -System's directory for character maps: %s\n\ - locale files : %s\n"), - program_invocation_name, CHARMAP_PATH, LOCALE_PATH); - fputs (gettext ("\ -Report bugs using the `glibcbug' script to <bugs@gnu.ai.mit.edu>.\n"), - stdout); - } - - exit (status); -} - - /* The address of this function will be assigned to the hook in the error functions. */ static void diff --git a/locale/weight.h b/locale/weight.h index 76e6537762..96fb28e987 100644 --- a/locale/weight.h +++ b/locale/weight.h @@ -55,8 +55,8 @@ typedef struct weight_t # define collate_rules \ ((u_int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_RULES)) -static __inline int get_weight (const STRING_TYPE **str, weight_t *result); -static __inline int +static __inline void get_weight (const STRING_TYPE **str, weight_t *result); +static __inline void get_weight (const STRING_TYPE **str, weight_t *result) #else # define collate_nrules \ @@ -70,11 +70,11 @@ get_weight (const STRING_TYPE **str, weight_t *result) # define collate_rules \ ((u_int32_t *) current->values[_NL_ITEM_INDEX (_NL_COLLATE_RULES)].string) -static __inline int get_weight (const STRING_TYPE **str, weight_t *result, - struct locale_data *current, - const u_int32_t *__collate_table, - const u_int32_t *__collate_extra); -static __inline int +static __inline void get_weight (const STRING_TYPE **str, weight_t *result, + struct locale_data *current, + const u_int32_t *__collate_table, + const u_int32_t *__collate_extra); +static __inline void get_weight (const STRING_TYPE **str, weight_t *result, struct locale_data *current, const u_int32_t *__collate_table, const u_int32_t *__collate_extra) @@ -107,7 +107,7 @@ get_weight (const STRING_TYPE **str, weight_t *result, result->data[cnt].value = &__collate_extra[idx]; idx += result->data[cnt].number; } - return 0; + return; } slot += level_size; } @@ -123,7 +123,7 @@ get_weight (const STRING_TYPE **str, weight_t *result, result->data[cnt].number = 1; result->data[cnt].value = &__collate_table[slot + 1 + cnt]; } - return ch == 0; + return; } /* We now look for any collation element which starts with CH. @@ -156,14 +156,12 @@ get_weight (const STRING_TYPE **str, weight_t *result, result->data[cnt].value = &__collate_extra[idx]; idx += result->data[cnt].number; } - return 0; + return; } /* To next entry in list. */ slot += __collate_extra[slot]; } - /* NOTREACHED */ - return 0; /* To calm down gcc. */ } @@ -174,7 +172,7 @@ get_weight (const STRING_TYPE **str, weight_t *result, order. We have this strange extra macro since the functions which use the - given locale (not the global one) canot use the global tables. */ + given locale (not the global one) cannot use the global tables. */ #ifndef USE_IN_EXTENDED_LOCALE_MODEL # define call_get_weight(strp, newp) get_weight ((strp), (newp)) #else @@ -182,11 +180,11 @@ get_weight (const STRING_TYPE **str, weight_t *result, get_weight ((strp), (newp), current, collate_table, collate_extra) #endif -#define get_string(str, forw, backw) \ +#define get_string(str, forw, backw) \ do \ { \ weight_t *newp; \ - do \ + while (*str != '\0') \ { \ newp = (weight_t *) alloca (sizeof (weight_t) \ + (collate_nrules \ @@ -199,7 +197,7 @@ get_weight (const STRING_TYPE **str, weight_t *result, backw->next = newp; \ newp->next = NULL; \ backw = newp; \ + call_get_weight (&str, newp); \ } \ - while (call_get_weight (&str, newp) == 0); \ } \ while (0) |