[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bison message counters silently wrap around; return from 'main'
From: |
Paul Eggert |
Subject: |
Re: Bison message counters silently wrap around; return from 'main' |
Date: |
Wed, 23 Oct 2002 00:37:46 -0700 (PDT) |
> From: Akim Demaille <address@hidden>
> Date: 22 Oct 2002 09:04:06 +0200
>
> This had been a question a few months ago with Autoconf: nobody
> could recall what host could fail to exit nonzero when main does.
SunOS versions 2.0 through 3.5 have that problem. See:
http://groups.google.com/groups?selm=758%40auspex.UUCP
http://groups.google.com/groups?selm=1992Sep10.003907.15391%40sq.sq.com
However, I agree that this is now too ancient even for Bison, so
I installed the following change.
2002-10-22 Paul Eggert <address@hidden>
* src/complain.c (exit) [! (STDC_HEADERS || _LIBC)]: Remove exit
decl; not needed any more now that we assume ANSI C.
(main): Use return to exit, undoing yesterday's change.
The last OS that we could find where this wouldn't work is
SunOS 3.5, and that's too old to worry about now.
Index: src/complain.c
===================================================================
RCS file: /cvsroot/bison/bison/src/complain.c,v
retrieving revision 1.15
diff -p -u -r1.15 complain.c
--- src/complain.c 22 Oct 2002 04:53:49 -0000 1.15
+++ src/complain.c 23 Oct 2002 06:56:11 -0000
@@ -29,8 +29,6 @@
#if STDC_HEADERS || _LIBC
# include <stdlib.h>
# include <string.h>
-#else
-void exit ();
#endif
#include "complain.h"
Index: src/main.c
===================================================================
RCS file: /cvsroot/bison/bison/src/main.c,v
retrieving revision 1.71
diff -p -u -r1.71 main.c
--- src/main.c 22 Oct 2002 05:07:12 -0000 1.71
+++ src/main.c 23 Oct 2002 06:56:11 -0000
@@ -74,7 +74,7 @@ main (int argc, char *argv[])
timevar_pop (TV_READER);
if (complaint_issued)
- exit (EXIT_FAILURE);
+ return EXIT_FAILURE;
/* Find useless nonterminals and productions and reduce the grammar. */
timevar_push (TV_REDUCE);
@@ -138,7 +138,7 @@ main (int argc, char *argv[])
/* Stop if there were errors, to avoid trashing previous output
files. */
if (complaint_issued)
- exit (EXIT_FAILURE);
+ return EXIT_FAILURE;
/* Lookaheads are no longer needed. */
timevar_push (TV_FREE);
@@ -177,10 +177,5 @@ main (int argc, char *argv[])
timevar_stop (TV_TOTAL);
timevar_print (stderr);
- /* Some ancient SunOS versions exit (0) if main returns, so use
- `exit' to exit with nonzero status. */
- if (complaint_issued)
- exit (EXIT_FAILURE);
-
- return EXIT_SUCCESS;
+ return complaint_issued ? EXIT_FAILURE : EXIT_SUCCESS;
}