[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bison cleanup to use EXIT_FAILURE, EXIT_SUCCESS consistently
From: |
Paul Eggert |
Subject: |
Bison cleanup to use EXIT_FAILURE, EXIT_SUCCESS consistently |
Date: |
Mon, 21 Oct 2002 22:09:34 -0700 (PDT) |
In a couple of places Bison returns exit status 2 for failure, but
I don't see why. Also, it's not consistent about using EXIT_FAILURE
and EXIT_SUCCESS, and there is some duplicate exit code in getargs.
I installed this patch.
2002-10-21 Paul Eggert <address@hidden>
* src/complain.c (fatal_at, fatal): Use EXIT_FAILURE and EXIT_SUCCESS
rather than 1 and 0.
* src/main.c (main): Likewise.
* src/getargs.c (getargs): Likewise.
* src/reader.c (reader): Likewise.
* src/getarg.c (getargs): Remove duplicate code for
"Try `bison --help'".
* src/files.c (xfopen, xfclose): Use EXIT_FAILURE rather than 2.
What was that "2" for?
Index: src/complain.c
===================================================================
RCS file: /cvsroot/bison/bison/src/complain.c,v
retrieving revision 1.14
diff -p -u -r1.14 complain.c
--- src/complain.c 21 Oct 2002 05:28:16 -0000 1.14
+++ src/complain.c 22 Oct 2002 04:31:39 -0000
@@ -206,5 +206,5 @@ fatal (const char *message, ...)
va_end (args);
putc ('\n', stderr);
fflush (stderr);
- exit (1);
+ exit (EXIT_FAILURE);
}
Index: src/files.c
===================================================================
RCS file: /cvsroot/bison/bison/src/files.c,v
retrieving revision 1.77
diff -p -u -r1.77 files.c
--- src/files.c 21 Oct 2002 05:30:49 -0000 1.77
+++ src/files.c 22 Oct 2002 04:31:40 -0000
@@ -111,7 +111,7 @@ xfopen (const char *name, const char *mo
ptr = fopen (name, mode);
if (!ptr)
- error (2, errno, _("cannot open file `%s'"), name);
+ error (EXIT_FAILURE, errno, _("cannot open file `%s'"), name);
return ptr;
}
@@ -130,7 +130,7 @@ xfclose (FILE *ptr)
result = fclose (ptr);
if (result == EOF)
- error (2, errno, _("cannot close file"));
+ error (EXIT_FAILURE, errno, _("cannot close file"));
return result;
}
Index: src/getargs.c
===================================================================
RCS file: /cvsroot/bison/bison/src/getargs.c,v
retrieving revision 1.44
diff -p -u -r1.44 getargs.c
--- src/getargs.c 21 Oct 2002 18:15:13 -0000 1.44
+++ src/getargs.c 22 Oct 2002 04:31:40 -0000
@@ -337,11 +339,11 @@ getargs (int argc, char *argv[])
break;
case 'h':
- usage (0);
+ usage (EXIT_SUCCESS);
case 'V':
version ();
- exit (0);
+ exit (EXIT_SUCCESS);
case 'g':
/* Here, the -g and --graph=FILE options are differentiated. */
@@ -405,9 +407,7 @@ getargs (int argc, char *argv[])
break;
default:
- fprintf (stderr, _("Try `%s --help' for more information.\n"),
- program_name);
- exit (1);
+ usage (EXIT_FAILURE);
}
if (argc - optind != 1)
Index: src/main.c
===================================================================
RCS file: /cvsroot/bison/bison/src/main.c,v
retrieving revision 1.70
diff -p -u -r1.70 main.c
--- src/main.c 12 Aug 2002 14:41:48 -0000 1.70
+++ src/main.c 22 Oct 2002 04:31:40 -0000
@@ -73,8 +73,8 @@ main (int argc, char *argv[])
reader ();
timevar_pop (TV_READER);
if (complaint_issued)
- exit (1);
+ exit (EXIT_FAILURE);
/* Find useless nonterminals and productions and reduce the grammar. */
timevar_push (TV_REDUCE);
@@ -137,8 +137,8 @@ main (int argc, char *argv[])
/* Stop if there were errors, to avoid trashing previous output
files. */
if (complaint_issued)
- exit (1);
+ exit (EXIT_FAILURE);
/* Lookaheads are no longer needed. */
timevar_push (TV_FREE);
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.212
diff -p -u -r1.212 reader.c
--- src/reader.c 17 Oct 2002 17:47:33 -0000 1.212
+++ src/reader.c 22 Oct 2002 04:31:41 -0000
@@ -507,8 +507,8 @@ reader (void)
/* If something went wrong during the parsing, don't try to
continue. */
if (complaint_issued)
- exit (1);
+ exit (EXIT_FAILURE);
/* Grammar has been read. Do some checking */
if (nrules == 0)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Bison cleanup to use EXIT_FAILURE, EXIT_SUCCESS consistently,
Paul Eggert <=