mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-24 10:22:41 +08:00
cb09a2cda2
name to find codeset name (if any) and normalize it. If the normalized name differs, look up only that in the archive. * locale/programs/locarchive.c (add_locale_to_archive): If the name contains a codeset, normalize the codeset store only the normalized name in the archive. If not, add an alias containing the locale's normalized codeset name. Apply codeset name normalization when matching entries in the alias file. * locale/programs/locarchive.c (delete_locales_from_archive): Don't decrement HEAD->namehash_used here. (add_locale): Only need to insert name string when name_offset != 0. * locale/programs/localedef.c (options): Add -A/--alias-file. (alias_file): New variable. (parse_opt): Grok -A, set that. * locale/programs/localedef.h: Declare it. * locale/programs/locarchive.c (insert_name): New function, broken out of ... (add_locale_to_archive): ... here. Call that. (add_alias): New function. (add_locale): New static function, add_locale_to_archive renamed. (add_locale_to_archive): Call that and use add_alias to add an alias for the name with codeset if the given name lacks it. (enlarge_archive): Call add_locale instead of add_locale_to_archive. * locale/Makefile (routines): Add loadarchive. * locale/loadarchive.c: New file, started from code by Ulrich Drepper. (_nl_load_locale_from_archive): New function. * locale/localeinfo.h: Declare it. * locale/findlocale.c (_nl_find_locale): If using default locale path, try _nl_load_locale_from_archive first. * locale/loadlocale.c (_nl_intern_locale_data): New function, broken out of _nl_load_locale. (_nl_load_locale): Call that. * locale/localeinfo.h: Declare it. (struct locale_data): Replace member `mmaped' with `alloc', an enum. (struct locale_data): Remove unused member `options'. * locale/findlocale.c (_nl_remove_locale): Update uses. * locale/loadlocale.c (_nl_load_locale, _nl_unload_locale): Likewise. * locale/C-collate.c: Update initializer. * locale/C-identification.c: Likewise. * locale/C-measurement.c: Likewise. * locale/C-telephone.c: Likewise. * locale/C-address.c: Likewise. * locale/C-name.c: Likewise. * locale/C-paper.c: Likewise. * locale/C-time.c: Likewise. * locale/C-numeric.c: Likewise. * locale/C-monetary.c: Likewise. * locale/C-messages.c : Likewise. * locale/C-ctype.c: Likewise. * locale/hashval.h [! LONGBITS]: Include <limits.h> here and use CHAR_BIT instead of BITSPERBYTE. * locale/localeinfo.h (_nl_find_locale, _nl_load_locale, _nl_unload_locale): Add `internal_function attribute_hidden' to decls. * locale/findlocale.c (_nl_find_locale): Add internal_function to defn. (_nl_remove_locale): Likewise. * locale/loadlocale.c (_nl_load_locale, _nl_unload_locale): Likewise. * locale/findlocale.c (_nl_default_locale_path): New variable. (_nl_find_locale): If LOCALE_PATH is null, default to that. * locale/localeinfo.h: Declare it. * locale/setlocale.c (setlocale): Use _nl_default_locale_path in place of LOCALEDIR. If no LOCPATH, pass null to _nl_find_locale. * locale/newlocale.c (__newlocale): Likewise. * misc/err.c (vwarnx, vwarn): Fix typos in libc_hidden_def uses. * inet/rexec.c (rexec_af): Add libc_hidden_def. * sysdeps/generic/morecore.c: Likewise. * signal/allocrtsig.c (__libc_current_sigrtmin): Likewise. (__libc_current_sigrtmax): Likewise. 2002-08-08 Roland McGrath <roland@redhat.com> * locale/loadlocale.c (_nl_load_locale): Don't use MAP_INHERIT. * catgets/open_catalog.c (__open_catalog): Likewise. * locale/programs/locarchive.c (INITIAL_NUM_NAMES): Renamed from typo INITIAL_NUM_NANES. (create_archive): Update use.
182 lines
5.2 KiB
C
182 lines
5.2 KiB
C
/* General definitions for localedef(1).
|
|
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 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
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, write to the Free
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
02111-1307 USA. */
|
|
|
|
#ifndef _LOCALEDEF_H
|
|
#define _LOCALEDEF_H 1
|
|
|
|
/* Get the basic locale definitions. */
|
|
#include <errno.h>
|
|
#include <locale.h>
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
|
|
#include "repertoire.h"
|
|
#include "../locarchive.h"
|
|
|
|
|
|
/* We need a bitmask for the locales. */
|
|
enum
|
|
{
|
|
CTYPE_LOCALE = 1 << LC_CTYPE,
|
|
NUMERIC_LOCALE = 1 << LC_NUMERIC,
|
|
TIME_LOCALE = 1 << LC_TIME,
|
|
COLLATE_LOCALE = 1 << LC_COLLATE,
|
|
MONETARY_LOCALE = 1 << LC_MONETARY,
|
|
MESSAGES_LOCALE = 1 << LC_MESSAGES,
|
|
PAPER_LOCALE = 1 << LC_PAPER,
|
|
NAME_LOCALE = 1 << LC_NAME,
|
|
ADDRESS_LOCALE = 1 << LC_ADDRESS,
|
|
TELEPHONE_LOCALE = 1 << LC_TELEPHONE,
|
|
MEASUREMENT_LOCALE = 1 << LC_MEASUREMENT,
|
|
IDENTIFICATION_LOCALE = 1 << LC_IDENTIFICATION,
|
|
ALL_LOCALES = (1 << LC_CTYPE
|
|
| 1 << LC_NUMERIC
|
|
| 1 << LC_TIME
|
|
| 1 << LC_COLLATE
|
|
| 1 << LC_MONETARY
|
|
| 1 << LC_MESSAGES
|
|
| 1 << LC_PAPER
|
|
| 1 << LC_NAME
|
|
| 1 << LC_ADDRESS
|
|
| 1 << LC_TELEPHONE
|
|
| 1 << LC_MEASUREMENT
|
|
| 1 << LC_IDENTIFICATION)
|
|
};
|
|
|
|
|
|
/* Opaque types for the different locales. */
|
|
struct locale_ctype_t;
|
|
struct locale_collate_t;
|
|
struct locale_monetary_t;
|
|
struct locale_numeric_t;
|
|
struct locale_time_t;
|
|
struct locale_messages_t;
|
|
struct locale_paper_t;
|
|
struct locale_name_t;
|
|
struct locale_address_t;
|
|
struct locale_telephone_t;
|
|
struct locale_measurement_t;
|
|
struct locale_identification_t;
|
|
|
|
|
|
/* Definitions for the locale. */
|
|
struct localedef_t
|
|
{
|
|
struct localedef_t *next;
|
|
|
|
const char *name;
|
|
|
|
int needed;
|
|
int avail;
|
|
|
|
union
|
|
{
|
|
void *generic;
|
|
struct locale_ctype_t *ctype;
|
|
struct locale_collate_t *collate;
|
|
struct locale_monetary_t *monetary;
|
|
struct locale_numeric_t *numeric;
|
|
struct locale_time_t *time;
|
|
struct locale_messages_t *messages;
|
|
struct locale_paper_t *paper;
|
|
struct locale_name_t *name;
|
|
struct locale_address_t *address;
|
|
struct locale_telephone_t *telephone;
|
|
struct locale_measurement_t *measurement;
|
|
struct locale_identification_t *identification;
|
|
} categories[__LC_LAST];
|
|
|
|
size_t len[__LC_LAST];
|
|
|
|
const char *copy_name[__LC_LAST];
|
|
|
|
const char *repertoire_name;
|
|
};
|
|
|
|
|
|
/* Global variables of the localedef program. */
|
|
extern int verbose;
|
|
extern int be_quiet;
|
|
extern int oldstyle_tables;
|
|
extern const char *repertoire_global;
|
|
extern int max_locarchive_open_retry;
|
|
extern bool no_archive;
|
|
extern const char *alias_file;
|
|
|
|
|
|
/* Prototypes for a few program-wide used functions. */
|
|
extern void *xmalloc (size_t __n);
|
|
extern void *xcalloc (size_t __n, size_t __size);
|
|
extern void *xrealloc (void *__p, size_t __n);
|
|
extern char *xstrdup (const char *__str);
|
|
|
|
|
|
/* Wrapper to switch LC_CTYPE back to the locale specified in the
|
|
environment for output. */
|
|
#define WITH_CUR_LOCALE(stmt) \
|
|
do { \
|
|
int saved_errno = errno; \
|
|
const char *cur_locale_ = setlocale (LC_CTYPE, NULL); \
|
|
setlocale (LC_CTYPE, ""); \
|
|
errno = saved_errno; \
|
|
stmt; \
|
|
setlocale (LC_CTYPE, cur_locale_); \
|
|
} while (0)
|
|
|
|
|
|
/* Mark given locale as to be read. */
|
|
extern struct localedef_t *add_to_readlist (int locale, const char *name,
|
|
const char *repertoire_name,
|
|
int generate,
|
|
struct localedef_t *copy_locale);
|
|
|
|
/* Find the information for the locale NAME. */
|
|
extern struct localedef_t *find_locale (int locale, const char *name,
|
|
const char *repertoire_name,
|
|
const struct charmap_t *charmap);
|
|
|
|
/* Load (if necessary) the information for the locale NAME. */
|
|
extern struct localedef_t *load_locale (int locale, const char *name,
|
|
const char *repertoire_name,
|
|
const struct charmap_t *charmap,
|
|
struct localedef_t *copy_locale);
|
|
|
|
|
|
/* Open the locale archive. */
|
|
extern void open_archive (struct locarhandle *ah, bool readonly);
|
|
|
|
/* Close the locale archive. */
|
|
extern void close_archive (struct locarhandle *ah);
|
|
|
|
/* Add given locale data to the archive. */
|
|
extern int add_locale_to_archive (struct locarhandle *ah, const char *name,
|
|
locale_data_t data, bool replace);
|
|
|
|
/* Add content of named directories to locale archive. */
|
|
extern int add_locales_to_archive (size_t nlist, char *list[], bool replace);
|
|
|
|
/* Removed named locales from archive. */
|
|
extern int delete_locales_from_archive (size_t nlist, char *list[]);
|
|
|
|
/* List content of locale archive. */
|
|
extern void show_archive_content (int verbose);
|
|
|
|
#endif /* localedef.h */
|