fix-LC_COLLATE-rules
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Sat, 2 Dec 2017 10:07:17 +0000 (10:07 +0000)
committerAurelien Jarno <aurel32@debian.org>
Sat, 2 Dec 2017 10:07:17 +0000 (10:07 +0000)
Gbp-Pq: Topic locale
Gbp-Pq: Name fix-LC_COLLATE-rules.diff

locale/programs/ld-collate.c

index 8667249a12e8336ca1bc6f86149fca7fc91daee1..8e7d496ae2c67e1adb8d94a3a8ada66414038bf9 100644 (file)
@@ -1555,6 +1555,7 @@ collate_finish (struct localedef_t *locale, const struct charmap_t *charmap)
   int i;
   int need_undefined = 0;
   struct section_list *sect;
+  enum coll_sort_rule *orules;
   int ruleidx;
   int nr_wide_elems = 0;
 
@@ -1566,18 +1567,28 @@ collate_finish (struct localedef_t *locale, const struct charmap_t *charmap)
                                "LC_COLLATE"));
       return;
     }
+  if (nrules == 0)
+    {
+      /* An error message has already been printed:
+          empty category description not allowed.  */
+      return;
+    }
 
   /* If this assertion is hit change the type in `element_t'.  */
   assert (nrules <= sizeof (runp->used_in_level) * 8);
 
   /* Make sure that the `position' rule is used either in all sections
      or in none.  */
+  sect = collate->sections;
+  while (sect != NULL && sect->rules == NULL)
+    sect = sect->next;
+  orules = sect->rules;
   for (i = 0; i < nrules; ++i)
     for (sect = collate->sections; sect != NULL; sect = sect->next)
       if (sect != collate->current_section
          && sect->rules != NULL
          && ((sect->rules[i] & sort_position)
-             != (collate->current_section->rules[i] & sort_position)))
+             != (orules[i] & sort_position)))
        {
          WITH_CUR_LOCALE (error (0, 0, _("\
 %s: `position' must be used for a specific level in all sections or none"),
@@ -3363,6 +3374,9 @@ error while adding equivalent collating symbol"));
                      no_error = 0;
                    }
                }
+             /* Update current section.  */
+             if (collate->cursor != NULL)
+               collate->current_section = collate->cursor->section;
 
              lr_ignore_rest (ldfile, no_error);
            }