[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] GNU M4 source repository branch, master, updated. cvs-readonly-162
From: |
Eric Blake |
Subject: |
[SCM] GNU M4 source repository branch, master, updated. cvs-readonly-162-g21d7d8d |
Date: |
Fri, 26 Sep 2008 04:21:23 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU M4 source repository".
http://git.sv.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=21d7d8d495676649673124f16448b6576818fc1f
The branch, master has been updated
via 21d7d8d495676649673124f16448b6576818fc1f (commit)
via 4a5040d239a6afca25f52b4fc8e37c0aa020eb6a (commit)
via d46d4cdd7e8c0edef237818f7f254130d346cc97 (commit)
from 1948a3f2b75f967d540b37bea3485282e407c922 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 21d7d8d495676649673124f16448b6576818fc1f
Author: Eric Blake <address@hidden>
Date: Thu Sep 25 22:16:57 2008 -0600
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 <address@hidden>
(cherry picked from commit 5116db0fcd37e4480062b4819dca17a98a7890d7)
commit 4a5040d239a6afca25f52b4fc8e37c0aa020eb6a
Author: Eric Blake <address@hidden>
Date: Wed Sep 24 22:02:45 2008 -0600
Unify error handling for reading directories.
* m4/path.c (m4_path_search): Factor open attempts...
(m4_fopen): ...into new function, to reject directories.
* tests/others.at (directory): Enhance test.
* doc/m4.texinfo (Include): Document that directories cannot be
input files.
Signed-off-by: Eric Blake <address@hidden>
(cherry picked from commit eed62f0d2729c243d7c081c48d789f9d86fa340f)
commit d46d4cdd7e8c0edef237818f7f254130d346cc97
Author: Eric Blake <address@hidden>
Date: Thu Sep 25 07:17:25 2008 -0600
Avoid bugs on platforms that mishandle trailing /.
* ltdl/m4/gnulib-cache.m4: Import fopen module.
* tests/others.at (directory): New test.
Signed-off-by: Eric Blake <address@hidden>
(cherry picked from commit ce1f8f6861b928b7b587d69eee2000a0101e3381)
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 27 +++++++++++++++++++++++
doc/m4.texinfo | 7 +++--
ltdl/m4/gnulib-cache.m4 | 3 +-
m4/input.c | 10 +++++---
m4/m4private.h | 1 +
m4/module.c | 5 ++-
m4/path.c | 34 +++++++++++++++++++++-------
modules/gnu.c | 4 +-
modules/m4.c | 12 ++++++----
src/freeze.c | 6 +++-
src/main.c | 17 ++++++++------
tests/options.at | 6 ++--
tests/others.at | 54 ++++++++++++++++++++++++++++++++++++++++++----
13 files changed, 143 insertions(+), 43 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1acc167..229b057 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2008-09-25 Eric Blake <address@hidden>
+
+ 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.
+ * tests/others.at (directory): Enhance test.
+ * doc/m4.texinfo (Include): Document that directories cannot be
+ input files.
+
+ Avoid bugs on platforms that mishandle trailing /.
+ * ltdl/m4/gnulib-cache.m4: Import fopen module.
+ * tests/others.at (directory): New test.
+
2008-09-16 Eric Blake <address@hidden>
Fix bootstrap for Solaris /bin/sh.
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index ad0b2d4..cb31fb4 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}
address@hidden: input read from stdin
address@hidden: 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'
address@hidden: input read from examples/incl.m4
address@hidden: input read from `examples/incl.m4'
@result{}Include file start
@result{}Include file end
@error{}m4debug: input reverted to stdin, line 3
@@ -5729,7 +5729,8 @@ the previous input file.
The expansion of @code{include} and @code{sinclude} is therefore the
contents of @var{file}.
-If @var{file} does not exist (or cannot be read), the expansion is void,
+If @var{file} does not exist, is a directory, or cannot otherwise be
+read, the expansion is void,
and @code{include} will fail with an error while @code{sinclude} is
silent. The empty string counts as a file that does not exist.
diff --git a/ltdl/m4/gnulib-cache.m4 b/ltdl/m4/gnulib-cache.m4
index f61b8d7..64ef86b 100644
--- a/ltdl/m4/gnulib-cache.m4
+++ b/ltdl/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --local-dir=local --lib=libgnu
--source-base=gnu --m4-base=ltdl/m4 --doc-base=doc --aux-dir=build-aux
--with-tests --libtool --macro-prefix=M4 assert autobuild avltree-oset
binary-io clean-temp cloexec close-stream closein config-h configmake dirname
error exit fdl fflush filenamecat flexmember fopen-safer fseeko gendocs gettext
git-version-gen gnumakefile gnupload gpl-3.0 intprops memmem mkstemp obstack
obstack-printf-posix progname propername quote regex regexprops-generic
sprintf-posix stdbool stdlib-safer strnlen strtod strtol tempname unlocked-io
vasnprintf-posix verify verror xalloc xalloc-die xmemdup0 xprintf-posix
xstrndup xvasprintf-posix
+# gnulib-tool --import --dir=. --local-dir=local --lib=libgnu
--source-base=gnu --m4-base=ltdl/m4 --doc-base=doc --tests-base=tests/gnu
--aux-dir=build-aux --with-tests --libtool --macro-prefix=M4 assert autobuild
avltree-oset binary-io clean-temp cloexec close-stream closein config-h
configmake dirname error exit fdl fflush filenamecat flexmember fopen
fopen-safer fseeko gendocs gettext git-version-gen gnumakefile gnupload gpl-3.0
intprops memmem mkstemp obstack obstack-printf-posix progname propername quote
regex regexprops-generic sprintf-posix stdbool stdlib-safer strnlen strtod
strtol tempname unlocked-io vasnprintf-posix verify verror xalloc xalloc-die
xmemdup0 xprintf-posix xstrndup xvasprintf-posix
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([local])
@@ -37,6 +37,7 @@ gl_MODULES([
fflush
filenamecat
flexmember
+ fopen
fopen-safer
fseeko
gendocs
diff --git a/m4/input.c b/m4/input.c
index 1a5fbc5..c3c47d0 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 71249af..49fba3b 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 bb24573..0130a91 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/m4/path.c b/m4/path.c
index 91991e0..bf15193 100644
--- a/m4/path.c
+++ b/m4/path.c
@@ -123,6 +123,29 @@ m4_add_include_directory (m4 *context, const char *dir,
bool prepend)
#endif
}
+/* Attempt to open FILE; if it opens, verify that it is not a
+ directory, and ensure it does not leak across execs. */
+static FILE *
+m4_fopen (m4 *context, const char *file, const char *mode)
+{
+ FILE *fp = fopen (file, "r");
+ if (fp)
+ {
+ struct stat st;
+ int fd = fileno (fp);
+ if (fstat (fd, &st) == 0 && S_ISDIR (st.st_mode))
+ {
+ fclose (fp);
+ errno = EISDIR;
+ return NULL;
+ }
+ if (set_cloexec_flag (fileno (fp), true) != 0)
+ m4_error (context, 0, errno, NULL,
+ _("cannot protect input file across forks"));
+ }
+ return fp;
+}
+
/* Search for FILE according to -B options, `.', -I options, then
M4PATH environment. If successful, return the open file, and if
RESULT is not NULL, set *RESULT to a malloc'd string that
@@ -152,12 +175,9 @@ m4_path_search (m4 *context, const char *file, char
**expanded_name)
lookup will do the trick. */
if (IS_ABSOLUTE_FILE_NAME (file) || m4_get_posixly_correct_opt (context))
{
- fp = fopen (file, "r");
+ fp = m4_fopen (context, file, "r");
if (fp != NULL)
{
- if (set_cloexec_flag (fileno (fp), true) != 0)
- m4_error (context, 0, errno, NULL,
- _("cannot protect input file across forks"));
if (expanded_name != NULL)
*expanded_name = xstrdup (file);
return fp;
@@ -174,16 +194,12 @@ m4_path_search (m4 *context, const char *file, char
**expanded_name)
xfprintf (stderr, "path_search (%s) -- trying %s\n", file, name);
#endif
- fp = fopen (name, "r");
+ fp = m4_fopen (context, name, "r");
if (fp != NULL)
{
m4_debug_message (context, M4_DEBUG_TRACE_PATH,
_("path search for `%s' found `%s'"),
file, name);
- if (set_cloexec_flag (fileno (fp), true) != 0)
- m4_error (context, 0, errno, NULL,
- _("cannot protect input file across forks"));
-
if (expanded_name != NULL)
*expanded_name = name;
else
diff --git a/modules/gnu.c b/modules/gnu.c
index 74e1c4a..fd557eb 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 0c9a145..e9695a3 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 44400f3..5d5b4ee 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 0f0b014..b890041 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 904cc7d..31a1ced 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 a1111c6..3a23d19 100644
--- a/tests/others.at
+++ b/tests/others.at
@@ -124,6 +124,50 @@ Done
AT_CLEANUP
+## --------- ##
+## directory ##
+## --------- ##
+
+AT_SETUP([directory])
+
+AT_DATA([in1.m4],
+[[include(`in2.m4/')
+]])
+AT_DATA([in2.m4],
+[[sinclude(`in2.m4/')
+sinclude(`.')
+]])
+AT_DATA([in3.m4],
+[[include(`.')
+]])
+
+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 `in1.m4/': Not a directory
+]])
+
+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:in1.m4:1: include: cannot open `in2.m4/': Not a directory
+]])
+
+AT_CHECK_M4([in2.m4], [0], [[
+
+]])
+
+AT_CHECK_M4([in3.m4], [1], [[
+]], [stderr])
+dnl mingw fails with EACCES rather than the expected EISDIR
+AT_CHECK([sed 's/Permission denied/Is a directory/' stderr], [0],
+[[m4:in3.m4:1: include: cannot open `.': Is a directory
+]])
+
+AT_CLEANUP
+
+
## ------- ##
## foreach ##
## ------- ##
@@ -569,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
]], [-])
@@ -583,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
]], [-])
@@ -609,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
]], [-])
hooks/post-receive
--
GNU M4 source repository
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] GNU M4 source repository branch, master, updated. cvs-readonly-162-g21d7d8d,
Eric Blake <=