]> Savannah Git Hosting - gnulib.git/commitdiff
uniwbrk tests: Modernize code.
authorBruno Haible <bruno@clisp.org>
Sun, 15 Sep 2024 13:20:08 +0000 (15:20 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 15 Sep 2024 13:20:08 +0000 (15:20 +0200)
* tests/uniwbrk/test-uc-wordbreaks.c (main): Reduce the scope of local
variables. Remove memset() calls. Align expected and actial output
lines. Add comments.

ChangeLog
tests/uniwbrk/test-uc-wordbreaks.c

index 56ff30e8ef4d8758556a5f583e5a13391238ecf5..a31bdc08611b09f63ed4d200db711f315024e06f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-09-15  Bruno Haible  <bruno@clisp.org>
+
+       uniwbrk tests: Modernize code.
+       * tests/uniwbrk/test-uc-wordbreaks.c (main): Reduce the scope of local
+       variables. Remove memset() calls. Align expected and actial output
+       lines. Add comments.
+
 2024-09-15  Bruno Haible  <bruno@clisp.org>
 
        unigbrk tests: Modernize code.
index 8213446f7753cc22b01e3549a0c73aec26e5954f..1c7bb1017ee10c96c6d0aa0c7b11dc17daabd873 100644 (file)
@@ -65,10 +65,10 @@ int
 main (int argc, char *argv[])
 {
   const char *filename;
-  char line[4096];
-  int exit_code;
   FILE *stream;
+  int exit_code;
   int lineno;
+  char line[4096];
 
   if (argc != 2)
     {
@@ -88,26 +88,24 @@ main (int argc, char *argv[])
 
   exit_code = 0;
   lineno = 0;
-  while (fgets (line, sizeof line, stream))
+  while (fgets (line, sizeof (line), stream))
     {
-      char *comment;
-      const char *p;
-      uint32_t input[100];
-      char breaks[101];
-      char breaks_expected[101];
-      int i;
-
       lineno++;
 
-      memset (breaks, 0, sizeof (breaks));
-      memset (breaks_expected, 0, sizeof (breaks_expected));
-
-      comment = strchr (line, '#');
+      /* Cut off the trailing comment, if any.  */
+      char *comment = strchr (line, '#');
       if (comment != NULL)
         *comment = '\0';
+      /* Is the remaining line blank?  */
       if (line[strspn (line, " \t\r\n")] == '\0')
         continue;
 
+      const char *p;
+      uint32_t input[100];
+      char breaks[100];
+      char breaks_expected[101];
+      int i;
+
       i = 0;
       p = line;
       do
@@ -170,7 +168,7 @@ main (int argc, char *argv[])
                        input[j], wordbreakproperty_to_string (input_wbp));
             }
           fprintf (stderr, "\n");
-          fprintf (stderr, "%s:%d: actual: ", filename, lineno);
+          fprintf (stderr, "%s:%d: actual:   ", filename, lineno);
           for (j = 0; j < i - 1; j++)
             {
               int input_wbp = uc_wordbreak_property (input[j]);