diff options
author | Eric Blake <ebb9@byu.net> | 2008-05-29 07:24:16 -0600 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2008-06-02 07:16:36 -0600 |
commit | 50c5eb094704ebfe272b695a89ad35280a40a716 (patch) | |
tree | b5cbe19bec8e7cf2192261d4dec8f0d9a786c548 /modules/gnu.c | |
parent | a3aa897fc496179ff7bdd0fe6cd42a9e298e8473 (diff) | |
download | m4-50c5eb094704ebfe272b695a89ad35280a40a716.tar.gz |
Stage 24c: Improve display of macro names with embedded NUL.
* m4/m4module.h (m4_push_string_init): Add parameters.
* m4/m4private.h (struct m4_macro_args): Remove argv0 and
argv0_len, now redundant with info.
(m4__push_wrapup_init): Add parameter.
* m4/input.c (m4_push_string_init, m4__push_wrapup_init): Track
location from caller, rather than context.
(composite_peek, composite_read, match_input): Adjust callers.
* m4/utility.c (m4_symbol_value_lookup): Quote macro name.
(m4_verror_at_line): Allow NUL in macro name.
* m4/macro.c (trace_flush, m4_trace_prepare, trace_pre): Allow NUL
in trace.
(expand_macro): No longer munge context location.
(collect_arguments, m4_arg_text, m4_arg_empty, m4_arg_len)
(m4_make_argv_ref, m4_push_arg, m4_wrap_args): Adjust callers.
* modules/gnu.c (builtin, indir): Likewise.
* tests/null.m4: Enhance test.
* tests/null.err: Adjust expected output.
* tests/null.out: Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'modules/gnu.c')
-rw-r--r-- | modules/gnu.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/modules/gnu.c b/modules/gnu.c index a13ae110..ead1b62b 100644 --- a/modules/gnu.c +++ b/modules/gnu.c @@ -29,6 +29,7 @@ #endif #include "modules/m4.h" +#include "quotearg.h" /* Rename exported symbols for dlpreload()ing. */ #define m4_builtin_table gnu_LTX_m4_builtin_table @@ -404,7 +405,8 @@ M4BUILTIN_HANDLER (builtin) { const m4_call_info *me = m4_arg_info (argv); const char *name; - m4_symbol_value *value; + size_t len; + m4_symbol_value *value = NULL; if (!m4_is_arg_text (argv, 1)) { @@ -419,9 +421,12 @@ M4BUILTIN_HANDLER (builtin) return; } name = M4ARG (2); - value = m4_builtin_find_by_name (NULL, name); + len = M4ARGLEN (2); + if (len == strlen (name)) + value = m4_builtin_find_by_name (NULL, name); if (value == NULL) - m4_warn (context, 0, me, _("undefined builtin `%s'"), name); + m4_warn (context, 0, me, _("undefined builtin %s"), + quotearg_style_mem (locale_quoting_style, name, len)); else { m4_push_builtin (context, obs, value); @@ -434,16 +439,19 @@ M4BUILTIN_HANDLER (builtin) else { name = M4ARG (1); - value = m4_builtin_find_by_name (NULL, name); + len = M4ARGLEN (1); + if (len == strlen (name)) + value = m4_builtin_find_by_name (NULL, name); if (value == NULL) - m4_warn (context, 0, me, _("undefined builtin `%s'"), name); + m4_warn (context, 0, me, _("undefined builtin %s"), + quotearg_style_mem (locale_quoting_style, name, len)); else { const m4_builtin *bp = m4_get_symbol_value_builtin (value); m4_macro_args *new_argv; bool flatten = (bp->flags & M4_BUILTIN_FLATTEN_ARGS) != 0; - new_argv = m4_make_argv_ref (context, argv, name, M4ARGLEN (1), - flatten, false); + new_argv = m4_make_argv_ref (context, argv, name, len, flatten, + false); if (!m4_bad_argc (context, argc - 1, m4_arg_info (new_argv), bp->min_args, bp->max_args, (bp->flags & M4_BUILTIN_SIDE_EFFECT) != 0)) @@ -678,7 +686,8 @@ M4BUILTIN_HANDLER (indir) m4_symbol *symbol = m4_symbol_lookup (M4SYMTAB, name, len); if (symbol == NULL) - m4_warn (context, 0, me, _("undefined macro `%s'"), name); + m4_warn (context, 0, me, _("undefined macro %s"), + quotearg_style_mem (locale_quoting_style, name, len)); else { m4_macro_args *new_argv; |