This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Why is the sort-test ignoring ':', '(' and ';' and trailing space


I just discovered that the current sort test is ignoring the three
characters ':', '(' and ';', and is skipping trailing whitespace.  Why
is this?

This make it impossible to check the sorting order of the three
characters, and also make it impossible to get correct ordering of a
line with only whitespace and an empty line.

This strange misfeature have been confusing me for a few weeks, as I
was unable to understand why the ordering of "", ";", "(" and ":"
changed from time to time, and that the characters was sorted out of
their correct order.  I suggest chaning collate-test.c and xfrm-test.c
to remove this special handling.

This is the code in question (with my patches to disable it):

Index: collate-test.c
===================================================================
RCS file: /cvs/glibc/libc/localedata/collate-test.c,v
retrieving revision 1.5
diff -u -3 -p -u -r1.5 collate-test.c
--- collate-test.c      6 Jul 2001 04:55:34 -0000       1.5
+++ collate-test.c      6 Jul 2003 20:14:51 -0000
@@ -72,10 +78,15 @@ main (int argc, char *argv[])
            }
        }
       strings[nstrings].line = strdup (line);
+#if 0
+      /* Why limit the lines at ':', '(' and ';'?) [pere 2003-07-06] */
       l = strcspn (line, ":(;");
       while (l > 0 && isspace (line[l - 1]))
        --l;
       strings[nstrings].key = strndup (line, l);
+#else
+      strings[nstrings].key = strdup (line);
+#endif
       ++nstrings;
     }

Index: xfrm-test.c
===================================================================
RCS file: /cvs/glibc/libc/localedata/xfrm-test.c,v
retrieving revision 1.5
diff -u -3 -p -u -r1.5 xfrm-test.c
--- xfrm-test.c 6 Jul 2001 04:55:34 -0000       1.5
+++ xfrm-test.c 6 Jul 2003 20:20:07 -0000
@@ -74,6 +80,7 @@ main (int argc, char *argv[])
            }
        }
       strings[nstrings].line = strdup (line);
+#if 0
       l = strcspn (line, ":(;");
       while (l > 0 && isspace (line[l - 1]))
        --l;
@@ -85,6 +92,12 @@ main (int argc, char *argv[])
       strxfrm (newp, line, needed + 1);
       strings[nstrings].xfrm = newp;
       line[l] = saved;
+#else
+      needed = strxfrm (NULL, line, 0);
+      newp = malloc (needed + 1);
+      strxfrm (newp, line, needed + 1);
+      strings[nstrings].xfrm = newp;
+#endif
       ++nstrings;
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]