aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog51
-rw-r--r--include/libintl.h4
-rw-r--r--locale/Makefile9
-rw-r--r--locale/hashval.h41
-rw-r--r--locale/locarchive.h97
-rw-r--r--locale/programs/ld-address.c2
-rw-r--r--locale/programs/ld-collate.c4
-rw-r--r--locale/programs/ld-ctype.c3
-rw-r--r--locale/programs/ld-identification.c3
-rw-r--r--locale/programs/ld-measurement.c2
-rw-r--r--locale/programs/ld-messages.c2
-rw-r--r--locale/programs/ld-monetary.c2
-rw-r--r--locale/programs/ld-name.c2
-rw-r--r--locale/programs/ld-numeric.c2
-rw-r--r--locale/programs/ld-paper.c2
-rw-r--r--locale/programs/ld-telephone.c2
-rw-r--r--locale/programs/ld-time.c2
-rw-r--r--locale/programs/localedef.c95
-rw-r--r--locale/programs/localedef.h28
-rw-r--r--locale/programs/locarchive.c931
-rw-r--r--locale/programs/locfile.c61
-rw-r--r--locale/programs/locfile.h8
-rw-r--r--locale/programs/simple-hash.c30
-rw-r--r--locale/programs/simple-hash.h4
24 files changed, 1317 insertions, 70 deletions
diff --git a/ChangeLog b/ChangeLog
index 72a1108891..21a66a2e22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,46 @@
+2002-04-18 Ulrich Drepper <drepper@redhat.com>
+
+ * locale/programs/locfile.c (to_archive): New variable. To collect
+ data which has to be added to the locale archive.
+ (write_all_categories): Take new third parameter with locale name.
+ Unless no_archive flag set add new locale data to the archive
+ (write_locale_data): Unless no-archive flag set store generated data
+ in to_archive data structure instead of generation output file.
+ Add new parameter with locale category index.
+ * locale/programs/locfile.h: Add new parameters in declaractions of
+ write_all_categories and write_locale_data.
+ * locale/programs/localedef.c: Recognize --no-archive, --list-archive,
+ --add-to-archive, and --delete-from-archive options. Pass extra
+ parameter to write_all_categories.
+ * locale/programs/localedef.h: Add prototypes for functions in
+ locarchive.c.
+ * locale/locarchive.h: New file.
+ * locale/programs/locarchive.c: New file.
+ * locale/Makefile (distribute): Add programs/locarchive.c and
+ locarchive.h.
+ (localedef-modules): Add md5 and locarchive.
+ Add vpath to crypt subdir for md5.c.
+
+ * locale/programs/ld-address.c: Pass locale category ID as new second
+ parameter to write_locale_data.
+ * locale/programs/ld-collate.c: Likewise.
+ * locale/programs/ld-ctype.c: Likewise.
+ * locale/programs/ld-identification.c: Likewise.
+ * locale/programs/ld-measurement.c: Likewise.
+ * locale/programs/ld-messages.c: Likewise.
+ * locale/programs/ld-monetary.c: Likewise.
+ * locale/programs/ld-name.c: Likewise.
+ * locale/programs/ld-numeric.c: Likewise.
+ * locale/programs/ld-paper.c: Likewise.
+ * locale/programs/ld-telephone.c: Likewise.
+ * locale/programs/ld-time.c: Likewise.
+
+ * locale/simple-hash.c: Move compute_hashval function from here...
+ * locale/hashval.h: ...to here. New file.
+ * locale/simple-hash.h: Add prototype for compute_hashval.
+
+ * include/libintl.h: Minor cleanups.
+
2002-04-16 Ulrich Drepper <drepper@redhat.com>
* posix/regcomp.c (gettext): Use INTUSE for _libc_intl_domainname.
@@ -13,10 +56,10 @@
2002-02-17 Andreas Schwab <schwab@suse.de>
- * reldep7.c: New file.
- * reldep7mod1.c: New file.
- * reldep7mod2.c: New file.
- * Makefile: Add rules to build and run reldep7.
+ * elf/reldep7.c: New file.
+ * elf/reldep7mod1.c: New file.
+ * elf/reldep7mod2.c: New file.
+ * elf/Makefile: Add rules to build and run reldep7.
2002-04-14 Jakub Jelinek <jakub@redhat.com>
diff --git a/include/libintl.h b/include/libintl.h
index 99f7787ba2..146c9300f6 100644
--- a/include/libintl.h
+++ b/include/libintl.h
@@ -30,10 +30,10 @@ extern const char _libc_intl_domainname_internal[] attribute_hidden;
/* This is defined as an optimizing macro, so use it. */
# if !defined NOT_IN_libc && defined SHARED
# define _(msgid) \
- __dcgettext_internal (_libc_intl_domainname_internal, (msgid), LC_MESSAGES)
+ __dcgettext_internal (_libc_intl_domainname_internal, msgid, LC_MESSAGES)
# else
# define _(msgid) \
- __dcgettext (_libc_intl_domainname, (msgid), LC_MESSAGES)
+ __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
#endif
#endif
diff --git a/locale/Makefile b/locale/Makefile
index 03ed1b66fa..7a773f104f 100644
--- a/locale/Makefile
+++ b/locale/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991, 92, 1995-1999, 2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1991,92,1995-1999,2000,2001,2002 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -26,6 +26,7 @@ distribute = localeinfo.h categories.def iso-639.def iso-3166.def \
iso-4217.def weight.h weightwc.h strlen-hash.h elem-hash.h \
indigits.h indigitswc.h outdigits.h outdigitswc.h \
coll-lookup.h C-translit.h.in C-translit.h gen-translit.pl \
+ locarchive.h \
$(addprefix programs/, \
locale.c localedef.c \
$(localedef-modules:=.c) $(locale-modules:=.c) \
@@ -33,7 +34,7 @@ distribute = localeinfo.h categories.def iso-639.def iso-3166.def \
charmap-kw.gperf charmap-kw.h locfile-token.h \
locfile-kw.gperf locfile-kw.h linereader.h \
locfile.h charmap.h repertoire.h localedef.h \
- 3level.h charmap-dir.h)
+ 3level.h charmap-dir.h locarchive.c)
routines = setlocale findlocale loadlocale localeconv nl_langinfo \
nl_langinfo_l mb_cur_max \
newlocale duplocale freelocale
@@ -54,12 +55,12 @@ extra-libs-others = $(extra-libs)
libBrokenLocale-routines = broken_cur_max
subdir-dirs = programs
-vpath %.c programs
+vpath %.c programs ../crypt
vpath %.h programs
vpath %.gperf programs
localedef-modules := $(categories:%=ld-%) charmap linereader locfile \
- repertoire
+ repertoire md5 locarchive
locale-modules := locale-spec
lib-modules := charmap-dir simple-hash xmalloc xstrdup
diff --git a/locale/hashval.h b/locale/hashval.h
new file mode 100644
index 0000000000..15ec1244cf
--- /dev/null
+++ b/locale/hashval.h
@@ -0,0 +1,41 @@
+/* Implement simple hashing table with string based keys.
+ Copyright (C) 1994-1997, 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, October 1994.
+
+ 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. */
+
+unsigned long
+compute_hashval (key, keylen)
+ const void *key;
+ size_t keylen;
+{
+ size_t cnt;
+ unsigned long int hval;
+
+ /* Compute the hash value for the given string. The algorithm
+ is taken from [Aho,Sethi,Ullman], modified to reduce the number of
+ collisions for short strings with very varied bit patterns.
+ See http://www.clisp.org/haible/hashfunc.html. */
+ cnt = 0;
+ hval = keylen;
+ while (cnt < keylen)
+ {
+ hval = (hval << 9) | (hval >> (LONGBITS - 9));
+ hval += (unsigned long int) *(((char *) key) + cnt++);
+ }
+ return hval != 0 ? hval : ~((unsigned long) 0);
+}
diff --git a/locale/locarchive.h b/locale/locarchive.h
new file mode 100644
index 0000000000..2005989598
--- /dev/null
+++ b/locale/locarchive.h
@@ -0,0 +1,97 @@
+/* Definitions for locale archive handling.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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 _LOCARCHIVE_H
+#define _LOCARCHIVE_H 1
+
+#include <stdint.h>
+
+
+#define AR_MAGIC 0xde020109
+
+struct locarhead
+{
+ uint32_t magic;
+ /* Serial number. */
+ uint32_t serial;
+ /* Name hash table. */
+ uint32_t namehash_offset;
+ uint32_t namehash_used;
+ uint32_t namehash_size;
+ /* String table. */
+ uint32_t string_offset;
+ uint32_t string_used;
+ uint32_t string_size;
+ /* Table with locale records. */
+ uint32_t locrectab_offset;
+ uint32_t locrectab_used;
+ uint32_t locrectab_size;
+ /* MD5 sum hash table. */
+ uint32_t sumhash_offset;
+ uint32_t sumhash_used;
+ uint32_t sumhash_size;
+};
+
+
+struct namehashent
+{
+ /* Hash value of the name. */
+ uint32_t hashval;
+ /* Offset of the name in the string table. */
+ uint32_t name_offset;
+ /* Offset of the locale record. */
+ uint32_t locrec_offset;
+};
+
+
+struct sumhashent
+{
+ /* MD5 sum. */
+ char sum[16];
+ /* Offset of the file in the archive. */
+ uint32_t file_offset;
+};
+
+struct locrecent
+{
+ struct
+ {
+ uint32_t offset;
+ uint32_t len;
+ } record[__LC_LAST];
+};
+
+
+struct locarhandle
+{
+ int fd;
+ void *addr;
+ size_t len;
+};
+
+
+/* In memory data for the locales with their checksums. */
+typedef struct
+{
+ off64_t size;
+ void *addr;
+ char sum[16];
+} locale_data_t[__LC_LAST];
+
+#endif /* locarchive.h */
diff --git a/locale/programs/ld-address.c b/locale/programs/ld-address.c
index 52b91cfc28..5c8efaa282 100644
--- a/locale/programs/ld-address.c
+++ b/locale/programs/ld-address.c
@@ -422,7 +422,7 @@ address_output (struct localedef_t *locale, const struct charmap_t *charmap,
assert (cnt == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS));
- write_locale_data (output_path, "LC_ADDRESS",
+ write_locale_data (output_path, LC_ADDRESS, "LC_ADDRESS",
3 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS), iov);
}
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
index 191194799d..ca58266839 100644
--- a/locale/programs/ld-collate.c
+++ b/locale/programs/ld-collate.c
@@ -1987,7 +1987,7 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
assert (cnt == _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE));
- write_locale_data (output_path, "LC_COLLATE", 2 + cnt, iov);
+ write_locale_data (output_path, LC_COLLATE, "LC_COLLATE", 2 + cnt, iov);
return;
}
@@ -2571,7 +2571,7 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
assert (cnt == _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE));
- write_locale_data (output_path, "LC_COLLATE", 2 + cnt, iov);
+ write_locale_data (output_path, LC_COLLATE, "LC_COLLATE", 2 + cnt, iov);
obstack_free (&weightpool, NULL);
obstack_free (&extrapool, NULL);
diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
index 1026133dc2..eed2e94732 100644
--- a/locale/programs/ld-ctype.c
+++ b/locale/programs/ld-ctype.c
@@ -1214,7 +1214,8 @@ ctype_output (struct localedef_t *locale, const struct charmap_t *charmap,
assert (2 + elem + offset == (nelems + 2 * ctype->nr_charclass
+ ctype->map_collection_nr + 4 + 2));
- write_locale_data (output_path, "LC_CTYPE", 2 + elem + offset, iov);
+ write_locale_data (output_path, LC_CTYPE, "LC_CTYPE", 2 + elem + offset,
+ iov);
}
diff --git a/locale/programs/ld-identification.c b/locale/programs/ld-identification.c
index 481e4e79c4..ae5ea6fb16 100644
--- a/locale/programs/ld-identification.c
+++ b/locale/programs/ld-identification.c
@@ -291,7 +291,8 @@ identification_output (struct localedef_t *locale,
assert (cnt == (2 + _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION)
+ (__LC_LAST - 2)));
- write_locale_data (output_path, "LC_IDENTIFICATION", cnt, iov);
+ write_locale_data (output_path, LC_IDENTIFICATION, "LC_IDENTIFICATION", cnt,
+ iov);
}
diff --git a/locale/programs/ld-measurement.c b/locale/programs/ld-measurement.c
index 75219bdf9f..2aa75b47dc 100644
--- a/locale/programs/ld-measurement.c
+++ b/locale/programs/ld-measurement.c
@@ -150,7 +150,7 @@ measurement_output (struct localedef_t *locale,
assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT));
- write_locale_data (output_path, "LC_MEASUREMENT",
+ write_locale_data (output_path, LC_MEASUREMENT, "LC_MEASUREMENT",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT), iov);
}
diff --git a/locale/programs/ld-messages.c b/locale/programs/ld-messages.c
index fadf82757f..d5cc393e4b 100644
--- a/locale/programs/ld-messages.c
+++ b/locale/programs/ld-messages.c
@@ -226,7 +226,7 @@ messages_output (struct localedef_t *locale, const struct charmap_t *charmap,
assert (cnt + 1 == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES));
- write_locale_data (output_path, "LC_MESSAGES",
+ write_locale_data (output_path, LC_MESSAGES, "LC_MESSAGES",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES), iov);
}
diff --git a/locale/programs/ld-monetary.c b/locale/programs/ld-monetary.c
index 4bb7c0bba4..4c36c505ba 100644
--- a/locale/programs/ld-monetary.c
+++ b/locale/programs/ld-monetary.c
@@ -612,7 +612,7 @@ monetary_output (struct localedef_t *locale, const struct charmap_t *charmap,
assert (cnt == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY));
- write_locale_data (output_path, "LC_MONETARY",
+ write_locale_data (output_path, LC_MONETARY, "LC_MONETARY",
3 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY), iov);
}
diff --git a/locale/programs/ld-name.c b/locale/programs/ld-name.c
index 11e0ace7d6..80b42f7048 100644
--- a/locale/programs/ld-name.c
+++ b/locale/programs/ld-name.c
@@ -210,7 +210,7 @@ name_output (struct localedef_t *locale, const struct charmap_t *charmap,
assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_NAME));
- write_locale_data (output_path, "LC_NAME",
+ write_locale_data (output_path, LC_NAME, "LC_NAME",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_NAME), iov);
}
diff --git a/locale/programs/ld-numeric.c b/locale/programs/ld-numeric.c
index 6e385f2be6..594c0c8c1b 100644
--- a/locale/programs/ld-numeric.c
+++ b/locale/programs/ld-numeric.c
@@ -187,7 +187,7 @@ numeric_output (struct localedef_t *locale, const struct charmap_t *charmap,
assert (cnt + 1 == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC));
- write_locale_data (output_path, "LC_NUMERIC",
+ write_locale_data (output_path, LC_NUMERIC, "LC_NUMERIC",
3 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC), iov);
}
diff --git a/locale/programs/ld-paper.c b/locale/programs/ld-paper.c
index 2dce9ca8da..2910954f04 100644
--- a/locale/programs/ld-paper.c
+++ b/locale/programs/ld-paper.c
@@ -154,7 +154,7 @@ paper_output (struct localedef_t *locale, const struct charmap_t *charmap,
assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_PAPER));
- write_locale_data (output_path, "LC_PAPER",
+ write_locale_data (output_path, LC_PAPER, "LC_PAPER",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_PAPER), iov);
}
diff --git a/locale/programs/ld-telephone.c b/locale/programs/ld-telephone.c
index 01dcf36008..5a60c016b0 100644
--- a/locale/programs/ld-telephone.c
+++ b/locale/programs/ld-telephone.c
@@ -218,7 +218,7 @@ telephone_output (struct localedef_t *locale, const struct charmap_t *charmap,
assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE));
- write_locale_data (output_path, "LC_TELEPHONE",
+ write_locale_data (output_path, LC_TELEPHONE, "LC_TELEPHONE",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE), iov);
}
diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c
index 32d9dad971..2ff56b0034 100644
--- a/locale/programs/ld-time.c
+++ b/locale/programs/ld-time.c
@@ -906,7 +906,7 @@ time_output (struct localedef_t *locale, const struct charmap_t *charmap,
+ 2 + time->num_era * 10 - 1));
assert (last_idx == _NL_ITEM_INDEX (_NL_NUM_LC_TIME));
- write_locale_data (output_path, "LC_TIME", 2 + cnt, iov);
+ write_locale_data (output_path, LC_TIME, "LC_TIME", 2 + cnt, iov);
}
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
index 3c159560e9..526f2025e7 100644
--- a/locale/programs/localedef.c
+++ b/locale/programs/localedef.c
@@ -27,6 +27,7 @@
#include <libintl.h>
#include <locale.h>
#include <mcheck.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -56,7 +57,8 @@ int verbose;
/* If not zero suppress warnings and information messages. */
int be_quiet;
-/* If not zero, produce old-style hash table instead of 3-level access tables. */
+/* If not zero, produce old-style hash table instead of 3-level access
+ tables. */
int oldstyle_tables;
/* If not zero force output even if warning were issued. */
@@ -77,15 +79,38 @@ const char *repertoire_global;
/* List of all locales. */
static struct localedef_t *locales;
+/* If true don't add locale data to archive. */
+bool no_archive;
+
+/* If true add named locales to archive. */
+static bool add_to_archive;
+
+/* If true delete named locales from archive. */
+static bool delete_from_archive;
+
+/* If true replace archive content when adding. */
+static bool replace_archive;
+
+/* If true list archive content. */
+static bool list_archive;
+
+/* Maximum number of retries when opening the locale archive. */
+int max_locarchive_open_retry = 10;
+
/* 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
-#define OPT_OLDSTYLE 3
-#define OPT_PREFIX 4
+#define OPT_POSIX 301
+#define OPT_QUIET 302
+#define OPT_OLDSTYLE 303
+#define OPT_PREFIX 304
+#define OPT_NO_ARCHIVE 305
+#define OPT_ADD_TO_ARCHIVE 306
+#define OPT_REPLACE 307
+#define OPT_DELETE_FROM_ARCHIVE 308
+#define OPT_LIST_ARCHIVE 309
/* Definitions of arguments for argp functions. */
static const struct argp_option options[] =
@@ -106,6 +131,15 @@ static const struct argp_option options[] =
{ "quiet", OPT_Q