]> Savannah Git Hosting - m4.git/commitdiff

Savannah Git Hosting - m4.git/commitdiff

git git@sv / m4.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 969296f)
Factor out handling of macro name in error messages.
2007年11月23日 22:18:40 +0000 (15:18 -0700)
2007年11月23日 22:18:40 +0000 (15:18 -0700)
* m4/m4module.h (m4_error, m4_error_at_line, m4_warn)
(m4_warn_at_line): Add new parameter.
* m4/utility.c (m4_verror_at_line): New helper method.
(m4_error, m4_error_at_line, m4_warn, m4_warn_at_line): Add new
parameter.
(m4_bad_argc, m4_numeric_arg, m4_parse_truth_arg): All callers
changed.
* m4/debug.c: Likewise.
* m4/input.c: Likewise.
* m4/macro.c: Likewise.
* m4/module.c: Likewise.
* m4/output.c: Likewise.
* m4/path.c: Likewise.
* modules/evalparse.c: Likewise.
* modules/format.c: Likewise.
* modules/gnu.c: Likewise.
* modules/load.c: Likewise.
* modules/m4.c: Likewise.
* modules/mpeval.c: Likewise.
* src/freeze.c: Likewise.
* src/main.c: Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
17 files changed:

diff --git a/ChangeLog b/ChangeLog
index 8688d19303df2771926dc59c5dfa426a8eae1459..0ac9fbd716ebf4645c1c14052a5a6bc7e4ffec8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2007年11月23日 Eric Blake <ebb9@byu.net>
+
+ Factor out handling of macro name in error messages.
+ * m4/m4module.h (m4_error, m4_error_at_line, m4_warn)
+ (m4_warn_at_line): Add new parameter.
+ * m4/utility.c (m4_verror_at_line): New helper method.
+ (m4_error, m4_error_at_line, m4_warn, m4_warn_at_line): Add new
+ parameter.
+ (m4_bad_argc, m4_numeric_arg, m4_parse_truth_arg): All callers
+ changed.
+ * m4/debug.c: Likewise.
+ * m4/input.c: Likewise.
+ * m4/macro.c: Likewise.
+ * m4/module.c: Likewise.
+ * m4/output.c: Likewise.
+ * m4/path.c: Likewise.
+ * modules/evalparse.c: Likewise.
+ * modules/format.c: Likewise.
+ * modules/gnu.c: Likewise.
+ * modules/load.c: Likewise.
+ * modules/m4.c: Likewise.
+ * modules/mpeval.c: Likewise.
+ * src/freeze.c: Likewise.
+ * src/main.c: Likewise.
+
2007年11月14日 Eric Blake <ebb9@byu.net>
Handle some defn corner cases differently.
diff --git a/m4/debug.c b/m4/debug.c
index c90efde1807202f5569b199a6dedf79cdd4ea3ef..dd4a941958905703df4edd237437b7467e3a1a5a 100644 (file)
--- a/m4/debug.c
+++ b/m4/debug.c
@@ -143,7 +143,8 @@ set_debug_file (m4 *context, FILE *fp)
debug_file = m4_get_debug_file (context);
if (debug_file != NULL && debug_file != stderr && debug_file != stdout
&& close_stream (debug_file) != 0)
- m4_error (context, 0, errno, _("error writing to debug stream"));
+ /* FIXME - use macro name. */
+ m4_error (context, 0, errno, NULL, _("error writing to debug stream"));
debug_file = fp;
m4_set_debug_file (context, fp);
@@ -162,7 +163,9 @@ set_debug_file (m4 *context, FILE *fp)
&& stdout_stat.st_ino != 0)
{
if (debug_file != stderr && close_stream (debug_file) != 0)
- m4_error (context, 0, errno, _("error writing to debug stream"));
+ /* FIXME - use macro name. */
+ m4_error (context, 0, errno, NULL,
+ _("error writing to debug stream"));
m4_set_debug_file (context, stdout);
}
}
@@ -189,8 +192,9 @@ m4_debug_set_output (m4 *context, const char *name)
return false;
if (set_cloexec_flag (fileno (fp), true) != 0)
- m4_error (context, 0, errno,
- _("cannot protect debug file across forks"));
+ /* FIXME - use macro name. */
+ m4_warn (context, errno, NULL,
+ _("cannot protect debug file across forks"));
set_debug_file (context, fp);
}
return true;
diff --git a/m4/input.c b/m4/input.c
index a8c4f879db4a495b1df8314f02f7647a6e156e7c..9fbbe08c70d7e31a9bd396fa5f9bedcf87dc2f9a 100644 (file)
--- a/m4/input.c
+++ b/m4/input.c
@@ -289,12 +289,12 @@ file_clean (m4_input_block *me, m4 *context)
if (ferror (me->u.u_f.fp))
{
- m4_error (context, 0, 0, _("error reading file `%s'"), me->file);
+ m4_error (context, 0, 0, NULL, _("error reading file `%s'"), me->file);
if (me->u.u_f.close)
fclose (me->u.u_f.fp);
}
else if (me->u.u_f.close && fclose (me->u.u_f.fp) == EOF)
- m4_error (context, 0, errno, _("error reading file `%s'"), me->file);
+ m4_error (context, 0, errno, NULL, _("error reading file `%s'"), me->file);
start_of_input_line = me->u.u_f.advance_line;
m4_set_output_line (context, -1);
}
@@ -846,8 +846,8 @@ m4_skip_line (m4 *context, const char *name)
;
if (ch == CHAR_EOF)
/* current_file changed; use the previous value we cached. */
- m4_warn_at_line (context, 0, file, line,
- _("%s: end of file treated as newline"), name);
+ m4_warn_at_line (context, 0, file, line, name,
+ _("end of file treated as newline"));
/* On the rare occasion that dnl crosses include file boundaries
(either the input file did not end in a newline, or changesyntax
was used), calling next_char can update current_file and
@@ -1081,9 +1081,7 @@ m4__next_token (m4 *context, m4_symbol_value *token, int *line,
{
ch = next_char (context, true);
if (ch == CHAR_EOF)
- m4_error_at_line (context, EXIT_FAILURE, 0, file, *line,
- "%s%s%s", caller ? caller : "",
- caller ? ": " : "",
+ m4_error_at_line (context, EXIT_FAILURE, 0, file, *line, caller,
_("end of file in string"));
if (m4_has_syntax (M4SYNTAX, ch, M4_SYNTAX_RQUOTE))
@@ -1110,9 +1108,7 @@ m4__next_token (m4 *context, m4_symbol_value *token, int *line,
{
ch = next_char (context, true);
if (ch == CHAR_EOF)
- m4_error_at_line (context, EXIT_FAILURE, 0, file, *line,
- "%s%s%s", caller ? caller : "",
- caller ? ": " : "",
+ m4_error_at_line (context, EXIT_FAILURE, 0, file, *line, caller,
_("end of file in string"));
if (MATCH (context, ch, context->syntax->rquote.string, true))
{
@@ -1141,9 +1137,7 @@ m4__next_token (m4 *context, m4_symbol_value *token, int *line,
if (ch != CHAR_EOF)
obstack_1grow (&token_stack, ch);
else
- m4_error_at_line (context, EXIT_FAILURE, 0, file, *line,
- "%s%s%s", caller ? caller : "",
- caller ? ": " : "",
+ m4_error_at_line (context, EXIT_FAILURE, 0, file, *line, caller,
_("end of file in comment"));
type = (m4_get_discard_comments_opt (context)
? M4_TOKEN_NONE : M4_TOKEN_STRING);
@@ -1160,9 +1154,7 @@ m4__next_token (m4 *context, m4_symbol_value *token, int *line,
obstack_grow (&token_stack, context->syntax->ecomm.string,
context->syntax->ecomm.length);
else
- m4_error_at_line (context, EXIT_FAILURE, 0, file, *line,
- "%s%s%s", caller ? caller : "",
- caller ? ": " : "",
+ m4_error_at_line (context, EXIT_FAILURE, 0, file, *line, caller,
_("end of file in comment"));
type = (m4_get_discard_comments_opt (context)
? M4_TOKEN_NONE : M4_TOKEN_STRING);
diff --git a/m4/m4module.h b/m4/m4module.h
index b4693d7846f2f9dc9bad9f8ee0c53596ebc04b98..6bfa18a31efc2ab2e7eb270be4c56c1b80135a6e 100644 (file)
--- a/m4/m4module.h
+++ b/m4/m4module.h
@@ -110,12 +110,16 @@ extern void m4_dump_args (m4 *, m4_obstack *, int,
extern bool m4_parse_truth_arg (m4 *, const char *, const char *, bool);
/* Error handling. */
-extern void m4_error (m4 *, int, int, const char *, ...) M4_GNUC_PRINTF (4, 5);
+extern void m4_error (m4 *, int, int, const char *, const char *, ...)
+ M4_GNUC_PRINTF (5, 6);
extern void m4_error_at_line (m4 *, int, int, const char *, int,
- const char *, ...) M4_GNUC_PRINTF (6, 7);
-extern void m4_warn (m4 *, int, const char *, ...) M4_GNUC_PRINTF (3, 4);
-extern void m4_warn_at_line (m4 *, int, const char *, int,
- const char *, ...) M4_GNUC_PRINTF (5, 6);
+ const char *, const char *, ...)
+ M4_GNUC_PRINTF (7, 8);
+extern void m4_warn (m4 *, int, const char *, const char *, ...)
+ M4_GNUC_PRINTF (4, 5);
+extern void m4_warn_at_line (m4 *, int, const char *, int, const char *,
+ const char *, ...)
+ M4_GNUC_PRINTF (6, 7);
extern const char * m4_get_program_name (void);
extern void m4_set_program_name (const char *);
@@ -202,7 +206,7 @@ typedef void *m4_symtab_apply_func (m4_symbol_table *, const char *,
extern m4_symbol_table *m4_symtab_create (size_t);
extern void m4_symtab_delete (m4_symbol_table*);
extern void * m4_symtab_apply (m4_symbol_table*, bool,
- m4_symtab_apply_func*, void*);
+ m4_symtab_apply_func*, void*);
extern m4_symbol *m4_symbol_lookup (m4_symbol_table*, const char *);
extern m4_symbol *m4_symbol_pushdef (m4_symbol_table*,
diff --git a/m4/macro.c b/m4/macro.c
index 6ea3f89c4d3b1e7311ff85331f1cf5e13932d974..ffe55f718f6c34cb7e4ec05f2d940cf000a2b159 100644 (file)
--- a/m4/macro.c
+++ b/m4/macro.c
@@ -204,8 +204,8 @@ expand_argument (m4 *context, m4_obstack *obs, m4_symbol_value *argp,
break;
case M4_TOKEN_EOF:
- m4_error_at_line (context, EXIT_FAILURE, 0, file, line,
- _("%s: end of file in argument list"), caller);
+ m4_error_at_line (context, EXIT_FAILURE, 0, file, line, caller,
+ _("end of file in argument list"));
break;
case M4_TOKEN_WORD:
@@ -282,7 +282,7 @@ expand_macro (m4 *context, const char *name, m4_symbol *symbol)
expansion_level++;
if (m4_get_nesting_limit_opt (context) > 0
&& expansion_level > m4_get_nesting_limit_opt (context))
- m4_error (context, EXIT_FAILURE, 0, _("\
+ m4_error (context, EXIT_FAILURE, 0, NULL, _("\
recursion limit of %zu exceeded, use -L<N> to change it"),
m4_get_nesting_limit_opt (context));
@@ -404,9 +404,9 @@ m4_macro_call (m4 *context, m4_symbol_value *value, m4_obstack *expansion,
}
else if (m4_is_symbol_value_placeholder (value))
{
- m4_warn (context, 0,
- _("%s: builtin `%s' requested by frozen file not found"),
- M4ARG (0), m4_get_symbol_value_placeholder (value));
+ m4_warn (context, 0, M4ARG (0),
+ _("builtin `%s' requested by frozen file not found"),
+ m4_get_symbol_value_placeholder (value));
}
else
{
@@ -514,9 +514,9 @@ process_macro (m4 *context, m4_symbol_value *value, m4_obstack *obs,
}
else
{
- m4_error (context, 0, 0,
- _("%s: unterminated parameter reference: %s"),
- M4ARG (0), key);
+ m4_error (context, 0, 0, M4ARG (0),
+ _("unterminated parameter reference: %s"),
+ key);
}
text = *endp ? 1 + endp : endp;
diff --git a/m4/module.c b/m4/module.c
index 458808eb6c16b068d3aee9e7f14e480788edd1df..4a65dbdbf2573e9ee171b3b655362d8c46336908 100644 (file)
--- a/m4/module.c
+++ b/m4/module.c
@@ -124,7 +124,8 @@ m4_module_import (m4 *context, const char *module_name,
symbol_address = lt_dlsym (module->handle, symbol_name);
if (!symbol_address)
- m4_error (context, 0, 0, _("cannot load symbol `%s' from module `%s'"),
+ m4_error (context, 0, 0, NULL,
+ _("cannot load symbol `%s' from module `%s'"),
symbol_name, module_name);
}
@@ -252,7 +253,7 @@ m4_module_unload (m4 *context, const char *name, m4_obstack *obs)
if (errors)
{
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("cannot unload module `%s': %s"),
name ? name : MODULE_SELF_NAME, module_dlerror ());
}
@@ -332,7 +333,8 @@ m4__module_init (m4 *context)
module system has already been initialized. */
if (iface_id)
{
- m4_error (context, 0, 0, _("multiple module loader initializations"));
+ m4_error (context, 0, 0, NULL,
+ _("multiple module loader initializations"));
return;
}
@@ -372,9 +374,8 @@ m4__module_init (m4 *context)
/* Couldn't initialize the module system; diagnose and exit. */
if (errors)
- m4_error (context, EXIT_FAILURE, 0,
- _("failed to initialize module loader: %s"),
- module_dlerror ());
+ m4_error (context, EXIT_FAILURE, 0, NULL,
+ _("failed to initialize module loader: %s"), module_dlerror ());
#ifdef DEBUG_MODULES
fputs ("Module loader initialized.\n", stderr);
@@ -433,7 +434,7 @@ m4__module_open (m4 *context, const char *name, m4_obstack *obs)
assert (!old);
err = lt_dlerror ();
if (err)
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("unable to load module `%s': %s"), name, err);
}
@@ -452,7 +453,7 @@ m4__module_open (m4 *context, const char *name, m4_obstack *obs)
&& !lt_dlsym (handle, BUILTIN_SYMBOL)
&& !lt_dlsym (handle, MACRO_SYMBOL))
{
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("module `%s' has no entry points"), name);
}
@@ -462,8 +463,8 @@ m4__module_open (m4 *context, const char *name, m4_obstack *obs)
else
{
/* Couldn't open the module; diagnose and exit. */
- m4_error (context, EXIT_FAILURE, 0, _("cannot open module `%s': %s"),
- name, module_dlerror ());
+ m4_error (context, EXIT_FAILURE, 0, NULL,
+ _("cannot open module `%s': %s"), name, module_dlerror ());
}
return module;
@@ -496,8 +497,8 @@ m4__module_exit (m4 *context)
if (errors)
{
- m4_error (context, EXIT_FAILURE, 0, _("cannot unload all modules: %s"),
- module_dlerror ());
+ m4_error (context, EXIT_FAILURE, 0, NULL,
+ _("cannot unload all modules: %s"), module_dlerror ());
}
}
@@ -582,7 +583,7 @@ module_remove (m4 *context, m4_module *module, m4_obstack *obs)
failure about not closing a resident module. */
void *old = lt_dlcaller_set_data (iface_id, handle, NULL);
if (!old)
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("unable to close module `%s': %s"), name,
module_dlerror());
assert (old == module);
@@ -604,8 +605,8 @@ module_remove (m4 *context, m4_module *module, m4_obstack *obs)
}
if (errors)
- m4_error (context, EXIT_FAILURE, 0, _("cannot close module `%s': %s"),
- name, module_dlerror ());
+ m4_error (context, EXIT_FAILURE, 0, NULL,
+ _("cannot close module `%s': %s"), name, module_dlerror ());
if (last_reference)
free (module);
diff --git a/m4/output.c b/m4/output.c
index 1f8d1b0e80eeff5daa6bbaa29c937495503f1092..3eb77588307c82e54805d203b55f5349c3791220 100644 (file)
--- a/m4/output.c
+++ b/m4/output.c
@@ -218,7 +218,7 @@ m4_tmpfile (m4 *context, int divnum)
{
output_temp_dir = create_temp_dir ("m4-", NULL, true);
if (output_temp_dir == NULL)
- m4_error (context, EXIT_FAILURE, errno,
+ m4_error (context, EXIT_FAILURE, errno, NULL,
_("cannot create temporary file for diversion"));
atexit (cleanup_tmpfile);
}
@@ -228,11 +228,11 @@ m4_tmpfile (m4 *context, int divnum)
if (file == NULL)
{
unregister_temp_file (output_temp_dir, name);
- m4_error (context, EXIT_FAILURE, errno,
+ m4_error (context, EXIT_FAILURE, errno, NULL,
_("cannot create temporary file for diversion"));
}
else if (set_cloexec_flag (fileno (file), true) != 0)
- m4_warn (context, errno, _("cannot protect diversion across forks"));
+ m4_warn (context, errno, NULL, _("cannot protect diversion across forks"));
return file;
}
@@ -247,14 +247,14 @@ m4_tmpopen (m4 *context, int divnum)
file = fopen_temp (name, O_BINARY ? "ab+" : "a+");
if (file == NULL)
- m4_error (context, EXIT_FAILURE, errno,
+ m4_error (context, EXIT_FAILURE, errno, NULL,
_("cannot create temporary file for diversion"));
else if (set_cloexec_flag (fileno (file), true) != 0)
- m4_warn (context, errno, _("cannot protect diversion across forks"));
+ m4_warn (context, errno, NULL, _("cannot protect diversion across forks"));
/* POSIX states that it is undefined whether an append stream starts
at offset 0 or at the end. We want the beginning. */
else if (fseeko (file, 0, SEEK_SET) != 0)
- m4_error (context, EXIT_FAILURE, errno,
+ m4_error (context, EXIT_FAILURE, errno, NULL,
_("cannot seek to beginning of diversion"));
return file;
}
@@ -351,7 +351,7 @@ make_room_for (m4 *context, size_t length)
count = fwrite (selected_buffer, selected_diversion->used, 1,
selected_diversion->u.file);
if (count != 1)
- m4_error (context, EXIT_FAILURE, errno,
+ m4_error (context, EXIT_FAILURE, errno, NULL,
_("cannot flush diversion to temporary file"));
}
@@ -379,7 +379,7 @@ make_room_for (m4 *context, size_t length)
FILE *file = selected_diversion->u.file;
selected_diversion->u.file = NULL;
if (m4_tmpclose (file) != 0)
- m4_error (context, 0, errno,
+ m4_error (context, 0, errno, NULL,
_("cannot close temporary file for diversion"));
}
@@ -439,7 +439,8 @@ m4_output_text (m4 *context, const char *text, size_t length)
{
count = fwrite (text, length, 1, output_file);
if (count != 1)
- m4_error (context, EXIT_FAILURE, errno, _("copying inserted file"));
+ m4_error (context, EXIT_FAILURE, errno, NULL,
+ _("copying inserted file"));
}
else
{
@@ -640,7 +641,7 @@ m4_make_diversion (m4 *context, int divnum)
FILE *file = output_diversion->u.file;
output_diversion->u.file = NULL;
if (m4_tmpclose (file) != 0)
- m4_error (context, 0, errno,
+ m4_error (context, 0, errno, NULL,
_("cannot close temporary file for diversion"));
}
output_diversion = NULL;
@@ -725,7 +726,8 @@ m4_insert_file (m4 *context, FILE *file)
{
length = fread (buffer, 1, COPY_BUFFER_SIZE, file);
if (ferror (file))
- m4_error (context, EXIT_FAILURE, errno, _("reading inserted file"));
+ m4_error (context, EXIT_FAILURE, errno, NULL,
+ _("reading inserted file"));
if (length == 0)
break;
m4_output_text (context, buffer, length);
@@ -772,11 +774,11 @@ insert_diversion_helper (m4 *context, m4_diversion *diversion)
diversion->u.file = NULL;
diversion->used = 0;
if (m4_tmpclose (file) != 0)
- m4_error (context, 0, errno,
+ m4_error (context, 0, errno, NULL,
_("cannot clean temporary file for diversion"));
}
if (m4_tmpremove (diversion->divnum) != 0)
- m4_error (context, 0, errno,
+ m4_error (context, 0, errno, NULL,
_("cannot clean temporary file for diversion"));
}
if (!gl_oset_remove (diversion_table, diversion))
@@ -855,14 +857,14 @@ m4_freeze_diversions (m4 *context, FILE *file)
assert (!diversion->u.file);
diversion->u.file = m4_tmpopen (context, diversion->divnum);
if (fstat (fileno (diversion->u.file), &file_stat) < 0)
- m4_error (context, EXIT_FAILURE, errno,
+ m4_error (context, EXIT_FAILURE, errno, NULL,
_("cannot stat diversion"));
/* FIXME - support 64-bit off_t with 32-bit long, and
fix frozen file format to support 64-bit integers.
This implies fixing shipout_text to take off_t. */
if (file_stat.st_size < 0
|| file_stat.st_size != (unsigned long int) file_stat.st_size)
- m4_error (context, EXIT_FAILURE, errno,
+ m4_error (context, EXIT_FAILURE, errno, NULL,
_("diversion too large"));
xfprintf (file, "D%d,%lu\n", diversion->divnum,
(unsigned long int) file_stat.st_size);
diff --git a/m4/path.c b/m4/path.c
index b0b45d742e7c2cd60009e47bcc2eec73bc03f48d..078165519d61ca1fe521df6a818451dfc7b033cb 100644 (file)
--- a/m4/path.c
+++ b/m4/path.c
@@ -157,7 +157,7 @@ m4_path_search (m4 *context, const char *file, char **expanded_name)
if (fp != NULL)
{
if (set_cloexec_flag (fileno (fp), true) != 0)
- m4_error (context, 0, errno,
+ m4_error (context, 0, errno, NULL,
_("cannot protect input file across forks"));
if (expanded_name != NULL)
*expanded_name = xstrdup (file);
@@ -182,7 +182,7 @@ m4_path_search (m4 *context, const char *file, char **expanded_name)
_("path search for `%s' found `%s'"),
file, name);
if (set_cloexec_flag (fileno (fp), true) != 0)
- m4_error (context, 0, errno,
+ m4_error (context, 0, errno, NULL,
_("cannot protect input file across forks"));
if (expanded_name != NULL)
diff --git a/m4/utility.c b/m4/utility.c
index 3436f1b46e75f63fa73a4cf00ab40ce143d6a8df..1839ea1a77d9f0acdb2dbb67d8224dd46fc5b596 100644 (file)
--- a/m4/utility.c
+++ b/m4/utility.c
@@ -45,15 +45,15 @@ m4_bad_argc (m4 *context, int argc, m4_symbol_value **argv,
{
if (argc - 1 < min)
{
- m4_warn (context, 0, _("%s: too few arguments: %d < %d"),
- M4ARG (0), argc - 1, min);
+ m4_warn (context, 0, M4ARG (0), _("too few arguments: %d < %d"),
+ argc - 1, min);
return ! side_effect;
}
if (argc - 1 > max)
{
- m4_warn (context, 0, _("%s: extra arguments ignored: %d > %d"),
- M4ARG (0), argc - 1, max);
+ m4_warn (context, 0, M4ARG (0), _("extra arguments ignored: %d > %d"),
+ argc - 1, max);
}
return false;
@@ -81,15 +81,15 @@ m4_numeric_arg (m4 *context, int argc, m4_symbol_value **argv,
if (*M4ARG (arg) == '0円')
{
*valuep = 0;
- m4_warn (context, 0, _("%s: empty string treated as 0"), M4ARG (0));
+ m4_warn (context, 0, M4ARG (0), _("empty string treated as 0"));
}
else
{
*valuep = strtol (skip_space (context, M4ARG (arg)), &endp, 10);
if (*skip_space (context, endp) != 0)
{
- m4_warn (context, 0, _("%s: non-numeric argument `%s'"),
- M4ARG (0), M4ARG (arg));
+ m4_warn (context, 0, M4ARG (0), _("non-numeric argument `%s'"),
+ M4ARG (arg));
return false;
}
}
@@ -136,19 +136,49 @@ m4_parse_truth_arg (m4 *context, const char *arg, const char *me,
|| ((arg[0] == 'o' || arg[0] == 'O')
&& (arg[1] == 'n' || arg[1] == 'N')))
return true;
- m4_warn (context, 0, _("%s: unknown directive `%s'"), me, arg);
+ m4_warn (context, 0, me, _("unknown directive `%s'"), arg);
return previous;
}
+/* Helper for all error reporting. Report message based on FORMAT and
+ ARGS, on behalf of MACRO, at the optional location FILE and LINE.
+ If ERRNUM, decode the errno value as part of the message. If
+ STATUS, exit immediately with that status. If WARN, prepend
+ 'Warning: '. */
+static void
+m4_verror_at_line (m4 *context, bool warn, int status, int errnum,
+ const char *file, int line, const char *macro,
+ const char *format, va_list args)
+{
+ char *full = NULL;
+ /* Prepend warning and the macro name, as needed. But if that fails
+ for non-memory reasons (unlikely), then still use the original
+ format. */
+ if (warn && macro)
+ full = xasprintf (_("Warning: %s: %s"), macro, format);
+ else if (warn)
+ full = xasprintf (_("Warning: %s"), format);
+ else if (macro)
+ full = xasprintf (_("%s: %s"), macro, format);
+ verror_at_line (status, errnum, line ? file : NULL, line,
+ full ? full : format, args);
+ free (full);
+ if ((!warn || m4_get_fatal_warnings_opt (context))
+ && ! m4_get_exit_status (context))
+ m4_set_exit_status (context, EXIT_FAILURE);
+}
+
/* Issue an error. The message is printf-style, based on FORMAT and
any other arguments, and the program name and location (if we are
currently parsing an input file) are automatically prepended. If
ERRNUM is non-zero, include strerror output in the message. If
- STATUS is non-zero, or if errors are fatal, call exit immediately;
- otherwise, remember that an error occurred so that m4 cannot exit
- with success later on.*/
+ MACRO, prepend the message with the macro where the message
+ occurred. If STATUS is non-zero, or if errors are fatal, call exit
+ immediately; otherwise, remember that an error occurred so that m4
+ cannot exit with success later on.*/
void
-m4_error (m4 *context, int status, int errnum, const char *format, ...)
+m4_error (m4 *context, int status, int errnum, const char *macro,
+ const char *format, ...)
{
va_list args;
int line = m4_get_current_line (context);
@@ -156,9 +186,9 @@ m4_error (m4 *context, int status, int errnum, const char *format, ...)
va_start (args, format);
if (status == EXIT_SUCCESS && m4_get_warnings_exit_opt (context))
status = EXIT_FAILURE;
- verror_at_line (status, errnum, line ? m4_get_current_file (context) : NULL,
- line, format, args);
- m4_set_exit_status (context, EXIT_FAILURE);
+ m4_verror_at_line (context, false, status, errnum,
+ m4_get_current_file (context), line, macro, format, args);
+ va_end (args);
}
/* Issue an error. The message is printf-style, based on FORMAT and
@@ -167,49 +197,45 @@ m4_error (m4 *context, int status, int errnum, const char *format, ...)
include strerror output in the message. If STATUS is non-zero, or
if errors are fatal, call exit immediately; otherwise, remember
that an error occurred so that m4 cannot exit with success later
- on.*/
+ on. If MACRO, prepend the message with the macro where the message
+ occurred. */
void
m4_error_at_line (m4 *context, int status, int errnum, const char *file,
- int line, const char *format, ...)
+ int line, const char *macro, const char *format, ...)
{
va_list args;
va_start (args, format);
if (status == EXIT_SUCCESS && m4_get_warnings_exit_opt (context))
status = EXIT_FAILURE;
- verror_at_line (status, errnum, line ? file : NULL,
- line, format, args);
- m4_set_exit_status (context, EXIT_FAILURE);
+ m4_verror_at_line (context, false, status, errnum, file, line, macro,
+ format, args);
+ va_end (args);
}
/* Issue a warning, if they are not being suppressed. The message is
printf-style, based on FORMAT and any other arguments, and the
program name, location (if we are currently parsing an input file),
and "Warning:" are automatically prepended. If ERRNUM is non-zero,
- include strerror output in the message. If warnings are fatal,
- call exit immediately, otherwise exit status is unchanged. */
+ include strerror output in the message. If MACRO, prepend the
+ message with the macro where the message occurred. If warnings are
+ fatal, call exit immediately, otherwise exit status is
+ unchanged. */
void
-m4_warn (m4 *context, int errnum, const char *format, ...)
+m4_warn (m4 *context, int errnum, const char *macro, const char *format, ...)
{
if (!m4_get_suppress_warnings_opt (context))
{
va_list args;
int status = EXIT_SUCCESS;
int line = m4_get_current_line (context);
- char *full_format = xasprintf(_("Warning: %s"), format);
-
assert (m4_get_current_file (context) || ! line);
va_start (args, format);
if (m4_get_warnings_exit_opt (context))
status = EXIT_FAILURE;
- /* If the full_format failed (unlikely though that may be), at
- least fall back on the original format. */
- verror_at_line (status, errnum,
- line ? m4_get_current_file (context) : NULL, line,
- full_format ? full_format : format, args);
- free (full_format);
- if (m4_get_fatal_warnings_opt (context)
- && ! m4_get_exit_status (context))
- m4_set_exit_status (context, EXIT_FAILURE);
+ m4_verror_at_line (context, true, status, errnum,
+ m4_get_current_file (context), line, macro, format,
+ args);
+ va_end (args);
}
}
@@ -217,28 +243,23 @@ m4_warn (m4 *context, int errnum, const char *format, ...)
printf-style, based on FORMAT and any other arguments, and the
program name, location (from FILE and LINE), and "Warning:" are
automatically prepended. If ERRNUM is non-zero, include strerror
- output in the message. If warnings are fatal, call exit
+ output in the message. If MACRO, prepend the message with the
+ macro where the message occurred. If warnings are fatal, call exit
immediately, otherwise exit status is unchanged. */
void
m4_warn_at_line (m4 *context, int errnum, const char *file, int line,
- const char *format, ...)
+ const char *macro, const char *format, ...)
{
if (!m4_get_suppress_warnings_opt (context))
{
va_list args;
int status = EXIT_SUCCESS;
- char *full_format = xasprintf(_("Warning: %s"), format);
va_start (args, format);
if (m4_get_warnings_exit_opt (context))
status = EXIT_FAILURE;
- /* If the full_format failed (unlikely though that may be), at
- least fall back on the original format. */
- verror_at_line (status, errnum, line ? file : NULL, line,
- full_format ? full_format : format, args);
- free (full_format);
- if (m4_get_fatal_warnings_opt (context)
- && ! m4_get_exit_status (context))
- m4_set_exit_status (context, EXIT_FAILURE);
+ m4_verror_at_line (context, true, status, errnum, file, line, macro,
+ format, args);
+ va_end (args);
}
}
diff --git a/modules/evalparse.c b/modules/evalparse.c
index 5ac246c914c57b2e54f83835d188b090a1880140..b4639b0c5798f7b00b121983ecd3a0aa3d29fab3 100644 (file)
--- a/modules/evalparse.c
+++ b/modules/evalparse.c
@@ -898,8 +898,7 @@ m4_evaluate (m4 *context, m4_obstack *obs, int argc, m4_symbol_value **argv)
if (radix < 1 || radix > 36)
{
- m4_warn (context, 0, _("%s: radix out of range: %d"),
- M4ARG (0), radix);
+ m4_warn (context, 0, M4ARG (0), _("radix out of range: %d"), radix);
return;
}
@@ -908,7 +907,7 @@ m4_evaluate (m4 *context, m4_obstack *obs, int argc, m4_symbol_value **argv)
if (min < 0)
{
- m4_warn (context, 0, _("%s: negative width: %d"), M4ARG (0), min);
+ m4_warn (context, 0, M4ARG (0), _("negative width: %d"), min);
return;
}
@@ -919,7 +918,7 @@ m4_evaluate (m4 *context, m4_obstack *obs, int argc, m4_symbol_value **argv)
et = eval_lex (&val);
if (et == EOTEXT)
{
- m4_warn (context, 0, _("%s: empty string treated as zero"), M4ARG (0));
+ m4_warn (context, 0, M4ARG (0), _("empty string treated as zero"));
numb_set (val, numb_ZERO);
}
else
@@ -940,48 +939,42 @@ m4_evaluate (m4 *context, m4_obstack *obs, int argc, m4_symbol_value **argv)
break;
case MISSING_RIGHT:
- m4_warn (context, 0, _("%s: missing right parenthesis: %s"),
- M4ARG (0), M4ARG (1));
+ m4_warn (context, 0, M4ARG (0), _("missing right parenthesis: %s"),
+ M4ARG (1));
break;
case MISSING_COLON:
- m4_warn (context, 0, _("%s: missing colon: %s"),
- M4ARG (0), M4ARG (1));
+ m4_warn (context, 0, M4ARG (0), _("missing colon: %s"), M4ARG (1));
break;
case SYNTAX_ERROR:
- m4_warn (context, 0, _("%s: bad expression: %s"),
- M4ARG (0), M4ARG (1));
+ m4_warn (context, 0, M4ARG (0), _("bad expression: %s"), M4ARG (1));
break;
case UNKNOWN_INPUT:
- m4_warn (context, 0, _("%s: bad input: %s"), M4ARG (0), M4ARG (1));
+ m4_warn (context, 0, M4ARG (0), _("bad input: %s"), M4ARG (1));
break;
case EXCESS_INPUT:
- m4_warn (context, 0, _("%s: excess input: %s"), M4ARG (0),
- M4ARG (1));
+ m4_warn (context, 0, M4ARG (0), _("excess input: %s"), M4ARG (1));
break;
case INVALID_OPERATOR:
/* POSIX requires an error here, unless XCU ERN 137 is approved. */
- m4_error (context, 0, 0, _("%s: invalid operator: %s"), M4ARG (0),
+ m4_error (context, 0, 0, M4ARG (0), _("invalid operator: %s"),
M4ARG (1));
break;
case DIVIDE_ZERO:
- m4_warn (context, 0, _("%s: divide by zero: %s"), M4ARG (0),
- M4ARG (1));
+ m4_warn (context, 0, M4ARG (0), _("divide by zero: %s"), M4ARG (1));
break;
case MODULO_ZERO:
- m4_warn (context, 0, _("%s: modulo by zero: %s"), M4ARG (0),
- M4ARG (1));
+ m4_warn (context, 0, M4ARG (0), _("modulo by zero: %s"), M4ARG (1));
break;
case NEGATIVE_EXPONENT:
- m4_warn (context, 0, _("%s: negative exponent: %s"), M4ARG (0),
- M4ARG (1));
+ m4_warn (context, 0, M4ARG (0), _("negative exponent: %s"), M4ARG (1));
break;
default:
diff --git a/modules/format.c b/modules/format.c
index 913d21eaed0477e8c7c1194abce3a18c5ba64969..8e5f6701447a6cd9a704ac2d2e1c4385f20429f3 100644 (file)
--- a/modules/format.c
+++ b/modules/format.c
@@ -232,8 +232,7 @@ format (m4 *context, m4_obstack *obs, int argc, m4_symbol_value **argv)
c = *fmt++;
if (c > sizeof ok || !ok[c])
{
- m4_warn (context, 0, "%s: unrecognized specifier in `%s'",
- name, f);
+ m4_warn (context, 0, name, _("unrecognized specifier in `%s'"), f);
if (c == '0円')
fmt--;
continue;
diff --git a/modules/gnu.c b/modules/gnu.c
index 5c693962702b219e9092a1473d286e38634a34e3..1e02128a0a18997f25f0098f009a9a35adccc318 100644 (file)
--- a/modules/gnu.c
+++ b/modules/gnu.c
@@ -169,8 +169,8 @@ regexp_compile (m4 *context, const char *caller, const char *regexp,
if (msg != NULL)
{
- m4_error (context, 0, 0, _("%s: bad regular expression `%s': %s"),
- caller, regexp, msg);
+ m4_error (context, 0, 0, caller, _("bad regular expression `%s': %s"),
+ regexp, msg);
regfree (pat);
free (pat);
return NULL;
@@ -258,16 +258,16 @@ substitute (m4 *context, m4_obstack *obs, const char *caller,
case '7': case '8': case '9':
ch -= '0';
if (!buf || buf->pat->re_nsub < ch)
- m4_warn (context, 0, _("%s: sub-expression %d not present"),
- caller, ch);
+ m4_warn (context, 0, caller, _("sub-expression %d not present"),
+ ch);
else if (buf->regs.end[ch] > 0)
obstack_grow (obs, victim + buf->regs.start[ch],
buf->regs.end[ch] - buf->regs.start[ch]);
break;
case '0円':
- m4_warn (context, 0, _("%s: trailing \\ ignored in replacement"),
- caller);
+ m4_warn (context, 0, caller,
+ _("trailing \\ ignored in replacement"));
return;
default:
@@ -309,9 +309,8 @@ regexp_substitute (m4 *context, m4_obstack *obs, const char *caller,
copied verbatim. */
if (matchpos == -2)
- m4_error (context, 0, 0,
- _("%s: error matching regular expression `%s'"),
- caller, regexp);
+ m4_error (context, 0, 0, caller,
+ _("error matching regular expression `%s'"), regexp);
else if (!ignore_duplicates && (offset < length))
obstack_grow (obs, victim + offset, length - offset);
break;
@@ -412,36 +411,34 @@ M4BUILTIN_HANDLER (builtin)
if (! m4_is_symbol_value_text (argv[1]))
{
if (m4_is_symbol_value_func (argv[1])
- && m4_get_symbol_value_func (argv[1]) == builtin_builtin)
- {
- if (m4_bad_argc (context, argc, argv, 2, 2, false))
- return;
- if (! m4_is_symbol_value_text (argv[2]))
- {
- m4_warn (context, 0, _("%s: invalid macro name ignored"),
- M4ARG (0));
- return;
- }
- name = M4ARG (2);
- value = m4_builtin_find_by_name (NULL, name);
- if (value == NULL)
- m4_warn (context, 0, _("%s: undefined builtin `%s'"), M4ARG (0),
- name);
- else
- {
- m4_push_builtin (context, value);
- free (value);
- }
- }
+ && m4_get_symbol_value_func (argv[1]) == builtin_builtin)
+ {
+ if (m4_bad_argc (context, argc, argv, 2, 2, false))
+ return;
+ if (! m4_is_symbol_value_text (argv[2]))
+ {
+ m4_warn (context, 0, M4ARG (0), _("invalid macro name ignored"));
+ return;
+ }
+ name = M4ARG (2);
+ value = m4_builtin_find_by_name (NULL, name);
+ if (value == NULL)
+ m4_warn (context, 0, M4ARG (0), _("undefined builtin `%s'"), name);
+ else
+ {
+ m4_push_builtin (context, value);
+ free (value);
+ }
+ }
else
- m4_warn (context, 0, _("%s: invalid macro name ignored"), M4ARG (0));
+ m4_warn (context, 0, M4ARG (0), _("invalid macro name ignored"));
}
else
{
name = M4ARG (1);
value = m4_builtin_find_by_name (NULL, name);
if (value == NULL)
- m4_warn (context, 0, _("%s: undefined builtin `%s'"), M4ARG (0), name);
+ m4_warn (context, 0, M4ARG (0), _("undefined builtin `%s'"), name);
else
{
const m4_builtin *bp = m4_get_symbol_value_builtin (value);
@@ -471,7 +468,7 @@ m4_resyntax_encode_safe (m4 *context, const char *caller, const char *spec)
int resyntax = m4_regexp_syntax_encode (spec);
if (resyntax < 0)
- m4_warn (context, 0, _("%s: bad syntax-spec: `%s'"), caller, spec);
+ m4_warn (context, 0, caller, _("bad syntax-spec: `%s'"), spec);
return resyntax;
}
@@ -524,8 +521,8 @@ M4BUILTIN_HANDLER (changesyntax)
}
if (m4_set_syntax (M4SYNTAX, key, action,
key ? m4_expand_ranges (spec, obs) : "") < 0)
- m4_warn (context, 0, _("%s: undefined syntax code: `%c'"),
- M4ARG (0), key);
+ m4_warn (context, 0, M4ARG (0), _("undefined syntax code: `%c'"),
+ key);
}
}
else
@@ -544,10 +541,10 @@ M4BUILTIN_HANDLER (debugfile)
if (argc == 1)
m4_debug_set_output (context, NULL);
else if (m4_get_safer_opt (context) && *M4ARG (1))
- m4_error (context, 0, 0, _("%s: disabled by --safer"), M4ARG (0));
+ m4_error (context, 0, 0, M4ARG (0), _("disabled by --safer"));
else if (!m4_debug_set_output (context, M4ARG (1)))
- m4_error (context, 0, errno, _("%s: cannot set debug file `%s'"),
- M4ARG (0), M4ARG (1));
+ m4_error (context, 0, errno, M4ARG (0), _("cannot set debug file `%s'"),
+ M4ARG (1));
}
@@ -585,8 +582,8 @@ M4BUILTIN_HANDLER (debugmode)
{
new_debug_level = m4_debug_decode (context, debug_level, M4ARG (1));
if (new_debug_level < 0)
- m4_error (context, 0, 0, _("%s: bad debug flags: `%s'"),
- M4ARG (0), M4ARG (1));
+ m4_error (context, 0, 0, M4ARG (0), _("bad debug flags: `%s'"),
+ M4ARG (1));
else
m4_set_debug_level_opt (context, new_debug_level);
}
@@ -612,7 +609,7 @@ M4BUILTIN_HANDLER (esyscmd)
if (m4_get_safer_opt (context))
{
- m4_error (context, 0, 0, _("%s: disabled by --safer"), M4ARG (0));
+ m4_error (context, 0, 0, M4ARG (0), _("disabled by --safer"));
return;
}
@@ -628,9 +625,8 @@ M4BUILTIN_HANDLER (esyscmd)
pin = popen (M4ARG (1), "r");
if (pin == NULL)
{
- m4_error (context, 0, errno,
- _("%s: cannot open pipe to command `%s'"),
- M4ARG (0), M4ARG (1));
+ m4_error (context, 0, errno, M4ARG (0),
+ _("cannot open pipe to command `%s'"), M4ARG (1));
m4_set_sysval (-1);
}
else
@@ -669,14 +665,14 @@ M4BUILTIN_HANDLER (format)
M4BUILTIN_HANDLER (indir)
{
if (! m4_is_symbol_value_text (argv[1]))
- m4_warn (context, 0, _("%s: invalid macro name ignored"), M4ARG (0));
+ m4_warn (context, 0, M4ARG (0), _("invalid macro name ignored"));
else
{
const char *name = M4ARG (1);
m4_symbol *symbol = m4_symbol_lookup (M4SYMTAB, name);
if (symbol == NULL)
- m4_warn (context, 0, _("%s: undefined macro `%s'"), M4ARG (0), name);
+ m4_warn (context, 0, M4ARG (0), _("undefined macro `%s'"), name);
else
{
int i;
@@ -821,12 +817,13 @@ M4BUILTIN_HANDLER (regexp)
return;
length = strlen (M4ARG (1));
- startpos = regexp_search (buf, M4ARG (1), length, 0, length, replace == NULL);
+ startpos = regexp_search (buf, M4ARG (1), length, 0, length,
+ replace == NULL);
if (startpos == -2)
{
- m4_error (context, 0, 0, _("%s: error matching regular expression `%s'"),
- me, pattern);
+ m4_error (context, 0, 0, me, _("error matching regular expression `%s'"),
+ pattern);
return;
}
diff --git a/modules/load.c b/modules/load.c
index bb6dc1b268e4659229739bdaacfb41df4b6061f6..11f9ecf2f611d084bebc23c86f776707536aca97 100644 (file)
--- a/modules/load.c
+++ b/modules/load.c
@@ -78,7 +78,7 @@ M4INIT_HANDLER (load)
{
const char *err = m4_module_makeresident (module);
if (err)
- m4_error (context, 0, 0, _("cannot make module `%s' resident: %s"),
+ m4_error (context, 0, 0, NULL, _("cannot make module `%s' resident: %s"),
m4_get_module_name (module), err);
}
diff --git a/modules/m4.c b/modules/m4.c
index c4a5c62eb43a24c1dff488e052e00160e8b5375d..1ba0fcb8af1e6ac2863bbc061d66d2ed368c2def 100644 (file)
--- a/modules/m4.c
+++ b/modules/m4.c
@@ -142,7 +142,7 @@ M4INIT_HANDLER (m4)
{
const char *err = m4_module_makeresident (module);
if (err)
- m4_error (context, 0, 0, _("cannot make module `%s' resident: %s"),
+ m4_error (context, 0, 0, NULL, _("cannot make module `%s' resident: %s"),
m4_get_module_name (module), err);
}
@@ -172,7 +172,7 @@ M4BUILTIN_HANDLER (define)
m4_symbol_define (M4SYMTAB, M4ARG (1), value);
}
else
- m4_warn (context, 0, _("%s: invalid macro name ignored"), M4ARG (0));
+ m4_warn (context, 0, M4ARG (0), _("invalid macro name ignored"));
}
M4BUILTIN_HANDLER (undefine)
@@ -183,7 +183,7 @@ M4BUILTIN_HANDLER (undefine)
const char *name = M4ARG (i);
if (!m4_symbol_lookup (M4SYMTAB, name))
- m4_warn (context, 0, _("%s: undefined macro `%s'"), M4ARG (0), name);
+ m4_warn (context, 0, M4ARG (0), _("undefined macro `%s'"), name);
else
m4_symbol_delete (M4SYMTAB, name);
}
@@ -203,7 +203,7 @@ M4BUILTIN_HANDLER (pushdef)
m4_symbol_pushdef (M4SYMTAB, M4ARG (1), value);
}
else
- m4_warn (context, 0, _("%s: invalid macro name ignored"), M4ARG (0));
+ m4_warn (context, 0, M4ARG (0), _("invalid macro name ignored"));
}
M4BUILTIN_HANDLER (popdef)
@@ -214,7 +214,7 @@ M4BUILTIN_HANDLER (popdef)
const char *name = M4ARG (i);
if (!m4_symbol_lookup (M4SYMTAB, name))
- m4_warn (context, 0, _("%s: undefined macro `%s'"), M4ARG (0), name);
+ m4_warn (context, 0, M4ARG (0), _("undefined macro `%s'"), name);
else
m4_symbol_popdef (M4SYMTAB, name);
}
@@ -344,8 +344,8 @@ m4_dump_symbols (m4 *context, m4_dump_symbol_data *data, int argc,
if (symbol != NULL)
dump_symbol_CB (NULL, M4ARG (i), symbol, data);
else if (complain)
- m4_warn (context, 0, _("%s: undefined macro `%s'"),
- M4ARG (0), M4ARG (i));
+ m4_warn (context, 0, M4ARG (0), _("undefined macro `%s'"),
+ M4ARG (i));
}
}
@@ -401,15 +401,15 @@ M4BUILTIN_HANDLER (defn)
m4_symbol *symbol = m4_symbol_lookup (M4SYMTAB, name);
if (!symbol)
- m4_warn (context, 0, _("%s: undefined macro `%s'"), M4ARG (0), name);
+ m4_warn (context, 0, M4ARG (0), _("undefined macro `%s'"), name);
else if (m4_is_symbol_text (symbol))
m4_shipout_string (context, obs, m4_get_symbol_text (symbol), 0, true);
else if (m4_is_symbol_func (symbol))
m4_push_builtin (context, m4_get_symbol_value (symbol));
else if (m4_is_symbol_placeholder (symbol))
- m4_warn (context, 0,
- _("%s: builtin `%s' requested by frozen file not found"),
- name, m4_get_symbol_placeholder (symbol));
+ m4_warn (context, 0, name,
+ _("builtin `%s' requested by frozen file not found"),
+ m4_get_symbol_placeholder (symbol));
else
{
assert (!"Bad token data type in m4_defn");
@@ -471,7 +471,7 @@ sysval_flush_helper (m4 *context, FILE *stream, bool report)
{
if (fflush (stream) == EOF && report)
{
- m4_error (context, 0, errno, _("write error"));
+ m4_error (context, 0, errno, NULL, _("write error"));
clearerr (stream);
}
}
@@ -519,7 +519,7 @@ M4BUILTIN_HANDLER (syscmd)
{
if (m4_get_safer_opt (context))
{
- m4_error (context, 0, 0, _("%s: disabled by --safer"), M4ARG (0));
+ m4_error (context, 0, 0, M4ARG (0), _("disabled by --safer"));
return;
}
@@ -621,12 +621,11 @@ M4BUILTIN_HANDLER (undivert)
{
m4_insert_file (context, fp);
if (fclose (fp) == EOF)
- m4_error (context, 0, errno, _("%s: error undiverting `%s'"),
- me, str);
+ m4_error (context, 0, errno, me, _("error undiverting `%s'"),
+ str);
}
else
- m4_error (context, 0, errno, _("%s: cannot undivert `%s'"),
- me, str);
+ m4_error (context, 0, errno, me, _("cannot undivert `%s'"), str);
}
}
}
@@ -685,7 +684,7 @@ include (m4 *context, int argc, m4_symbol_value **argv, bool silent)
if (fp == NULL)
{
if (!silent)
- m4_error (context, 0, errno, _("%s: cannot open `%s'"), M4ARG (0),
+ m4_error (context, 0, errno, M4ARG (0), _("cannot open `%s'"),
M4ARG (1));
return;
}
@@ -722,7 +721,7 @@ m4_make_temp (m4 *context, m4_obstack *obs, const char *macro,
if (m4_get_safer_opt (context))
{
- m4_error (context, 0, 0, _("%s: disabled by --safer"), macro);
+ m4_error (context, 0, 0, macro, _("disabled by --safer"));
return;
}
@@ -746,10 +745,10 @@ m4_make_temp (m4 *context, m4_obstack *obs, const char *macro,
/* This use of _() will need to change if xgettext ever changes
its undocumented behavior of parsing both string options. */
- m4_error (context, 0, errno,
- _(dir ? "%s: cannot create directory from template `%s'"
- : "%s: cannot create file from template `%s'"),
- macro, name);
+ m4_error (context, 0, errno, macro,
+ _(dir ? "cannot create directory from template `%s'"
+ : "cannot create file from template `%s'"),
+ name);
obstack_free (obs, obstack_finish (obs));
}
else if (! dir)
@@ -759,7 +758,7 @@ m4_make_temp (m4 *context, m4_obstack *obs, const char *macro,
/* Use the first argument as at template for a temporary file name. */
M4BUILTIN_HANDLER (maketemp)
{
- m4_warn (context, 0, _("%s: recommend using mkstemp instead"), M4ARG (0));
+ m4_warn (context, 0, M4ARG (0), _("recommend using mkstemp instead"));
if (m4_get_posixly_correct_opt (context))
{
/* POSIX states "any trailing 'X' characters [are] replaced with
@@ -829,8 +828,8 @@ M4BUILTIN_HANDLER (m4exit)
exit_code = EXIT_FAILURE;
if (exit_code < 0 || exit_code > 255)
{
- m4_warn (context, 0, _("%s: exit status out of range: `%d'"),
- M4ARG (0), exit_code);
+ m4_warn (context, 0, M4ARG (0), _("exit status out of range: `%d'"),
+ exit_code);
exit_code = EXIT_FAILURE;
}
diff --git a/modules/mpeval.c b/modules/mpeval.c
index ef7389f7d58d105b643d32c4854a6b2fddaabbe2..a7027523b0b221113c25bb3e3f38b24be6a9e2a1 100644 (file)
--- a/modules/mpeval.c
+++ b/modules/mpeval.c
@@ -209,7 +209,7 @@ static void
mpq2mpz (m4 *context, mpz_t z, const number q, const char *noisily)
{
if (noisily && mpz_cmp_si (mpq_denref (q), (long) 1) != 0)
- m4_warn (context, 0, _("loss of precision in eval: %s"), noisily);
+ m4_warn (context, 0, NULL, _("loss of precision in eval: %s"), noisily);
mpz_div (z, mpq_numref (q), mpq_denref (q));
}
diff --git a/src/freeze.c b/src/freeze.c
index fa40ce706a8713d11a3ea911cae6ad003bf407f1..6e467bb887353dbe92ff8e3771dbf5313f8d242f 100644 (file)
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -91,7 +91,7 @@ produce_resyntax_dump (m4 *context, FILE *file)
const char *resyntax = m4_regexp_syntax_decode (code);
if (!resyntax)
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("invalid regexp syntax code `%d'"), code);
/* No need to use produce_mem_dump, since we know all resyntax
@@ -216,7 +216,7 @@ produce_frozen_state (m4 *context, const char *name)
if (!file)
{
- m4_error (context, 0, errno, _("cannot open `%s'"), name);
+ m4_error (context, 0, errno, NULL, _("cannot open `%s'"), name);
return;
}
@@ -283,10 +283,10 @@ static void
issue_expect_message (m4 *context, int expected)
{
if (expected == '\n')
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("expecting line feed in frozen file"));
else
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("expecting character `%c' in frozen file"), expected);
}
@@ -411,7 +411,7 @@ reload_frozen_state (m4 *context, const char *name)
int ch = (version > 1 ? decode_char (File) \
: getc (File)); \
if (ch == EOF) \
- m4_error (context, EXIT_FAILURE, 0, \
+ m4_error (context, EXIT_FAILURE, 0, NULL, \
_("premature end of frozen file")); \
*p++ = ch; \
} \
@@ -457,7 +457,7 @@ reload_frozen_state (m4 *context, const char *name)
file = m4_path_search (context, name, (char **)NULL);
if (file == NULL)
- m4_error (context, EXIT_FAILURE, errno, _("cannot open `%s'"), name);
+ m4_error (context, EXIT_FAILURE, errno, NULL, _("cannot open `%s'"), name);
allocated[0] = 100;
string[0] = xmalloc (allocated[0]);
@@ -488,11 +488,11 @@ reload_frozen_state (m4 *context, const char *name)
break;
default:
if (version > 2)
- m4_error (context, EXIT_MISMATCH, 0,
+ m4_error (context, EXIT_MISMATCH, 0, NULL,
_("frozen file version %d greater than max supported of 2"),
version);
else
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("ill-formed frozen file, version directive expected"));
}
VALIDATE ('\n');
@@ -503,7 +503,7 @@ reload_frozen_state (m4 *context, const char *name)
switch (character)
{
default:
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("ill-formed frozen file, unknown directive %c"),
character);
@@ -529,7 +529,7 @@ reload_frozen_state (m4 *context, const char *name)
else
/* 3 argument 'F' operations are invalid for format
version 1. */
- m4_error (context, EXIT_FAILURE, 0, _("\
+ m4_error (context, EXIT_FAILURE, 0, NULL, _("\
ill-formed frozen file, version 2 directive `%c' encountered"), 'F');
}
else
@@ -578,7 +578,7 @@ ill-formed frozen file, version 2 directive `%c' encountered"), 'F');
if (version < 2)
{
/* 'M' operator is not supported in format version 1. */
- m4_error (context, EXIT_FAILURE, 0, _("\
+ m4_error (context, EXIT_FAILURE, 0, NULL, _("\
ill-formed frozen file, version 2 directive `%c' encountered"), 'M');
}
@@ -597,7 +597,7 @@ ill-formed frozen file, version 2 directive `%c' encountered"), 'M');
if (version < 2)
{
/* 'R' operator is not supported in format version 1. */
- m4_error (context, EXIT_FAILURE, 0, _("\
+ m4_error (context, EXIT_FAILURE, 0, NULL, _("\
ill-formed frozen file, version 2 directive `%c' encountered"), 'R');
}
@@ -611,7 +611,7 @@ ill-formed frozen file, version 2 directive `%c' encountered"), 'R');
m4_regexp_syntax_encode (string[0]));
if (m4_get_regexp_syntax_opt (context) < 0)
{
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("unknown regexp syntax code `%s'"), string[0]);
}
@@ -622,7 +622,7 @@ ill-formed frozen file, version 2 directive `%c' encountered"), 'R');
if (version < 2)
{
/* 'S' operator is not supported in format version 1. */
- m4_error (context, EXIT_FAILURE, 0, _("\
+ m4_error (context, EXIT_FAILURE, 0, NULL, _("\
ill-formed frozen file, version 2 directive `%c' encountered"), 'S');
}
@@ -640,7 +640,7 @@ ill-formed frozen file, version 2 directive `%c' encountered"), 'S');
? '=' : '+'), string[0]) < 0)
&& (syntax != '0円'))
{
- m4_error (context, 0, 0,
+ m4_error (context, 0, 0, NULL,
_("undefined syntax code %c"), syntax);
}
break;
@@ -732,7 +732,7 @@ ill-formed frozen file, version 2 directive `%c' encountered"), 'S');
{
/* 3 argument 'T' operations are invalid for format
version 1. */
- m4_error (context, EXIT_FAILURE, 0, _("\
+ m4_error (context, EXIT_FAILURE, 0, NULL, _("\
ill-formed frozen file, version 2 directive `%c' encountered"), 'T');
}
}
diff --git a/src/main.c b/src/main.c
index 3fed2e5bf80e99ca5500eb7cb1d80b150a92b867..96a9cc572d42b7b0d7924c3287d57f3a5568acff 100644 (file)
--- a/src/main.c
+++ b/src/main.c
@@ -309,7 +309,7 @@ process_file (m4 *context, const char *name)
FILE *fp = m4_path_search (context, name, &full_name);
if (fp == NULL)
{
- m4_error (context, 0, errno, _("cannot open file `%s'"), name);
+ m4_error (context, 0, errno, NULL, _("cannot open file `%s'"), name);
return;
}
m4_push_file (context, fp, full_name, true);
@@ -490,11 +490,11 @@ main (int argc, char *const *argv, char *const *envp)
{
const char *dlerr = lt_dlerror ();
if (dlerr == NULL)
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("failed to add search directory `%s'"),
optarg);
else
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("failed to add search directory `%s': %s"),
optarg, dlerr);
}
@@ -614,7 +614,8 @@ main (int argc, char *const *argv, char *const *envp)
/* Do the basic initializations. */
if (debugfile && !m4_debug_set_output (context, debugfile))
- m4_error (context, 0, errno, _("cannot set debug file `%s'"), debugfile);
+ m4_error (context, 0, errno, NULL, _("cannot set debug file `%s'"),
+ debugfile);
m4_input_init (context);
m4_output_init (context);
m4_include_env_init (context);
@@ -692,7 +693,7 @@ main (int argc, char *const *argv, char *const *envp)
case 'r':
m4_set_regexp_syntax_opt (context, m4_regexp_syntax_encode (arg));
if (m4_get_regexp_syntax_opt (context) < 0)
- m4_error (context, EXIT_FAILURE, 0,
+ m4_error (context, EXIT_FAILURE, 0, NULL,
_("bad regexp syntax option: `%s'"), arg);
break;
GNU M4 source repository
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /