]> Savannah Git Hosting - gnulib.git/commitdiff
dfa: assume C99 in reorder_tokens
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 14 Sep 2020 01:27:07 +0000 (18:27 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 14 Sep 2020 01:41:32 +0000 (18:41 -0700)
* lib/dfa.c (reorder_tokens): Assume C99 and simplify.

ChangeLog
lib/dfa.c

index 1b5720761d7554121ae7dbf2aea1d96d1619ec1e..5f7a148e35f21863ce47076585a26fcf19ebd09c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-09-13  Paul Eggert  <eggert@cs.ucla.edu>
 
+       dfa: assume C99 in reorder_tokens
+       * lib/dfa.c (reorder_tokens): Assume C99 and simplify.
+
        dfa: fix dfa-heap-overrun failure
        * lib/dfa.c (reorder_tokens): When setting
        map[d->follows[i].elems[j].index], instead of incorrectly assuming
index 4992bcaf21098ee012389be9f96d6c64b60de54e..0fa9958fdc3fc85b1ac0a83f3bee4958f6d4cd14 100644 (file)
--- a/lib/dfa.c
+++ b/lib/dfa.c
@@ -2494,39 +2494,27 @@ compare (const void *a, const void *b)
 static void
 reorder_tokens (struct dfa *d)
 {
-  idx_t nleaves;
-  ptrdiff_t *map;
-  token *tokens;
-  position_set *follows;
-  int *constraints;
-  char *multibyte_prop;
-
-  nleaves = 0;
-
-  map = xnmalloc (d->tindex, sizeof *map);
-
+  idx_t nleaves = 0;
+  ptrdiff_t *map = xnmalloc (d->tindex, sizeof *map);
   map[0] = nleaves++;
-
   for (idx_t i = 1; i < d->tindex; i++)
     map[i] = -1;
 
-  tokens = xnmalloc (d->nleaves, sizeof *tokens);
-  follows = xnmalloc (d->nleaves, sizeof *follows);
-  constraints = xnmalloc (d->nleaves, sizeof *constraints);
-
-  if (d->localeinfo.multibyte)
-    multibyte_prop = xnmalloc (d->nleaves, sizeof *multibyte_prop);
-  else
-    multibyte_prop = NULL;
+  token *tokens = xnmalloc (d->nleaves, sizeof *tokens);
+  position_set *follows = xnmalloc (d->nleaves, sizeof *follows);
+  int *constraints = xnmalloc (d->nleaves, sizeof *constraints);
+  char *multibyte_prop = (d->localeinfo.multibyte
+                          ? xnmalloc (d->nleaves, sizeof *multibyte_prop)
+                          : NULL);
 
   for (idx_t i = 0; i < d->tindex; i++)
     for (idx_t j = 0; j < d->follows[i].nelem; j++)
-      if (map[d->follows[i].elems[j].index] == -1)
+      if (map[d->follows[i].elems[j].index] < 0)
         map[d->follows[i].elems[j].index] = nleaves++;
 
   for (idx_t i = 0; i < d->tindex; i++)
     {
-      if (map[i] == -1)
+      if (map[i] < 0)
         {
           free (d->follows[i].elems);
           d->follows[i].elems = NULL;