From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] locale-archive localedef fixes
Date: Sun, 15 Apr 2007 23:29:00 -0000 [thread overview]
Message-ID: <20070415233557.GN1826@sunsite.mff.cuni.cz> (raw)
Hi!
I looked a little bit at locale-archive and found a couple of issues:
1) any time we enlarge_archive, all aliases are lost as aliases, they become
normal locale-archive entries with their own locrec, rather than sharing
a locrec. As locrec is fairly big structure, this impacts the size of
the locale-archive.
2) serial field in the header was unitialized, containing whatever happened
to be on the stack
3) since 2002 when locarchive.c was written, localedata/SUPPORTED grew
substantially, so while perhaps initially we wouldn't need to grow the
locale-archive ever for the supported locales, now we need to at least 2
times.
2007-04-15 Jakub Jelinek <jakub@redhat.com>
* locale/programs/locarchive.c (INITIAL_NUM_NAMES,
INITIAL_SIZE_STRINGS, INITIAL_NUM_LOCREC): Update to accomodate
current number of locales in SUPPORTED.
(create_archive): Initialize serial.
(enlarge_archive): Preserve aliases rather than duplicating
their locrecs.
--- libc/locale/programs/locarchive.c.jj 2005-12-07 06:47:27.000000000 +0100
+++ libc/locale/programs/locarchive.c 2007-04-16 01:15:45.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -64,9 +64,9 @@ static const char *locnames[] =
/* Size of the initial archive header. */
-#define INITIAL_NUM_NAMES 450
-#define INITIAL_SIZE_STRINGS 3500
-#define INITIAL_NUM_LOCREC 350
+#define INITIAL_NUM_NAMES 900
+#define INITIAL_SIZE_STRINGS 7500
+#define INITIAL_NUM_LOCREC 420
#define INITIAL_NUM_SUMS 2000
@@ -88,6 +88,7 @@ create_archive (const char *archivefname
/* Create the initial content of the archive. */
head.magic = AR_MAGIC;
+ head.serial = 0;
head.namehash_offset = sizeof (struct locarhead);
head.namehash_used = 0;
head.namehash_size = next_prime (INITIAL_NUM_NAMES);
@@ -217,9 +218,12 @@ oldlocrecentcmp (const void *a, const vo
}
-/* forward decl for below */
+/* forward decls for below */
static uint32_t add_locale (struct locarhandle *ah, const char *name,
locale_data_t data, bool replace);
+static void add_alias (struct locarhandle *ah, const char *alias,
+ bool replace, const char *oldname,
+ uint32_t *locrec_offset_p);
static void
enlarge_archive (struct locarhandle *ah, const struct locarhead *head)
@@ -350,6 +354,7 @@ enlarge_archive (struct locarhandle *ah,
qsort (oldlocrecarray, loccnt, sizeof (struct oldlocrecent),
oldlocrecentcmp);
+ uint32_t last_locrec_offset = 0;
for (cnt = 0; cnt < loccnt; ++cnt)
{
/* Insert this entry in the new hash table. */
@@ -368,10 +373,25 @@ enlarge_archive (struct locarhandle *ah,
old_data[idx].sum);
}
- if (add_locale (&new_ah,
- ((char *) ah->addr
- + oldnamehashtab[oldlocrecarray[cnt].cnt].name_offset),
- old_data, 0) == 0)
+ if (cnt > 0 && oldlocrecarray[cnt - 1].locrec == oldlocrec)
+ {
+ const char *oldname
+ = ((char *) ah->addr
+ + oldnamehashtab[oldlocrecarray[cnt - 1].cnt].name_offset);
+
+ add_alias (&new_ah,
+ ((char *) ah->addr
+ + oldnamehashtab[oldlocrecarray[cnt].cnt].name_offset),
+ 0, oldname, &last_locrec_offset);
+ continue;
+ }
+
+ last_locrec_offset =
+ add_locale (&new_ah,
+ ((char *) ah->addr
+ + oldnamehashtab[oldlocrecarray[cnt].cnt].name_offset),
+ old_data, 0);
+ if (last_locrec_offset == 0)
error (EXIT_FAILURE, 0, _("cannot extend locale archive file"));
}
Jakub
reply other threads:[~2007-04-15 23:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070415233557.GN1826@sunsite.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).