On Tue, Jun 13, 2017 at 05:05:56PM -0400, Brian Callahan wrote:
> Hi --
>
> Whoops, that was unintentional. Fixed.
>
> ~Brian
Sorry for not looking sooner.
I would rather you use two variables for -E flags. e.g., set
error_warns for one -E flag, and fatal_warns for multiple -E flags.
That way, most of your comments would be no longer necessary at all. ;)
I mean:
> Index: usr.bin/m4/eval.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/m4/eval.c,v
> retrieving revision 1.74
> diff -u -p -u -p -r1.74 eval.c
> --- usr.bin/m4/eval.c 5 Feb 2015 12:59:57 -0000 1.74
> +++ usr.bin/m4/eval.c 13 Jun 2017 21:03:15 -0000
> @@ -269,6 +269,12 @@ expand_builtin(const char *argv[], int a
> warn("%s at line %lu: include(%s)",
> CURRENT_NAME, CURRENT_LINE,
> argv[2]);
> exit_code = 1;
That comment:
> + /* exit immediately if multiple -E flags
> + */
> + if (fatal_warns == 2) {
> + killdiv();
> + exit(exit_code);
> + }
> } else
> err(1, "%s at line %lu: include(%s)",
> CURRENT_NAME, CURRENT_LINE,
> argv[2]);
> Index: usr.bin/m4/gnum4.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/m4/gnum4.c,v
> retrieving revision 1.50
> diff -u -p -u -p -r1.50 gnum4.c
> --- usr.bin/m4/gnum4.c 29 Apr 2015 00:13:26 -0000 1.50
> +++ usr.bin/m4/gnum4.c 13 Jun 2017 21:03:15 -0000
> @@ -255,11 +256,35 @@ exit_regerror(int er, regex_t *re, const
> m4errx(1, "regular expression error in %s: %s.", source, errbuf);
> }
>
> +/* warnx() plus check to see if we need to change exit code or exit.
> + * -E flag functionality.
> + */
> +void
> +m4_warnx(const char *fmt, ...)
> +{
> + va_list ap;
> +
> + va_start(ap, fmt);
> + vwarnx(fmt, ap);
> + va_end(ap);
> +
and that code:
> + /* Do nothing if no -E flags, set exit_code > 0 but keep going
> + * if one -E flag, exit immediately with exit status > 0 if
> + * two or more -E flags.
> + */
> + if (fatal_warns == 0)
> + return;
> + else if (fatal_warns == 1)
> + exit_code = 1;
> + else
> + exit(1);
> +}
> +
which would become something like:
if (fatal_warns)
exit(1);
if (error_warns)
exit_code = 1;
no need for any comment....