summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2008-09-25 22:16:57 -0600
committerEric Blake <ebb9@byu.net>2008-09-25 22:19:36 -0600
commit21d7d8d495676649673124f16448b6576818fc1f (patch)
treee4c437c4eb8a97d841f6842e4c1b8b03a6e39e9d
parent4a5040d239a6afca25f52b4fc8e37c0aa020eb6a (diff)
downloadm4-21d7d8d495676649673124f16448b6576818fc1f.tar.gz
Tweak error message on command line failure.
* m4/m4private.h (includes): Use "quotearg.h". * src/main.c (process_file, main): Use nicer quotes for file name in error messages. * m4/input.c (file_clean, m4_push_file): Likewise. * m4/module.c (m4__module_open): Likewise. * src/freeze.c (produce_frozen_state, reload_frozen_state): Likewise. * modules/gnu.c (debugfile): Likewise. * modules/m4.c (undivert, include): Likewise. * tests/others.at (directory, stdin closed): Update tests. * tests/options.at (file names, --debugmode): Likewise. * doc/m4.texinfo (Debugmode): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit 5116db0fcd37e4480062b4819dca17a98a7890d7)
-rw-r--r--ChangeLog14
-rw-r--r--doc/m4.texinfo4
-rw-r--r--m4/input.c10
-rw-r--r--m4/m4private.h1
-rw-r--r--m4/module.c5
-rw-r--r--modules/gnu.c4
-rw-r--r--modules/m4.c12
-rw-r--r--src/freeze.c6
-rw-r--r--src/main.c17
-rw-r--r--tests/options.at6
-rw-r--r--tests/others.at12
11 files changed, 58 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index fd85259a..229b057b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2008-09-25 Eric Blake <ebb9@byu.net>
+ Tweak error message on command line failure.
+ * m4/m4private.h (includes): Use "quotearg.h".
+ * src/main.c (process_file, main): Use nicer quotes for file name
+ in error messages.
+ * m4/input.c (file_clean, m4_push_file): Likewise.
+ * m4/module.c (m4__module_open): Likewise.
+ * src/freeze.c (produce_frozen_state, reload_frozen_state):
+ Likewise.
+ * modules/gnu.c (debugfile): Likewise.
+ * modules/m4.c (undivert, include): Likewise.
+ * tests/others.at (directory, stdin closed): Update tests.
+ * tests/options.at (file names, --debugmode): Likewise.
+ * doc/m4.texinfo (Debugmode): Likewise.
+
Unify error handling for reading directories.
* m4/path.c (m4_path_search): Factor open attempts...
(m4_fopen): ...into new function, to reject directories.
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index 9f523e5e..cb31fb4f 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -4371,13 +4371,13 @@ to macro tracing.
@comment options: -dip
@example
$ @kbd{m4 -dip -I examples}
-@error{}m4debug: input read from stdin
+@error{}m4debug: input read from `stdin'
define(`foo', `m4wrap(`wrapped text
')dnl')
@result{}
include(`incl.m4')dnl
@error{}m4debug: path search for `incl.m4' found `examples/incl.m4'
-@error{}m4debug: input read from examples/incl.m4
+@error{}m4debug: input read from `examples/incl.m4'
@result{}Include file start
@result{}Include file end
@error{}m4debug: input reverted to stdin, line 3
diff --git a/m4/input.c b/m4/input.c
index 1a5fbc58..c3c47d09 100644
--- a/m4/input.c
+++ b/m4/input.c
@@ -330,12 +330,14 @@ file_clean (m4_input_block *me, m4 *context, bool cleanup)
if (ferror (me->u.u_f.fp))
{
- m4_error (context, 0, 0, NULL, _("error reading file `%s'"), me->file);
+ m4_error (context, 0, 0, NULL, _("error reading %s"),
+ quotearg_style (locale_quoting_style, 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, NULL, _("error reading file `%s'"), me->file);
+ m4_error (context, 0, errno, NULL, _("error reading %s"),
+ quotearg_style (locale_quoting_style, me->file));
start_of_input_line = me->u.u_f.line_start;
m4_set_output_line (context, -1);
return true;
@@ -373,8 +375,8 @@ m4_push_file (m4 *context, FILE *fp, const char *title, bool close_file)
next = NULL;
}
- m4_debug_message (context, M4_DEBUG_TRACE_INPUT,
- _("input read from %s"), title);
+ m4_debug_message (context, M4_DEBUG_TRACE_INPUT, _("input read from %s"),
+ quotearg_style (locale_quoting_style, title));
i = (m4_input_block *) obstack_alloc (current_input, sizeof *i);
i->funcs = &file_funcs;
diff --git a/m4/m4private.h b/m4/m4private.h
index 71249af8..49fba3b1 100644
--- a/m4/m4private.h
+++ b/m4/m4private.h
@@ -25,6 +25,7 @@
#include <ltdl.h>
#include "cloexec.h"
+#include "quotearg.h"
#include "xmemdup0.h"
typedef struct m4__search_path_info m4__search_path_info;
diff --git a/m4/module.c b/m4/module.c
index bb245731..0130a91c 100644
--- a/m4/module.c
+++ b/m4/module.c
@@ -412,8 +412,9 @@ m4__module_open (m4 *context, const char *name, m4_obstack *obs)
#endif /* DEBUG_MODULES */
m4_debug_message (context, M4_DEBUG_TRACE_MODULE,
- _("module %s: opening file `%s'"),
- name ? name : MODULE_SELF_NAME, info->filename);
+ _("module %s: opening file %s"),
+ name ? name : MODULE_SELF_NAME,
+ quotearg_style (locale_quoting_style, info->filename));
/* Provide the m4_module corresponding to the lt_dlhandle, if
not yet created. */
diff --git a/modules/gnu.c b/modules/gnu.c
index 74e1c4a7..fd557eb7 100644
--- a/modules/gnu.c
+++ b/modules/gnu.c
@@ -570,8 +570,8 @@ M4BUILTIN_HANDLER (debugfile)
else if (m4_get_safer_opt (context) && !m4_arg_empty (argv, 1))
m4_error (context, 0, 0, me, _("disabled by --safer"));
else if (!m4_debug_set_output (context, me, M4ARG (1)))
- m4_error (context, 0, errno, me, _("cannot set debug file `%s'"),
- M4ARG (1));
+ m4_error (context, 0, errno, me, _("cannot set debug file %s"),
+ quotearg_style (locale_quoting_style, M4ARG (1)));
}
diff --git a/modules/m4.c b/modules/m4.c
index 0c9a1456..e9695a32 100644
--- a/modules/m4.c
+++ b/modules/m4.c
@@ -28,6 +28,7 @@
# include "m4private.h"
#endif
+#include "quotearg.h"
#include "stdlib--.h"
#include "tempname.h"
#include "unistd--.h"
@@ -600,11 +601,12 @@ M4BUILTIN_HANDLER (undivert)
{
m4_insert_file (context, fp);
if (fclose (fp) == EOF)
- m4_error (context, 0, errno, me, _("error undiverting `%s'"),
- str);
+ m4_error (context, 0, errno, me, _("error undiverting %s"),
+ quotearg_style (locale_quoting_style, str));
}
else
- m4_error (context, 0, errno, me, _("cannot undivert `%s'"), str);
+ m4_error (context, 0, errno, me, _("cannot undivert `%s'"),
+ quotearg_style (locale_quoting_style, str));
}
}
}
@@ -664,8 +666,8 @@ include (m4 *context, int argc, m4_macro_args *argv, bool silent)
if (fp == NULL)
{
if (!silent)
- m4_error (context, 0, errno, m4_arg_info (argv), _("cannot open `%s'"),
- M4ARG (1));
+ m4_error (context, 0, errno, m4_arg_info (argv), _("cannot open %s"),
+ quotearg_style (locale_quoting_style, M4ARG (1)));
return;
}
diff --git a/src/freeze.c b/src/freeze.c
index 44400f3f..5d5b4eee 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -275,7 +275,8 @@ produce_frozen_state (m4 *context, const char *name)
if (!file)
{
- m4_error (context, 0, errno, NULL, _("cannot open `%s'"), name);
+ m4_error (context, 0, errno, NULL, _("cannot open %s"),
+ quotearg_style (locale_quoting_style, name));
return;
}
@@ -564,7 +565,8 @@ 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, NULL, _("cannot open `%s'"), name);
+ m4_error (context, EXIT_FAILURE, errno, NULL, _("cannot open %s"),
+ quotearg_style (locale_quoting_style, name));
m4_set_current_file (context, name);
allocated[0] = 100;
diff --git a/src/main.c b/src/main.c
index 0f0b0140..b8900417 100644
--- a/src/main.c
+++ b/src/main.c
@@ -306,14 +306,17 @@ static void
process_file (m4 *context, const char *name)
{
if (strcmp (name, "-") == 0)
- m4_push_file (context, stdin, "stdin", false);
+ /* TRANSLATORS: This is a short name for `standard input', used
+ when a command line file was given as `-'. */
+ m4_push_file (context, stdin, _("stdin"), false);
else
{
char *full_name;
FILE *fp = m4_path_search (context, name, &full_name);
if (fp == NULL)
{
- m4_error (context, 0, errno, NULL, _("cannot open file `%s'"), name);
+ m4_error (context, 0, errno, NULL, _("cannot open %s"),
+ quotearg_style (locale_quoting_style, name));
return;
}
m4_push_file (context, fp, full_name, true);
@@ -529,9 +532,9 @@ main (int argc, char *const *argv, char *const *envp)
break;
case 'd':
- /* Staggered handling of 'd', since -dm is useful prior to
- first file and prior to reloading, but other -d must also
- have effect between files. */
+ /* Staggered handling of 'd', since -dm is useful prior to
+ first file and prior to reloading, but other -d must also
+ have effect between files. */
if (seen_file || frozen_file_to_read)
goto defer;
if (m4_debug_decode (context, optarg) < 0)
@@ -615,8 +618,8 @@ main (int argc, char *const *argv, char *const *envp)
/* Do the basic initializations. */
if (debugfile && !m4_debug_set_output (context, NULL, debugfile))
- m4_error (context, 0, errno, NULL, _("cannot set debug file `%s'"),
- debugfile);
+ m4_error (context, 0, errno, NULL, _("cannot set debug file %s"),
+ quotearg_style (locale_quoting_style, debugfile));
m4_input_init (context);
m4_output_init (context);
m4_include_env_init (context);
diff --git a/tests/options.at b/tests/options.at
index 904cc7d6..31a1cedb 100644
--- a/tests/options.at
+++ b/tests/options.at
@@ -98,7 +98,7 @@ dnl Check that all files are processed even after missing file
AT_DATA([in], [[hello world
]])
AT_CHECK_M4([oops in], [1], [[hello world
-]], [[m4: cannot open file `oops': No such file or directory
+]], [[m4: cannot open `oops': No such file or directory
]])
dnl Check that '-' means stdin, even if ./- exists.
@@ -417,10 +417,10 @@ m4debug: module gnu: opened
m4debug: module gnu: builtins loaded
m4debug: module gnu: macros loaded
m4debug: path search for `in' found `in'
-m4debug: input read from in
+m4debug: input read from `in'
m4trace:in:1: -1- id 1: include ... = <include>{m4}
m4debug:in:1: path search for `nested' found `nested'
-m4debug:in:1: input read from nested
+m4debug:in:1: input read from `nested'
m4trace:in:1: -1- id 1: include(`nested') -> <file: nested>
m4trace:nested:1: -1- id 2: m4wrap ... = <m4wrap>{m4}
m4trace:nested:1: -1- id 2: m4wrap(`divnum
diff --git a/tests/others.at b/tests/others.at
index 71a1ee05..3a23d193 100644
--- a/tests/others.at
+++ b/tests/others.at
@@ -144,7 +144,7 @@ AT_DATA([in3.m4],
AT_CHECK_M4([in1.m4/], [1], [], [stderr])
dnl mingw fails with EINVAL rather than the expected ENOTDIR
AT_CHECK([sed 's/Invalid argument/Not a directory/' stderr], [0],
-[[m4: cannot open file `in1.m4/': Not a directory
+[[m4: cannot open `in1.m4/': Not a directory
]])
AT_CHECK_M4([in1.m4], [1], [[
@@ -613,13 +613,13 @@ AT_CHECK_M4([in.m4], [0], [ignore], [ignore], [-])
dnl error when stdin must be read
AT_CHECK_M4([], [1], [],
-[[m4:stdin:1: error reading file `stdin'
+[[m4:stdin:1: error reading `stdin'
m4: error closing file: Bad file descriptor
]], [-])
dnl error when stdin must be read
AT_CHECK_M4([-], [1], [],
-[[m4:stdin:1: error reading file `stdin'
+[[m4:stdin:1: error reading `stdin'
m4: error closing file: Bad file descriptor
]], [-])
@@ -627,8 +627,8 @@ dnl error once per command-line attempt to read stdin
AT_DATA([in.m4], [[hello world
]])
AT_CHECK_M4([- in.m4 -], [1], [[hello world
-]], [[m4:stdin:1: error reading file `stdin'
-m4:stdin:1: error reading file `stdin'
+]], [[m4:stdin:1: error reading `stdin'
+m4:stdin:1: error reading `stdin'
m4: error closing file: Bad file descriptor
]], [-])
@@ -653,7 +653,7 @@ AT_DATA([in2.m4], [[divert(`-1')undivert
divert`'world
]])
AT_CHECK_M4([in.m4 - in2.m4], [1], [[hello world
-]], [[m4:stdin:1: error reading file `stdin'
+]], [[m4:stdin:1: error reading `stdin'
m4: error closing file: Bad file descriptor
]], [-])