arn...@skeeve.com wrote:
You still need this additional change to fully move to C90.
Thanks, as Jim said we're trying to phase out pre-C99 code, but I suppose we might as well keep going for a bit longer. I installed the attached patches. The second one merges another change back from Gawk that I think is also C90-related but looks OK anyway.
>From 3ea42da7900b8c1bf4837bfd9578e7aa17c4e94d Mon Sep 17 00:00:00 2001 From: Arnold Robbins <arn...@skeeve.com> Date: Fri, 2 Sep 2016 15:27:12 -0700 Subject: [PATCH 1/2] dfa: port to C90 * src/dfa.c (dfamust): Avoid declarations after statement (Bug#21486). --- src/dfa.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dfa.c b/src/dfa.c index ff3721c..a1bcece 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -3747,9 +3747,11 @@ dfamust (struct dfa const *d) bool exact = false; bool begline = false; bool endline = false; + size_t rj; bool need_begline = false; bool need_endline = false; bool case_fold_unibyte = d->syntax.case_fold && MB_CUR_MAX == 1; + struct dfamust *dm; for (ri = 0; ri < d->tindex; ++ri) { @@ -3926,7 +3928,7 @@ dfamust (struct dfa const *d) } } - size_t rj = ri + 2; + rj = ri + 2; if (d->tokens[ri + 1] == CAT) { for (; rj < d->tindex - 1; rj += 2) @@ -3955,7 +3957,7 @@ dfamust (struct dfa const *d) } done:; - struct dfamust *dm = NULL; + dm = NULL; if (*result) { dm = xmalloc (sizeof *dm); -- 2.7.4
>From 1db0b5bf95168b776146a40fc020a255496fc881 Mon Sep 17 00:00:00 2001 From: Paul Eggert <egg...@cs.ucla.edu> Date: Fri, 2 Sep 2016 15:27:12 -0700 Subject: [PATCH 2/2] dfa: merge xalloc.h changes from Gawk * src/dfa.h (_GL_ATTRIBUTE_MALLOC): Define here, as other Gnulib .h files do. This is more consistent with Gawk. * src/dfa.c: Include xalloc.h, since dfa.h no longer does so. Include localeinfo.h later; we don't care about order, but Gawk does. --- src/dfa.c | 5 +++-- src/dfa.h | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dfa.c b/src/dfa.c index a1bcece..e009bc6 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -24,8 +24,6 @@ #include "dfa.h" -#include "localeinfo.h" - #include <assert.h> #include <ctype.h> #include <stdio.h> @@ -51,6 +49,9 @@ #include <wchar.h> +#include "xalloc.h" +#include "localeinfo.h" + /* HPUX defines these as macros in sys/param.h. */ #ifdef setbit # undef setbit diff --git a/src/dfa.h b/src/dfa.h index b8c44cc..9787d76 100644 --- a/src/dfa.h +++ b/src/dfa.h @@ -22,7 +22,11 @@ #include <stdbool.h> #include <stddef.h> -#include "xalloc.h" /* for _GL_ATTRIBUTE_MALLOC */ +#if 3 <= __GNUC__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +#else +# define _GL_ATTRIBUTE_MALLOC +#endif struct localeinfo; /* See localeinfo.h. */ -- 2.7.4