m4-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU M4 source repository branch, branch-1.4, updated. v1.4.11-50-g


From: Eric Blake
Subject: [SCM] GNU M4 source repository branch, branch-1.4, updated. v1.4.11-50-geed62f0
Date: Thu, 25 Sep 2008 04:16:49 +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=eed62f0d2729c243d7c081c48d789f9d86fa340f

The branch, branch-1.4 has been updated
       via  eed62f0d2729c243d7c081c48d789f9d86fa340f (commit)
       via  ce1f8f6861b928b7b587d69eee2000a0101e3381 (commit)
      from  389962e4de8a76bf4c32a0a1febb71f3289e1660 (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 eed62f0d2729c243d7c081c48d789f9d86fa340f
Author: Eric Blake <address@hidden>
Date:   Wed Sep 24 21:42:53 2008 -0600

    Unify error handling for reading directories.
    
    * src/path.c (m4_path_search): Factor open attempts...
    (m4_fopen): ...into new function, to reject directories.
    * doc/m4.texinfo (Include): Document that directories cannot be
    input files.
    
    Signed-off-by: Eric Blake <address@hidden>

commit ce1f8f6861b928b7b587d69eee2000a0101e3381
Author: Eric Blake <address@hidden>
Date:   Wed Sep 24 20:41:05 2008 -0600

    Avoid bugs on platforms that mishandle trailing /.
    
    * m4/gnulib-cache.m4: Import fopen module.
    * doc/m4.texinfo (Command line files, Include): Add tests.
    (Using frozen files): This test now works on mingw.
    * checks/check-them (examples): Expand xerr to allow ignoring
    error output because of differences in platform errno values.
    
    Signed-off-by: Eric Blake <address@hidden>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |   15 ++++++++++++++
 checks/check-them  |   19 ++++++++++-------
 doc/m4.texinfo     |   55 ++++++++++++++++++++++++++++++++++++++++++++++++---
 m4/gnulib-cache.m4 |    3 +-
 src/path.c         |   34 +++++++++++++++++++++++--------
 5 files changed, 104 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 69969b0..b2e6b57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2008-09-24  Eric Blake  <address@hidden>
+
+       Unify error handling for reading directories.
+       * src/path.c (m4_path_search): Factor open attempts...
+       (m4_fopen): ...into new function, to reject directories.
+       * doc/m4.texinfo (Include): Document that directories cannot be
+       input files.
+
+       Avoid bugs on platforms that mishandle trailing /.
+       * m4/gnulib-cache.m4: Import fopen module.
+       * doc/m4.texinfo (Command line files, Include): Add tests.
+       (Using frozen files): This test now works on mingw.
+       * checks/check-them (examples): Expand xerr to allow ignoring
+       error output because of differences in platform errno values.
+
 2008-09-22  Eric Blake  <address@hidden>
 
        Support alternate path separator.
diff --git a/checks/check-them b/checks/check-them
index fac1b2b..46162ca 100755
--- a/checks/check-them
+++ b/checks/check-them
@@ -126,14 +126,17 @@ do
   fi
 
   xerrfile=`sed -n 's/^dnl @ expected error: //p' "$file"`
-  if test -z "$xerrfile" ; then
-    sed '/^dnl @error{}/!d
-        s///; '"s|^m4:|$m4name:|; s|examples/|$examples/|" \
-      "$file" > $xerr
-  else
-    sed "s|^m4:|$m4name:|; s|examples/|$examples/|" \
-      "$examples/$xerrfile" > $xerr
-  fi
+  case $xerrfile in
+    ignore)
+      cp $err $xerr ;;
+    '')
+      sed '/^dnl @error{}/!d
+          s///; '"s|^m4:|$m4name:|; s|examples/|$examples/|" \
+        "$file" > $xerr ;;
+    *)
+      sed "s|^m4:|$m4name:|; s|examples/|$examples/|" \
+        "$examples/$xerrfile" > $xerr ;;
+  esac
 
   # For the benefit of mingw, normalize \r\n line endings
   if $strip_needed ; then
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index ff653c2..6fcd9f3 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -925,6 +925,19 @@ If you need to read a file whose name starts with a 
@file{-}, you can
 specify it as @samp{./-file}, or use @option{--} to mark the end of
 options.
 
