]> sourceware.org Git - glibc.git/commitdiff
2002-08-14 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@gnu.org>
Thu, 15 Aug 2002 07:49:22 +0000 (07:49 +0000)
committerRoland McGrath <roland@gnu.org>
Thu, 15 Aug 2002 07:49:22 +0000 (07:49 +0000)
(oldlocrecentcmp): Compare just on file locations used.

ChangeLog
locale/programs/locarchive.c

index ebfadb8de647923875691cb2bc604210e1ad6ff6..ce6c3ed5cde51b94ffa6329ccfcd0e775f9dadbb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
-2002-08-14  Roland McGrath  <roland@frob.com>
+2002-08-14  Roland McGrath  <roland@redhat.com>
 
        * locale/locarchive.h (struct locale_category_data): Give this name to
        the type of locale_data_t's elements.
@@ -8,6 +8,7 @@
        hard-coding it to do everything but LC_CTYPE and LC_COLLATE.
        (show_archive_content): Detect categories inside LC_ALL block
        directly, instead of hard-coding.
+       (oldlocrecentcmp): Compare just on file locations used.
 
 2002-08-14  Jakub Jelinek  <jakub@redhat.com>
 
index 057fab8d2e91f06d27c8b2225cfe08bddaf3a14e..ea2cf8279274725fd530ce4c96cb9c5d76ca82bb 100644 (file)
@@ -168,6 +168,8 @@ create_archive (const char *archivefname, struct locarhandle *ah)
 }
 
 
+/* This structure and qsort comparator function are used below to sort an
+   old archive's locrec table in order of data position in the file.  */
 struct oldlocrecent
 {
   unsigned int cnt;
@@ -179,31 +181,35 @@ oldlocrecentcmp (const void *a, const void *b)
 {
   struct locrecent *la = ((const struct oldlocrecent *) a)->locrec;
   struct locrecent *lb = ((const struct oldlocrecent *) b)->locrec;
+  uint32_t start_a = -1, end_a = 0;
+  uint32_t start_b = -1, end_b = 0;
+  int cnt;
 
-  if (la->record[LC_ALL].offset < lb->record[LC_ALL].offset)
-    return -1;
-  if (la->record[LC_ALL].offset > lb->record[LC_ALL].offset)
-    return 1;
-
-  if (la->record[LC_CTYPE].offset < lb->record[LC_CTYPE].offset)
-    return -1;
-  if (la->record[LC_CTYPE].offset > lb->record[LC_CTYPE].offset)
-    return 1;
-
-  if (la->record[LC_COLLATE].offset < lb->record[LC_COLLATE].offset)
-    return -1;
-  if (la->record[LC_COLLATE].offset > lb->record[LC_COLLATE].offset)
-    return 1;
-
-  if (((const struct oldlocrecent *) a)->cnt
-      < ((const struct oldlocrecent *) b)->cnt)
-    return -1;
+  for (cnt = 0; cnt < __LC_LAST; ++cnt)
+    if (cnt != LC_ALL)
+      {
+       if (la->record[cnt].offset < start_a)
+         start_a = la->record[cnt].offset;
+       if (la->record[cnt].offset + la->record[cnt].len > end_a)
+         end_a = la->record[cnt].offset + la->record[cnt].len;
+      }
+  assert (start_a != (uint32_t)-1);
+  assert (end_a != 0);
 
-  if (((const struct oldlocrecent *) a)->cnt
-      > ((const struct oldlocrecent *) b)->cnt)
-    return 1;
+  for (cnt = 0; cnt < __LC_LAST; ++cnt)
+    if (cnt != LC_ALL)
+      {
+       if (lb->record[cnt].offset < start_b)
+         start_b = lb->record[cnt].offset;
+       if (lb->record[cnt].offset + lb->record[cnt].len > end_b)
+         end_b = lb->record[cnt].offset + lb->record[cnt].len;
+      }
+  assert (start_b != (uint32_t)-1);
+  assert (end_b != 0);
 
-  return 0;
+  if (start_a != start_b)
+    return (int)start_a - (int)start_b;
+  return (int)end_a - (int)end_b;
 }
 
 
@@ -323,10 +329,11 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head)
                                           + head->namehash_offset);
   oldlocrectab = (struct locrecent *) ((char *) ah->addr
                                       + head->locrectab_offset);
+
+  /* Sort the old locrec table in order of data position.  */
   oldlocrecarray = (struct oldlocrecent *)
                   alloca (head->namehash_size
                           * sizeof (struct oldlocrecent));
-
   for (cnt = 0, loccnt = 0; cnt < head->namehash_size; ++cnt)
     if (oldnamehashtab[cnt].locrec_offset != 0)
       {
@@ -335,7 +342,6 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head)
          = (struct locrecent *) ((char *) ah->addr
                                  + oldnamehashtab[cnt].locrec_offset);
       }
-
   qsort (oldlocrecarray, loccnt, sizeof (struct oldlocrecent),
         oldlocrecentcmp);
 
This page took 0.074058 seconds and 5 git commands to generate.