mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
maint: avoid "magic number exit".
* cfg.mk (local-checks-to-skip): No longer skip it. * bootstrap.conf (gnulib_modules): Add sysexits. * doc/bison.texinfo, etc/bench.pl.in, src/parse-gram.y, * src/system.h, tests/calc.at, tests/named-refs.at: Use assert where appropriate instead of "if (...) exit". Use symbolic exit status elsewhere. Conflicts: doc/bison.texinfo src/parse-gram.y
This commit is contained in:
@@ -24,6 +24,7 @@ gnulib_modules='
|
||||
javaexec-script ldexpl maintainer-makefile malloc-gnu mbschr mbsrchr
|
||||
mbswidth obstack perror pipe-posix quote quotearg realloc-posix
|
||||
spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp
|
||||
sysexits
|
||||
unistd unistd-safer unlocked-io update-copyright unsetenv verify
|
||||
warnings xalloc xalloc-die xstrndup
|
||||
|
||||
|
||||
1
cfg.mk
1
cfg.mk
@@ -47,7 +47,6 @@ local-checks-to-skip = \
|
||||
sc_prohibit_atoi_atof \
|
||||
sc_prohibit_doubled_word \
|
||||
sc_prohibit_empty_lines_at_EOF \
|
||||
sc_prohibit_magic_number_exit \
|
||||
sc_prohibit_strcmp
|
||||
|
||||
# The local directory containing the checked-out copy of gnulib used in
|
||||
|
||||
@@ -9366,8 +9366,8 @@ calcxx_driver::scan_begin ()
|
||||
yyin = stdin;
|
||||
else if (!(yyin = fopen (file.c_str (), "r")))
|
||||
@{
|
||||
error (std::string ("cannot open ") + file);
|
||||
exit (1);
|
||||
error (std::string ("cannot open ") + file + ": " + strerror(errno));
|
||||
exit (EXIT_FAILURE);
|
||||
@}
|
||||
@}
|
||||
|
||||
@@ -10045,11 +10045,17 @@ yyparse (char const *file)
|
||||
{
|
||||
yyin = fopen (file, "r");
|
||||
if (!yyin)
|
||||
exit (2);
|
||||
{
|
||||
perror ("fopen");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
/* One token only. */
|
||||
yylex ();
|
||||
if (fclose (yyin) != 0)
|
||||
exit (3);
|
||||
{
|
||||
perror ("fclose");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -291,9 +291,8 @@ yylex (void)
|
||||
static int
|
||||
power (int base, int exponent)
|
||||
{
|
||||
assert (0 <= exponent);
|
||||
int res = 1;
|
||||
if (exponent < 0)
|
||||
exit (3);
|
||||
for (/* Niente */; exponent; --exponent)
|
||||
res *= base;
|
||||
return res;
|
||||
|
||||
1
lib/.gitignore
vendored
1
lib/.gitignore
vendored
@@ -263,3 +263,4 @@
|
||||
/closeout.h
|
||||
/fpending.c
|
||||
/fpending.h
|
||||
/sysexits.in.h
|
||||
|
||||
1
m4/.gitignore
vendored
1
m4/.gitignore
vendored
@@ -167,3 +167,4 @@
|
||||
/xalloc.m4
|
||||
/xsize.m4
|
||||
/xstrndup.m4
|
||||
/sysexits.m4
|
||||
|
||||
@@ -758,8 +758,8 @@ version_check (location const *loc, char const *version)
|
||||
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
||||
{
|
||||
complain_at (*loc, "require bison %s, but have %s",
|
||||
version, PACKAGE_VERSION);
|
||||
exit (63);
|
||||
version, PACKAGE_VERSION);
|
||||
exit (EX_CONFIG);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
typedef size_t uintptr_t;
|
||||
#endif
|
||||
|
||||
#include <sysexits.h>
|
||||
|
||||
/*---------.
|
||||
| Gnulib. |
|
||||
|
||||
@@ -347,8 +347,7 @@ static int
|
||||
power (int base, int exponent)
|
||||
{
|
||||
int res = 1;
|
||||
if (exponent < 0)
|
||||
exit (3);
|
||||
assert (0 <= exponent);
|
||||
for (/* Niente */; exponent; --exponent)
|
||||
res *= base;
|
||||
return res;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# FIXME: Duplication with calc.at.
|
||||
AT_BANNER([[Named references tests.]])
|
||||
|
||||
AT_SETUP([Tutorial calculator])
|
||||
@@ -142,8 +143,7 @@ int yylex (void)
|
||||
static int power (int base, int exponent)
|
||||
{
|
||||
int res = 1;
|
||||
if (exponent < 0)
|
||||
exit (3);
|
||||
assert (0 <= exponent);
|
||||
for (/* Niente */; exponent; --exponent)
|
||||
res *= base;
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user