diff options
author | Eric Blake <ebb9@byu.net> | 2007-11-05 20:37:52 -0700 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2007-11-05 20:37:52 -0700 |
commit | 892295b5672cc38a55b1a727fc11297d145cfe18 (patch) | |
tree | 77f727c6dad27603437cf299548396ba77f0062a | |
parent | 94692e6c0e3287149061f5e0bd1c4d5dc02e2fd8 (diff) | |
download | m4-892295b5672cc38a55b1a727fc11297d145cfe18.tar.gz |
Use assert, rather than INTERNAL ERROR.
* src/m4.h: Include <assert.h>.
* src/builtin.c (m4_dumpdef, define_macro, m4_defn): Use assert.
* src/debug.c (trace_pre): Likewise.
* src/eval.c (evaluate, cmp_term, shift_term, mult_term):
Likewise.
* src/freeze.c (produce_frozen_state): Likewise.
* src/input.c (push_string_init, pop_input, init_macro_token)
(peek_input, next_char_1, set_word_regexp): Likewise.
* src/m4.c (main): Likewise.
* src/macro.c (expand_token, expand_argument, call_macro):
Likewise.
* src/output.c (make_diversion): Likewise.
* src/symtab.c (symtab_init): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | src/builtin.c | 26 | ||||
-rw-r--r-- | src/debug.c | 6 | ||||
-rw-r--r-- | src/eval.c | 12 | ||||
-rw-r--r-- | src/freeze.c | 6 | ||||
-rw-r--r-- | src/input.c | 37 | ||||
-rw-r--r-- | src/m4.c | 2 | ||||
-rw-r--r-- | src/m4.h | 1 | ||||
-rw-r--r-- | src/macro.c | 9 | ||||
-rw-r--r-- | src/output.c | 2 | ||||
-rw-r--r-- | src/symtab.c | 10 |
11 files changed, 50 insertions, 76 deletions
@@ -1,5 +1,20 @@ 2007-11-05 Eric Blake <ebb9@byu.net> + Use assert, rather than INTERNAL ERROR. + * src/m4.h: Include <assert.h>. + * src/builtin.c (m4_dumpdef, define_macro, m4_defn): Use assert. + * src/debug.c (trace_pre): Likewise. + * src/eval.c (evaluate, cmp_term, shift_term, mult_term): + Likewise. + * src/freeze.c (produce_frozen_state): Likewise. + * src/input.c (push_string_init, pop_input, init_macro_token) + (peek_input, next_char_1, set_word_regexp): Likewise. + * src/m4.c (main): Likewise. + * src/macro.c (expand_token, expand_argument, call_macro): + Likewise. + * src/output.c (make_diversion): Likewise. + * src/symtab.c (symtab_init): Likewise. + Use build-aux directory. * configure.ac (PACKAGE, VERSION): Delete, since Automake does this now. diff --git a/src/builtin.c b/src/builtin.c index 0b7f5c13..280344f2 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -364,7 +364,7 @@ set_macro_sequence (const char *regexp) { const char *msg; - if (! regexp) + if (!regexp) regexp = DEFAULT_MACRO_SEQUENCE; else if (regexp[0] == '\0') { @@ -697,8 +697,7 @@ define_macro (int argc, token_data **argv, symbol_lookup mode) break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad token data type in define_macro ()")); + assert (!"define_macro"); abort (); } } @@ -900,16 +899,14 @@ m4_dumpdef (struct obstack *obs, int argc, token_data **argv) bp = find_builtin_by_addr (SYMBOL_FUNC (data.base[0])); if (bp == NULL) { - M4ERROR ((warning_status, 0, "\ -INTERNAL ERROR: builtin not found in builtin table")); + assert (!"m4_dumpdef"); abort (); } DEBUG_PRINT1 ("<%s>\n", bp->name); break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad token data type in m4_dumpdef ()")); + assert (!"m4_dumpdef"); abort (); break; } @@ -946,7 +943,7 @@ m4_builtin (struct obstack *obs, int argc, token_data **argv) else { int i; - if (! bp->groks_macro_args) + if (!bp->groks_macro_args) for (i = 2; i < argc; i++) if (TOKEN_DATA_TYPE (argv[i]) != TOKEN_TEXT) { @@ -987,7 +984,7 @@ m4_indir (struct obstack *obs, int argc, token_data **argv) else { int i; - if (! SYMBOL_MACRO_ARGS (s)) + if (!SYMBOL_MACRO_ARGS (s)) for (i = 2; i < argc; i++) if (TOKEN_DATA_TYPE (argv[i]) != TOKEN_TEXT) { @@ -1042,8 +1039,7 @@ builtin `%s' requested by frozen file is not supported", ARG (i))); break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad symbol type in m4_defn ()")); + assert (!"m4_defn"); abort (); } } @@ -1061,13 +1057,13 @@ builtin `%s' requested by frozen file is not supported", ARG (i))); # define M4SYSVAL_TERMSIGBITS(status) \ (WIFSIGNALED (status) ? WTERMSIG (status) << 8 : 0) -#else /* ! UNIX && ! defined WEXITSTATUS */ +#else /* !UNIX && !defined WEXITSTATUS */ /* Platforms such as mingw do not support the notion of reporting which signal terminated a process. Furthermore if WEXITSTATUS was not provided, then the exit value is in the low eight bits. */ # define M4SYSVAL_EXITBITS(status) status # define M4SYSVAL_TERMSIGBITS(status) 0 -#endif /* ! UNIX && ! defined WEXITSTATUS */ +#endif /* !UNIX && !defined WEXITSTATUS */ /* Fallback definitions if <stdlib.h> or <sys/wait.h> are inadequate. */ #ifndef WEXITSTATUS @@ -1956,7 +1952,7 @@ m4_translit (struct obstack *obs, int argc, token_data **argv) hence the found map. */ for ( ; (ch = *from) != '\0'; from++) { - if (! found[ch]) + if (!found[ch]) { found[ch] = 1; map[ch] = *to; @@ -1967,7 +1963,7 @@ m4_translit (struct obstack *obs, int argc, token_data **argv) for (data = ARG (1); (ch = *data) != '\0'; data++) { - if (! found[ch]) + if (!found[ch]) obstack_1grow (obs, ch); else if (map[ch]) obstack_1grow (obs, map[ch]); diff --git a/src/debug.c b/src/debug.c index c94a7461..998ccb9b 100644 --- a/src/debug.c +++ b/src/debug.c @@ -398,16 +398,14 @@ trace_pre (const char *name, int id, int argc, token_data **argv) bp = find_builtin_by_addr (TOKEN_DATA_FUNC (argv[i])); if (bp == NULL) { - M4ERROR ((warning_status, 0, "\ -INTERNAL ERROR: builtin not found in builtin table! (trace_pre ())")); + assert (!"trace_pre"); abort (); } trace_format ("<%s>", bp->name); break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad token data type (trace_pre ())")); + assert (!"trace_pre"); abort (); } @@ -352,8 +352,7 @@ evaluate (const char *expr, int32_t *val) break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad error code in evaluate ()")); + assert (!"evaluate"); abort (); } @@ -584,8 +583,7 @@ cmp_term (eval_token et, int32_t *v1) break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad comparison operator in cmp_term ()")); + assert (!"cmp_term"); abort (); } } @@ -638,8 +636,7 @@ shift_term (eval_token et, int32_t *v1) break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad shift operator in shift_term ()")); + assert (!"shift_term"); abort (); } } @@ -735,8 +732,7 @@ mult_term (eval_token et, int32_t *v1) break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad operator in mult_term ()")); + assert (!"mult_term"); abort (); } } diff --git a/src/freeze.c b/src/freeze.c index 18280f7b..2858e64d 100644 --- a/src/freeze.c +++ b/src/freeze.c @@ -115,8 +115,7 @@ produce_frozen_state (const char *name) bp = find_builtin_by_addr (SYMBOL_FUNC (sym)); if (bp == NULL) { - M4ERROR ((warning_status, 0, "\ -INTERNAL ERROR: builtin not found in builtin table!")); + assert (!"produce_frozen_state"); abort (); } xfprintf (file, "F%d,%d\n", @@ -132,8 +131,7 @@ INTERNAL ERROR: builtin not found in builtin table!")); break; default: - M4ERROR ((warning_status, 0, "\ -INTERNAL ERROR: bad token data type in freeze_one_symbol ()")); + assert (!"produce_frozen_state"); abort (); break; } diff --git a/src/input.c b/src/input.c index b81d0860..23903f39 100644 --- a/src/input.c +++ b/src/input.c @@ -241,13 +241,7 @@ push_macro (builtin_func *func) struct obstack * push_string_init (void) { - if (next != NULL) - { - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: recursive push_string!")); - abort (); - } - + assert (next == NULL); next = (input_block *) obstack_alloc (current_input, sizeof (struct input_block)); next->type = INPUT_STRING; @@ -357,8 +351,7 @@ pop_input (void) break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: input stack botch in pop_input ()")); + assert (!"pop_input"); abort (); } obstack_free (current_input, isp); @@ -411,13 +404,7 @@ pop_wrapup (void) static void init_macro_token (token_data *td) { - if (isp->type != INPUT_MACRO) - { - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad call to init_macro_token ()")); - abort (); - } - + assert (isp->type == INPUT_MACRO); TOKEN_DATA_TYPE (td) = TOKEN_FUNC; TOKEN_DATA_FUNC (td) = isp->u.func; } @@ -463,8 +450,7 @@ peek_input (void) return CHAR_MACRO; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: input stack botch in peek_input ()")); + assert (!"peek_input"); abort (); } block = block->prev; @@ -541,8 +527,7 @@ next_char_1 (void) return CHAR_MACRO; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: input stack botch in next_char ()")); + assert (!"next_char_1"); abort (); } @@ -782,15 +767,9 @@ set_word_regexp (const char *regexp) Can't rely on struct assigns working, so redo the compilation. */ regfree (&word_regexp); msg = re_compile_pattern (regexp, strlen (regexp), &word_regexp); + assert (!msg); re_set_registers (&word_regexp, ®s, regs.num_regs, regs.start, regs.end); - if (msg != NULL) - { - M4ERROR ((EXIT_FAILURE, 0, - "INTERNAL ERROR: expression recompilation `%s': %s", - regexp, msg)); - } - default_word_regexp = false; if (word_start == NULL) @@ -923,10 +902,10 @@ next_token (token_data *td, int *line, const char *caller) orig_text = (char *) obstack_finish (&token_stack); if (regs.start[1] != -1) - obstack_grow (&token_stack,orig_text + regs.start[1], + obstack_grow (&token_stack, orig_text + regs.start[1], regs.end[1] - regs.start[1]); else - obstack_grow (&token_stack, orig_text,regs.end[0]); + obstack_grow (&token_stack, orig_text, regs.end[0]); type = TOKEN_WORD; } @@ -568,7 +568,7 @@ main (int argc, char *const *argv, char *const *envp) break; default: - M4ERROR ((0, 0, "INTERNAL ERROR: bad code in deferred arguments")); + assert (!"main"); abort (); } @@ -25,6 +25,7 @@ #include <config.h> +#include <assert.h> #include <ctype.h> #include <errno.h> #include <stdbool.h> diff --git a/src/macro.c b/src/macro.c index 0034789c..76f9276d 100644 --- a/src/macro.c +++ b/src/macro.c @@ -119,8 +119,7 @@ expand_token (struct obstack *obs, token_type t, token_data *td, int line) break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad token type in expand_token ()")); + assert (!"expand_token"); abort (); } } @@ -211,8 +210,7 @@ expand_argument (struct obstack *obs, token_data *argp, const char *caller) break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad token type in expand_argument ()")); + assert (!"expand_argument"); abort (); } @@ -284,8 +282,7 @@ call_macro (symbol *sym, int argc, token_data **argv, break; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: bad symbol type in call_macro ()")); + assert (!"call_macro"); abort (); } } diff --git a/src/output.c b/src/output.c index f88fc4b2..5873d8c4 100644 --- a/src/output.c +++ b/src/output.c @@ -593,7 +593,7 @@ make_diversion (int divnum) if (!output_diversion->size && !output_diversion->u.file) { if (!gl_oset_remove (diversion_table, output_diversion)) - error (EXIT_FAILURE, 0, "INTERNAL ERROR: make_diversion failed"); + assert (false); output_diversion->u.next = free_list; output_diversion->used = 0; free_list = output_diversion; diff --git a/src/symtab.c b/src/symtab.c index 8195e2e4..d65d4c5a 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -107,12 +107,7 @@ symtab_init (void) s[i] = NULL; #ifdef DEBUG_SYM - { - int e = atexit(show_profile); - if (e != 0) - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: unable to show symtab profile")); - } + atexit (show_profile); /* Ignore failure, since this is debug code. */ #endif /* DEBUG_SYM */ } @@ -307,8 +302,7 @@ lookup_symbol (const char *name, symbol_lookup mode) return NULL; default: - M4ERROR ((warning_status, 0, - "INTERNAL ERROR: invalid mode to symbol_lookup ()")); + assert (!"symbol_lookup"); abort (); } } |