Re: avoid fopen bugs

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 9/24/2008 10:16 PM:
> In both cases, mingw does not use the typical errno value.  So I had to
> modify the testsuite to allow ignoring stderr, so as to avoid failures
> from the difference in strerror output.

In the process of porting that patch to master, I noticed that the error
messages were not printed consistently.  Committing this:

- --
Don't work too hard, make some time for fun as well!

Eric Blake             [email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjcQmgACgkQ84KuGfSFAYCGeQCfUrSXS+iBU3kVfecsGT8EEcIj
x2EAoMZsxjtROQ0wmRTeMdFvkm2KVrVR
=cg2o
-----END PGP SIGNATURE-----

_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch379 (text/plain, 4.1 KB)
From 5116db0fcd37e4480062b4819dca17a98a7890d7 Mon Sep 17 00:00:00 2001
From: Eric Blake <[email protected]>
Date: Thu, 25 Sep 2008 06:32:26 -0600
Subject: [PATCH] Tweak error message on command line failure.

* src/m4.c (process_file): Match wording of include builtin.
* src/freeze.c (produce_frozen_state): Likewise.
* m4/gnulib-cache.m4: Regenerate.
* doc/m4.texinfo (Command line files, Using frozen files): Update
tests accordingly.

Signed-off-by: Eric Blake <[email protected]>
---
 ChangeLog          |    9 +++++++++
 doc/m4.texinfo     |    4 ++--
 m4/gnulib-cache.m4 |    2 +-
 src/freeze.c       |    2 +-
 src/m4.c           |    2 +-
 5 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b2e6b57..c6d3b67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-09-25  Eric Blake  <[email protected]>
+
+	Tweak error message on command line failure.
+	* src/m4.c (process_file): Match wording of include builtin.
+	* src/freeze.c (produce_frozen_state): Likewise.
+	* m4/gnulib-cache.m4: Regenerate.
+	* doc/m4.texinfo (Command line files, Using frozen files): Update
+	tests accordingly.
+
 2008-09-24  Eric Blake  <[email protected]>
 
 	Unify error handling for reading directories.
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index 6fcd9f3..940bd9c 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -934,7 +934,7 @@ Command line files
 @comment xerr: ignore
 @comment options: Makefile/
 @example
-@error{}m4: Makefile/: Not a directory
+@error{}m4: cannot open `Makefile/': Not a directory
 @end example
 @end ignore
 
@@ -6843,7 +6843,7 @@ Using frozen files
 @example
 $ @kbd{m4 -F /none/such}
 ^D
-@error{}m4: cannot open /none/such: No such file or directory
+@error{}m4: cannot open `/none/such': No such file or directory
 @end example
 @end ignore
 
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 96864de..f6cc1ac 100644
--- a/m4/gnulib-cache.m4
+++ b/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=libm4 --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream closein config-h dirname error fdl fflush filenamecat fopen fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload gpl-3.0 intprops mkstemp obstack progname regex sigaction stdbool stdint stdlib-safer strsignal strstr strtod strtol unlocked-io verror version-etc version-etc-fsf xalloc xprintf xvasprintf-posix
+#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream closein config-h dirname error fdl fflush filenamecat fopen fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload gpl-3.0 intprops mkstemp obstack progname regex sigaction stdbool stdint stdlib-safer strsignal strstr strtod strtol unlocked-io verror version-etc version-etc-fsf xalloc xprintf xvasprintf-posix
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([local])
diff --git a/src/freeze.c b/src/freeze.c
index 2a7ff30..ddc2e08 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -59,7 +59,7 @@ produce_frozen_state (const char *name)
   file = fopen (name, O_BINARY ? "wb" : "w");
   if (!file)
     {
-      M4ERROR ((EXIT_FAILURE, errno, "cannot open %s", name));
+      M4ERROR ((EXIT_FAILURE, errno, "cannot open `%s'", name));
       return;
     }
 
diff --git a/src/m4.c b/src/m4.c
index ee0fe8a..a414086 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -332,7 +332,7 @@ process_file (const char *name)
       FILE *fp = m4_path_search (name, &full_name);
       if (fp == NULL)
 	{
-	  error (0, errno, "%s", name);
+	  error (0, errno, "cannot open `%s'", name);
 	  /* Set the status to EXIT_FAILURE, even though we
 	     continue to process files after a missing file.  */
 	  retcode = EXIT_FAILURE;
-- 
1.6.0.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.