address@hidden
address@hidden Test that 'm4 file/' detects that file is not a directory; we
address@hidden can assume that the current directory contains a Makefile.
address@hidden mingw fails with EINVAL rather than ENOTDIR.
+
address@hidden status: 1
address@hidden xerr: ignore
address@hidden options: Makefile/
address@hidden
address@hidden: Makefile/: Not a directory
address@hidden example
address@hidden ignore
+
 @node Syntax
 @chapter Lexical and syntactic conventions
 
@@ -4693,7 +4706,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.
 
@@ -4774,6 +4788,42 @@ files on the command line.
 In @acronym{GNU} @code{m4}, an alternative method of reading files is
 using @code{undivert} (@pxref{Undivert}) on a named file.
 
address@hidden
address@hidden Test that include(`file/') detects that file is not a
address@hidden directory; we can assume that the current directory contains a
address@hidden Makefile.  mingw fails with EINVAL rather than ENOTDIR.
+
address@hidden status: 1
address@hidden xerr: ignore
address@hidden
+include(`Makefile/')
address@hidden:stdin:1: cannot open `Makefile/': Not a directory
address@hidden
address@hidden example
+
address@hidden POSIX allows, but doesn't require, failure on reading
address@hidden directories.  But since they aren't text files, it never makes
address@hidden sense, so we globally forbid it even if fopen doesn't.  mingw
address@hidden fails with EACCES rather than EISDIR.
+
address@hidden status: 1
address@hidden xerr: ignore
address@hidden
+include(`.')
address@hidden:stdin:1: cannot open `.': Is a directory
address@hidden
address@hidden example
+
address@hidden Meanwhile, ignore errors with sinclude.
+
address@hidden
+sinclude(`Makefile/')
address@hidden
+sinclude(`.')
address@hidden
address@hidden example
address@hidden ignore
+
 @node Search Path
 @section Searching for include files
 
@@ -6767,9 +6817,6 @@ changed strings for quotes or comments.  And future 
releases of
 
 @comment options: -F /dev/null
 @example
-ifdef(`__unix__', ,
-      `errprint(` skipping: /dev/null not known to exist
-')m4exit(`77')')dnl
 traceon(`undefined')dnl
 @end example
 
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 49f7c18..96864de 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-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 --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])
@@ -36,6 +36,7 @@ gl_MODULES([
   fdl
   fflush
   filenamecat
+  fopen
   fopen-safer
   fseeko
   gendocs
diff --git a/src/path.c b/src/path.c
index 4b904fc..317bd4e 100644
--- a/src/path.c
+++ b/src/path.c
@@ -105,6 +105,29 @@ add_include_directory (const char *dir)
 #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 (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 (fd, true) != 0)
+       M4ERROR ((warning_status, errno,
+                 "Warning: cannot protect input file across forks"));
+    }
+  return fp;
+}
+
 /* Search for FILE, first in `.', then according to -I options.  If
    successful, return the open file, and if RESULT is not NULL, set
    *RESULT to a malloc'd string that represents the file found with
@@ -129,12 +152,9 @@ m4_path_search (const char *file, char **result)
     }
 
   /* Look in current working directory first.  */
-  fp = fopen (file, "r");
+  fp = m4_fopen (file, "r");
   if (fp != NULL)
     {
-      if (set_cloexec_flag (fileno (fp), true) != 0)
-       M4ERROR ((warning_status, errno,
-                 "Warning: cannot protect input file across forks"));
       if (result)
        *result = xstrdup (file);
       return fp;
@@ -153,19 +173,15 @@ m4_path_search (const char *file, char **result)
       xfprintf (stderr, "m4_path_search (%s) -- trying %s\n", file, name);
 #endif
 
-      fp = fopen (name, "r");
+      fp = m4_fopen (name, "r");
       if (fp != NULL)
        {
          if (debug_level & DEBUG_TRACE_PATH)
            DEBUG_MESSAGE2 ("path search for `%s' found `%s'", file, name);
-         if (set_cloexec_flag (fileno (fp), true) != 0)
-           M4ERROR ((warning_status, errno,
-                     "Warning: cannot protect input file across forks"));
          if (result)
            *result = name;
          else
            free (name);
-         errno = e;
          return fp;
        }
       free (name);


hooks/post-receive
--
GNU M4 source repository




reply via email to

[Prev in Thread] Current Thread [Next in Thread]