[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
replaced `assert (x);' with `if (! (x)) abort ();' in Bison
From: |
Paul Eggert |
Subject: |
replaced `assert (x);' with `if (! (x)) abort ();' in Bison |
Date: |
Wed, 20 Nov 2002 21:33:08 -0800 (PST) |
> From: Akim Demaille <address@hidden>
> Date: 12 Nov 2002 09:29:49 +0100
> Reference:
> <http://mail.gnu.org/pipermail/bison-patches/2002-November/001346.html>
> So I guess we should remove all the asserts from bison itself.
Yes, that sounds right to me too. I installed the following patch.
2002-11-20 Paul Eggert <address@hidden>
Avoid use of <assert.h>, as the GNU Coding Standards hint that one
should use `if (! x) abort ();' rather than `assert (x);', and
anyway it's one less thing to worry about configuring.
* data/glr.c, lib/hash.c, src/system.h: Do not include <assert.h>.
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Likewise,
and replace all instances of assert with abort.
* tests/calc.at (_AT_DATA_CALC_Y): Likewise.
* tests/cxx-type.at (_AT_TEST_GLR_CXXTYPES): Likewise.
* data/glr.c (yydoAction, yyglrReduce, yysplitStack, yyresolveStates,
yyresolveAction, yyprocessOneStack): Use abort rather than assert.
* lib/hash.c (hash_lookup, hash_get_first, hash_get_next,
hash_find_entry, hash_rehash, hash_insert): Likewise.
* src/conflicts.c (resolve_sr_conflict): Likewise.
* src/lalr.c (set_goto_map, map_goto): Likewise.
* src/nullable.c (nullable_compute): Likewise.
* src/output.c (prepare_rules, token_definitions_output): Likewise.
* src/reader.c (packgram, reader): Likewise.
* src/state.c (state_new, state_free, state_transitions_set,
state_reduction_find): Likewise.
* src/symtab.c (symbol_user_token_number_set, symbol_make_alias,
symbol_pack): Likewise.
* src/tables.c (conflict_row, pack_vector): Likewise.
* src/vcg.c (get_color_str, get_textmode_str, get_shape_str,
get_layoutalgorithm_str, get_decision_str, get_orientation_str,
get_node_alignement_str, get_arrow_mode_str, get_crossing_type_str,
get_view_str, get_linestyle_str, get_arrowstyle_str): Likewise.
* lib/argmatch.h (ARRAY_CARDINALITY): Do not bother to #undef.
(ARGMATCH_CONSTRAINT): New macro.
(ARGMATCH_ASSERT): Use it.
* src/system.h (verify): New macro.
* src/getargs.c (trace_argmatch, report_argmatch): Use verify
rather than assert.
* src/tables.c (tables_generate): Likewise.
* src/struniq.c (struniq_assert): Now returns void, and aborts
if the assertion is false.
(struniq_assert_p): Remove.
* src/struniq.h: Likewise.
Index: data/glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.41
diff -p -u -r1.41 glr.c
--- data/glr.c 19 Nov 2002 07:35:29 -0000 1.41
+++ data/glr.c 21 Nov 2002 05:03:02 -0000
@@ -146,7 +146,6 @@ b4_copyright([Skeleton parser for GLR pa
[
/* This is the parser code for GLR (Generalized LR) parser. */
-#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -1038,7 +1037,8 @@ yydoAction (yyGLRStack* yystack, int yyk
{
/* Standard special case: single stack. */
yyGLRStackItem* rhs = (yyGLRStackItem*) yystack->yytops.yystates[yyk];
- assert (yyk == 0);
+ if (yyk != 0)
+ abort ();
yystack->yynextFree -= yynrhs;
yystack->yyspaceLeft += yynrhs;
yystack->yytops.yystates[0] = & yystack->yynextFree[-1].yystate;
@@ -1063,7 +1063,8 @@ yydoAction (yyGLRStack* yystack, int yyk
for (yyi = yynrhs-1, yys = yystack->yytops.yystates[yyk]; 0 <= yyi;
yyi -= 1, yys = yys->yypred)
{
- assert (yys->yypred != NULL);
+ if (! yys->yypred)
+ abort ();
yyrhsVals[yyi].yystate.yyresolved = yytrue;
yyrhsVals[yyi].yystate.yysemantics.yysval = yys->yysemantics.yysval;
yyrhsVals[yyi].yystate.yyloc = yys->yyloc;
@@ -1151,7 +1152,8 @@ yyglrReduce (yyGLRStack* yystack, size_t
0 < yyn; yyn -= 1)
{
yys = yys->yypred;
- assert (yys != NULL);
+ if (! yys)
+ abort ();
}
yyupdateSplit (yystack, yys);
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
@@ -1188,7 +1190,8 @@ yysplitStack (yyGLRStack* yystack, int y
{
if (yystack->yysplitPoint == NULL)
{
- assert (yyk == 0);
+ if (yyk != 0)
+ abort ();
yystack->yysplitPoint = yystack->yytops.yystates[yyk];
}
if (yystack->yytops.yysize >= yystack->yytops.yycapacity)
@@ -1286,7 +1289,8 @@ yyresolveStates (yyGLRState* yys, int yy
YYRESULTTAG yyflag;
if (0 < yyn)
{
- assert (yys->yypred != NULL);
+ if (! yys->yypred)
+ abort ();
yyflag = yyresolveStates (yys->yypred, yyn-1, yystack]b4_user_args[);
if (yyflag != yyok)
return yyflag;
@@ -1316,7 +1320,8 @@ yyresolveAction (yySemanticOption* yyopt
for (yyi = yynrhs-1, yys = yyopt->yystate; 0 <= yyi;
yyi -= 1, yys = yys->yypred)
{
- assert (yys->yypred != NULL);
+ if (! yys->yypred)
+ abort ();
yyrhsVals[yyi].yystate.yyresolved = yytrue;
yyrhsVals[yyi].yystate.yysemantics.yysval = yys->yysemantics.yysval;
yyrhsVals[yyi].yystate.yyloc = yys->yyloc;
@@ -1508,7 +1513,8 @@ yyprocessOneStack (yyGLRStack* yystack,
yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState;
YYDPRINTF ((stderr, "Stack %d Entering state %d\n", yyk, yystate));
- assert (yystate != YYFINAL);
+ if (yystate == YYFINAL)
+ abort ();
if (yyisDefaultedState (yystate))
{
yyrule = yydefaultAction (yystate);
Index: lib/argmatch.h
===================================================================
RCS file: /cvsroot/bison/bison/lib/argmatch.h,v
retrieving revision 1.2
diff -p -u -r1.2 argmatch.h
--- lib/argmatch.h 12 Aug 2002 14:11:02 -0000 1.2
+++ lib/argmatch.h 21 Nov 2002 05:03:02 -0000
@@ -40,11 +40,12 @@
cost, since it will be statically evalauted to `assert (0)' or
`assert (1)'. Unfortunately there is no -Wassert-0. */
-# undef ARRAY_CARDINALITY
# define ARRAY_CARDINALITY(Array) (sizeof ((Array)) / sizeof (*(Array)))
-# define ARGMATCH_ASSERT(Arglist, Vallist) \
- assert (ARRAY_CARDINALITY ((Arglist)) == ARRAY_CARDINALITY ((Vallist)) + 1)
+# define ARGMATCH_CONSTRAINT(Arglist, Vallist) \
+ (ARRAY_CARDINALITY ((Arglist)) == ARRAY_CARDINALITY ((Vallist)) + 1)
+# define ARGMATCH_ASSERT(Arglist, Vallist) \
+ assert (ARGMATCH_CONSTRAINT (Arglist, Vallist))
/* Return the index of the element of ARGLIST (NULL terminated) that
matches with ARG. If VALLIST is not NULL, then use it to resolve
Index: lib/hash.c
===================================================================
RCS file: /cvsroot/bison/bison/lib/hash.c,v
retrieving revision 1.7
diff -p -u -r1.7 hash.c
--- lib/hash.c 12 Aug 2002 14:11:02 -0000 1.7
+++ lib/hash.c 21 Nov 2002 05:03:02 -0000
@@ -33,7 +33,6 @@
typedef enum {false = 0, true = 1} bool;
#endif
#include <stdio.h>
-#include <assert.h>
#ifndef HAVE_DECL_FREE
"this configure-time declaration test was not run"
@@ -263,7 +262,8 @@ hash_lookup (const Hash_table *table, co
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- assert (bucket < table->bucket_limit);
+ if (table->bucket_limit <= bucket)
+ abort ();
if (bucket->data == NULL)
return NULL;
@@ -292,12 +292,11 @@ hash_get_first (const Hash_table *table)
if (table->n_entries == 0)
return NULL;
- for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
- if (bucket->data)
+ for (bucket = table->bucket; ; bucket++)
+ if (table->bucket_limit <= bucket)
+ abort ();
+ else if (bucket->data)
return bucket->data;
-
- assert (0);
- return NULL;
}
/* Return the user data for the entry following ENTRY, where ENTRY has been
@@ -311,7 +310,8 @@ hash_get_next (const Hash_table *table,
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- assert (bucket < table->bucket_limit);
+ if (table->bucket_limit <= bucket)
+ abort ();
/* Find next entry in the same bucket. */
for (cursor = bucket; cursor; cursor = cursor->next)
@@ -754,7 +754,9 @@ hash_find_entry (Hash_table *table, cons
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- assert (bucket < table->bucket_limit);
+ if (table->bucket_limit <= bucket)
+ abort ();
+
*bucket_head = bucket;
/* Test for empty bucket. */
@@ -848,7 +850,9 @@ hash_rehash (Hash_table *table, unsigned
= (new_table->bucket
+ new_table->hasher (data, new_table->n_buckets));
- assert (new_bucket < new_table->bucket_limit);
+ if (new_table->bucket_limit <= new_bucket)
+ abort ();
+
next = cursor->next;
if (new_bucket->data)
@@ -912,7 +916,9 @@ hash_insert (Hash_table *table, const vo
void *data;
struct hash_entry *bucket;
- assert (entry); /* cannot insert a NULL entry */
+ /* The caller cannot insert a NULL entry. */
+ if (! entry)
+ abort ();
/* If there's a matching entry already in the table, return that. */
if ((data = hash_find_entry (table, entry, &bucket, false)) != NULL)
Index: src/conflicts.c
===================================================================
RCS file: /cvsroot/bison/bison/src/conflicts.c,v
retrieving revision 1.96
diff -p -u -r1.96 conflicts.c
--- src/conflicts.c 15 Nov 2002 20:32:21 -0000 1.96
+++ src/conflicts.c 21 Nov 2002 05:03:02 -0000
@@ -231,8 +231,7 @@ resolve_sr_conflict (state_t *state, int
break;
case undef_assoc:
- assert (symbols[i]->assoc != undef_assoc);
- break;
+ abort ();
}
}
Index: src/getargs.c
===================================================================
RCS file: /cvsroot/bison/bison/src/getargs.c,v
retrieving revision 1.49
diff -p -u -r1.49 getargs.c
--- src/getargs.c 16 Nov 2002 12:31:36 -0000 1.49
+++ src/getargs.c 21 Nov 2002 05:03:03 -0000
@@ -88,7 +88,7 @@ static const int trace_types[] =
static void
trace_argmatch (char *args)
{
- ARGMATCH_ASSERT (trace_args, trace_types);
+ verify (trace_constraint, ARGMATCH_CONSTRAINT (trace_args, trace_types));
if (args)
{
args = strtok (args, ",");
@@ -139,7 +139,7 @@ static const int report_types[] =
static void
report_argmatch (char *args)
{
- ARGMATCH_ASSERT (report_args, report_types);
+ verify (report_constraint, ARGMATCH_CONSTRAINT (report_args, report_types));
args = strtok (args, ",");
do
{
Index: src/lalr.c
===================================================================
RCS file: /cvsroot/bison/bison/src/lalr.c,v
retrieving revision 1.93
diff -p -u -r1.93 lalr.c
--- src/lalr.c 12 Nov 2002 08:30:47 -0000 1.93
+++ src/lalr.c 21 Nov 2002 05:03:03 -0000
@@ -87,7 +87,8 @@ set_goto_map (void)
int i;
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
{
- assert (ngotos < GOTO_NUMBER_MAX);
+ if (ngotos >= GOTO_NUMBER_MAX)
+ abort ();
ngotos++;
goto_map[TRANSITION_SYMBOL (sp, i)]++;
}
@@ -144,8 +145,10 @@ map_goto (state_number_t state, symbol_n
low = goto_map[symbol];
high = goto_map[symbol + 1] - 1;
- while (low <= high)
+ for (;;)
{
+ if (high < low)
+ abort ();
middle = (low + high) / 2;
s = from_state[middle];
if (s == state)
@@ -155,10 +158,6 @@ map_goto (state_number_t state, symbol_n
else
high = middle - 1;
}
-
- assert (0);
- /* NOTREACHED */
- return 0;
}
Index: src/nullable.c
===================================================================
RCS file: /cvsroot/bison/bison/src/nullable.c,v
retrieving revision 1.36
diff -p -u -r1.36 nullable.c
--- src/nullable.c 1 Aug 2002 18:13:29 -0000 1.36
+++ src/nullable.c 21 Nov 2002 05:03:03 -0000
@@ -99,7 +99,8 @@ nullable_compute (void)
else
{
/* This rule has an empty RHS. */
- assert (item_number_as_rule_number (rule->rhs[0]) == ruleno);
+ if (item_number_as_rule_number (rule->rhs[0]) != ruleno)
+ abort ();
if (rule->useful && !nullable[rule->lhs->number])
{
nullable[rule->lhs->number] = 1;
Index: src/output.c
===================================================================
RCS file: /cvsroot/bison/bison/src/output.c,v
retrieving revision 1.211
diff -p -u -r1.211 output.c
--- src/output.c 15 Nov 2002 01:28:40 -0000 1.211
+++ src/output.c 21 Nov 2002 05:03:03 -0000
@@ -235,7 +235,8 @@ prepare_rules (void)
/* Merger-function index (GLR). */
merger[r] = rules[r].merger;
}
- assert (i == nritems);
+ if (i != nritems)
+ abort ();
muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems);
muscle_insert_unsigned_int_table ("prhs", prhs, 0, 0, nrules);
@@ -345,7 +346,8 @@ token_definitions_output (FILE *out)
/* At this stage, if there are literal aliases, they are part of
SYMBOLS, so we should not find symbols which are the aliases
here. */
- assert (number != USER_NUMBER_ALIAS);
+ if (number == USER_NUMBER_ALIAS)
+ abort ();
/* Skip error token. */
if (symbol == errtoken)
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.223
diff -p -u -r1.223 reader.c
--- src/reader.c 12 Nov 2002 08:30:47 -0000 1.223
+++ src/reader.c 21 Nov 2002 05:03:03 -0000
@@ -452,7 +452,8 @@ packgram (void)
p = p->next;
}
- assert (itemno == nritems);
+ if (itemno != nritems)
+ abort ();
if (trace_flag & trace_sets)
ritem_print (stderr);
@@ -539,8 +540,8 @@ reader (void)
grammar = p;
}
- assert (nsyms <= SYMBOL_NUMBER_MAX);
- assert (nsyms == ntokens + nvars);
+ if (! (nsyms <= SYMBOL_NUMBER_MAX && nsyms == ntokens + nvars))
+ abort ();
xfclose (finput);
Index: src/state.c
===================================================================
RCS file: /cvsroot/bison/bison/src/state.c,v
retrieving revision 1.25
diff -p -u -r1.25 state.c
--- src/state.c 12 Nov 2002 08:30:47 -0000 1.25
+++ src/state.c 21 Nov 2002 05:03:03 -0000
@@ -141,7 +141,8 @@ state_new (symbol_number_t accessing_sym
{
state_t *res;
- assert (nstates < STATE_NUMBER_MAX);
+ if (STATE_NUMBER_MAX <= nstates)
+ abort ();
res = STATE_ALLOC (core_size);
res->accessing_symbol = accessing_symbol;
@@ -179,7 +180,8 @@ state_free (state_t *state)
void
state_transitions_set (state_t *state, int num, state_t **transitions)
{
- assert (!state->transitions);
+ if (state->transitions)
+ abort ();
state->transitions = transitions_new (num, transitions);
}
@@ -191,7 +193,8 @@ state_transitions_set (state_t *state, i
void
state_reductions_set (state_t *state, int num, rule_t **reductions)
{
- assert (!state->reductions);
+ if (state->reductions)
+ abort ();
state->reductions = reductions_new (num, reductions);
}
@@ -215,7 +218,8 @@ state_reduction_find (state_t *state, ru
void
state_errs_set (state_t *state, int num, symbol_t **tokens)
{
- assert (!state->errs);
+ if (state->errs)
+ abort ();
state->errs = errs_new (num, tokens);
}
Index: src/struniq.c
===================================================================
RCS file: /cvsroot/bison/bison/src/struniq.c,v
retrieving revision 1.3
diff -p -u -r1.3 struniq.c
--- src/struniq.c 13 Nov 2002 06:26:24 -0000 1.3
+++ src/struniq.c 21 Nov 2002 05:03:03 -0000
@@ -51,21 +51,17 @@ struniq_new (const char *s)
}
-/*---------------------------------.
-| Return TRUE iff S is a struniq. |
-`---------------------------------*/
+/*------------------------------.
+| Abort if S is not a struniq. |
+`------------------------------*/
-bool
-struniq_assert_p (const char *s)
+void
+struniq_assert (const char *s)
{
if (!hash_lookup (struniqs_table, s))
{
error (0, 0, "not a struniq: %s", quotearg (s));
- return false;
- }
- else
- {
- return true;
+ abort ();
}
}
Index: src/struniq.h
===================================================================
RCS file: /cvsroot/bison/bison/src/struniq.h,v
retrieving revision 1.3
diff -p -u -r1.3 struniq.h
--- src/struniq.h 13 Nov 2002 06:27:18 -0000 1.3
+++ src/struniq.h 21 Nov 2002 05:03:03 -0000
@@ -41,8 +41,7 @@ struniq_t struniq_new (const char *s);
void struniqs_new (void);
/* Die if S is not a struniq. */
-#define struniq_assert(S) assert (struniq_assert_p (S));
-bool struniq_assert_p (const char *s);
+void struniq_assert (const char *s);
/* Free all the memory allocated for symbols. */
void struniqs_free (void);
Index: src/symtab.c
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.c,v
retrieving revision 1.51
diff -p -u -r1.51 symtab.c
--- src/symtab.c 12 Nov 2002 08:05:59 -0000 1.51
+++ src/symtab.c 21 Nov 2002 05:03:03 -0000
@@ -175,7 +175,8 @@ void
symbol_user_token_number_set (symbol_t *symbol,
int user_token_number, location_t location)
{
- assert (symbol->class == token_sym);
+ if (symbol->class != token_sym)
+ abort ();
if (symbol->user_token_number != USER_NUMBER_UNDEFINED
&& symbol->user_token_number != user_token_number)
@@ -252,7 +253,8 @@ symbol_make_alias (symbol_t *symbol, sym
/* symbol and symval combined are only one symbol */
nsyms--;
ntokens--;
- assert (ntokens == symbol->number || ntokens == symval->number);
+ if (ntokens != symbol->number && ntokens != symval->number)
+ abort ();
symbol->number = symval->number =
(symval->number < symbol->number) ? symval->number : symbol->number;
}
@@ -322,7 +324,8 @@ symbol_pack (symbol_t *this)
this->number = this->alias->number = 0;
else
{
- assert (this->alias->number != NUMBER_UNDEFINED);
+ if (this->alias->number == NUMBER_UNDEFINED)
+ abort ();
this->number = this->alias->number;
}
}
@@ -332,7 +335,8 @@ symbol_pack (symbol_t *this)
}
else /* this->class == token_sym */
{
- assert (this->number != NUMBER_UNDEFINED);
+ if (this->number == NUMBER_UNDEFINED)
+ abort ();
}
symbols[this->number] = this;
Index: src/system.h
===================================================================
RCS file: /cvsroot/bison/bison/src/system.h,v
retrieving revision 1.55
diff -p -u -r1.55 system.h
--- src/system.h 5 Nov 2002 23:42:51 -0000 1.55
+++ src/system.h 21 Nov 2002 05:03:03 -0000
@@ -41,7 +41,8 @@ char *alloca ();
#include <stdio.h>
-#include <assert.h>
+/* Verify a requirement at compile-time (unlike assert, which is runtime). */
+#define verify(name, assertion) struct name {char name[(assertion) ? 1 : -1];}
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
Index: src/tables.c
===================================================================
RCS file: /cvsroot/bison/bison/src/tables.c,v
retrieving revision 1.13
diff -p -u -r1.13 tables.c
--- src/tables.c 15 Nov 2002 20:32:21 -0000 1.13
+++ src/tables.c 21 Nov 2002 05:03:04 -0000
@@ -33,9 +33,9 @@
#include "conflicts.h"
#include "tables.h"
-/* Several tables will be indexed both by state and nonterminal
- numbers. We call `vector' such a thing (= either a state or a
- symbol number.
+/* Several tables are indexed both by state and nonterminal numbers.
+ We call such an index a `vector'; i.e., a vector is either a state
+ or a nonterminal number.
Of course vector_number_t ought to be wide enough to contain
state_number_t and symbol_number_t. */
@@ -190,14 +190,16 @@ conflict_row (state_t *state)
&& (actrow[j]
!= rule_number_as_item_number (reds->rules[i]->number)))
{
- assert (conflict_list_free > 0);
+ if (conflict_list_free <= 0)
+ abort ();
conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
conflict_list_cnt += 1;
conflict_list_free -= 1;
}
/* Leave a 0 at the end. */
- assert (conflict_list_free > 0);
+ if (conflict_list_free <= 0)
+ abort ();
conflict_list_cnt += 1;
conflict_list_free -= 1;
}
@@ -654,13 +656,17 @@ pack_vector (vector_number_t vector)
base_t *to = tos[i];
unsigned int *conflict_to = conflict_tos[i];
- assert (t);
+ if (! t)
+ abort ();
- for (j = lowzero - from[0]; j < (int) table_size; j++)
+ for (j = lowzero - from[0]; ; j++)
{
int k;
int ok = 1;
+ if ((int) table_size <= j)
+ abort ();
+
for (k = 0; ok && k < t; k++)
{
loc = j + state_number_as_int (from[k]);
@@ -692,13 +698,11 @@ pack_vector (vector_number_t vector)
if (loc > high)
high = loc;
- assert (BASE_MIN <= j && j <= BASE_MAX);
+ if (! (BASE_MIN <= j && j <= BASE_MAX))
+ abort ();
return j;
}
}
-#define pack_vector_succeeded 0
- assert (pack_vector_succeeded);
- return 0;
}
@@ -784,11 +788,12 @@ tables_generate (void)
{
int i;
- /* That's a poor way to make sure the sizes are properly corelated,
- in particular the signedness is not taking into account, but it's
- not useless. */
- assert (sizeof (nvectors) >= sizeof (nstates));
- assert (sizeof (nvectors) >= sizeof (nvars));
+ /* This is a poor way to make sure the sizes are properly
+ correlated. In particular the signedness is not taken into
+ account. But it's not useless. */
+ verify (sizes_are_properly_correlated,
+ (sizeof nstates <= sizeof nvectors
+ && sizeof nvars <= sizeof nvectors));
nvectors = state_number_as_int (nstates) + nvars;
Index: src/vcg.c
===================================================================
RCS file: /cvsroot/bison/bison/src/vcg.c,v
retrieving revision 1.9
diff -p -u -r1.9 vcg.c
--- src/vcg.c 30 Jun 2002 17:30:09 -0000 1.9
+++ src/vcg.c 21 Nov 2002 05:03:04 -0000
@@ -243,11 +243,8 @@ get_color_str (enum color_e c)
case orange: return "orange";
case orchid: return "orchid";
case black: return "black";
- default:
-#define A_known_default_color 0
- assert (A_known_default_color);
+ default: abort (); return NULL;
}
- return NULL;
}
static const char *
@@ -258,11 +255,8 @@ get_textmode_str (enum textmode_e t)
case centered: return "center";
case left_justify: return "left_justify";
case right_justify: return "right_justify";
- default:
-#define A_known_text_mode 0
- assert (A_known_text_mode);
+ default: abort (); return NULL;
}
- return NULL;
}
static const char *
@@ -274,11 +268,8 @@ get_shape_str (enum shape_e s)
case rhomb: return "rhomb";
case ellipse: return "ellipse";
case triangle: return "triangle";
- default:
-#define A_known_shape 0
- assert (A_known_shape);
+ default: abort (); return NULL;
}
- return NULL;
}
static const char *
@@ -300,11 +291,8 @@ get_layoutalgorithm_str (enum layoutalgo
case minbackward: return "minbackward";
case dfs: return "dfs";
case tree: return "tree";
- default:
-#define A_known_layout_algorithm 0
- assert (A_known_layout_algorithm);
+ default: abort (); return NULL;
}
- return NULL;
}
static const char *
@@ -314,11 +302,8 @@ get_decision_str (enum decision_e d)
{
case no: return "no";
case yes: return "yes";
- default:
-#define Either_yes_nor_no 0
- assert (Either_yes_nor_no);
+ default: abort (); return NULL;
}
- return NULL;
}
static const char *
@@ -330,11 +315,8 @@ get_orientation_str (enum orientation_e
case bottom_to_top: return "bottom_to_top";
case left_to_right: return "left_to_right";
case right_to_left: return "right_to_left";
- default:
-#define A_knownn_orientation 0
- assert (A_knownn_orientation);
+ default: abort (); return NULL;
}
- return NULL;
}
static const char *
@@ -345,11 +327,8 @@ get_node_alignement_str (enum alignement
case center: return "center";
case top: return "top";
case bottom: return "bottom";
- default:
-#define A_known_alignement 0
- assert (A_known_alignement);
+ default: abort (); return NULL;
}
- return NULL;
}
static const char *
@@ -359,11 +338,8 @@ get_arrow_mode_str (enum arrow_mode_e a)
{
case fixed: return "fixed";
case free_a: return "free";
- default:
-#define A_known_arrow_mode 0
- assert (A_known_arrow_mode);
+ default: abort (); return NULL;
}
- return NULL;
}
static const char *
@@ -375,11 +351,8 @@ get_crossing_type_str (enum crossing_typ
case median: return "median";
case barymedian: return "barymedian";
case medianbary: return "medianbary";
- default:
-#define A_known_crossing_type 0
- assert (A_known_crossing_type);
+ default: abort (); return NULL;
}
- return NULL;
}
static const char *
@@ -392,11 +365,8 @@ get_view_str (enum view_e v)
case pfish: return "pfish";
case fcfish: return "fcfish";
case fpfish: return "fpfish";
- default:
-#define A_known_view 0
- assert (A_known_view);
+ default: abort (); return NULL;
}
- return NULL;
}
static const char *
@@ -408,11 +378,8 @@ get_linestyle_str (enum linestyle_e l)
case dashed: return "dashed";
case dotted: return "dotted";
case invisible: return "invisible";
- default:
-#define A_known_line_style 0
- assert (A_known_line_style);
+ default: abort (); return NULL;
}
- return NULL;
}
static const char *
@@ -423,11 +390,8 @@ get_arrowstyle_str (enum arrowstyle_e a)
case solid: return "solid";
case line: return "line";
case none: return "none";
- default:
-#define A_known_arrow_style 0
- assert (A_known_arrow_style);
+ default: abort (); return NULL;
}
- return NULL;
}
/*----------------------------.
Index: tests/actions.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/actions.at,v
retrieving revision 1.23
diff -p -u -r1.23 actions.at
--- tests/actions.at 16 Nov 2002 12:30:23 -0000 1.23
+++ tests/actions.at 21 Nov 2002 05:03:04 -0000
@@ -319,7 +319,6 @@ AT_DATA_GRAMMAR([[input.y]],
%{
#include <stdio.h>
#include <stdlib.h>
-#include <assert.h>
#define RANGE(Location) (Location).first_line, (Location).last_line
static int yylex (void);
static void yyerror (const char *msg);
Index: tests/calc.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/calc.at,v
retrieving revision 1.46
diff -p -u -r1.46 calc.at
--- tests/calc.at 18 Nov 2002 07:52:13 -0000 1.46
+++ tests/calc.at 21 Nov 2002 05:03:04 -0000
@@ -46,7 +46,6 @@ AT_DATA_GRAMMAR([calc.y],
# include <string.h>
#endif
#include <ctype.h>
-#include <assert.h>
extern void perror (const char *s);
@@ -308,8 +307,10 @@ main (int argc, const char **argv)
yydebug = 1;
#endif
status = yyparse (]AT_PARAM_IF([&result, &count])[);
- assert (global_result == result);
- assert (global_count == count);
+ if (global_result != result)
+ abort ();
+ if (global_count != count)
+ abort ();
return status;
}
]])
Index: tests/cxx-type.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/cxx-type.at,v
retrieving revision 1.11
diff -p -u -r1.11 cxx-type.at
--- tests/cxx-type.at 15 Nov 2002 20:32:21 -0000 1.11
+++ tests/cxx-type.at 21 Nov 2002 05:03:04 -0000
@@ -91,7 +91,6 @@ declarator : ID { printf ("\"%s\" ", ]$
%%
-#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
@@ -99,7 +98,8 @@ declarator : ID { printf ("\"%s\" ", ]$
int
main (int argc, char** argv)
{
- assert (argc == 2);
+ if (argc != 2)
+ abort ();
if (!freopen (argv[1], "r", stdin))
abort ();
exit (yyparse ());
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- replaced `assert (x);' with `if (! (x)) abort ();' in Bison,
Paul Eggert <=