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.12-35-g


From: Eric Blake
Subject: [SCM] GNU M4 source repository branch, branch-1.4, updated. v1.4.12-35-gc05bae4
Date: Fri, 13 Mar 2009 13:39:56 +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=c05bae4ccb7b39543b019d612a4bdb6b7c6f0b08

The branch, branch-1.4 has been updated
       via  c05bae4ccb7b39543b019d612a4bdb6b7c6f0b08 (commit)
       via  060b5319b3452a2464eea1defc5fae608a12b574 (commit)
       via  b7163441589626c1e758c71d3df2b0fcfeb11008 (commit)
       via  9915ef54d55fae837209bc87d35c777715653bed (commit)
       via  5d2f4a97b5e56a9bd0ce543c3f74ce3084808fe6 (commit)
      from  e94228df28e881da59dd86bfb513ad9d07ca392a (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 c05bae4ccb7b39543b019d612a4bdb6b7c6f0b08
Author: Eric Blake <address@hidden>
Date:   Thu Mar 12 19:25:01 2009 -0600

    Fix awk script portability.
    
    * checks/get-them: In gsub, properly escape {.  Close all files
    before exiting.
    Reported by Gary V. Vaughan.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 060b5319b3452a2464eea1defc5fae608a12b574
Author: Eric Blake <address@hidden>
Date:   Mon Mar 2 15:08:31 2009 -0700

    Allow configuration choice in syscmd shell.
    
    * configure.ac (SYSCMD_SHELL): New test.
    * src/builtin.c (m4_syscmd, m4_esyscmd): Use it to avoid
    hard-coding the shell location.
    * doc/m4.texinfo (Syscmd, Esyscmd): Document this.
    * README: Document new configure option.
    * NEWS: Likewise.
    
    Signed-off-by: Eric Blake <address@hidden>

commit b7163441589626c1e758c71d3df2b0fcfeb11008
Author: Eric Blake <address@hidden>
Date:   Mon Mar 2 07:22:17 2009 -0700

    Remove cruft now that gnulib modules do the work.
    
    * configure.ac (M4_cv_func_system_consistent): Delete.
    * src/builtin.c (M4SYSVAL_EXITBITS, M4SYSVAL_TERMSIGBITS):
    Delete.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 9915ef54d55fae837209bc87d35c777715653bed
Author: Eric Blake <address@hidden>
Date:   Mon Mar 2 06:54:28 2009 -0700

    Use gnulib pipe module instead of popen(3).
    
    * m4/gnulib-cache.m4: Import pipe and wait-process modules.
    * src/builtin.c (m4_esyscmd): Rewrite with pipe module.
    Resolves a failure on AIX, reported by Gary V. Vaughan.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 5d2f4a97b5e56a9bd0ce543c3f74ce3084808fe6
Author: Eric Blake <address@hidden>
Date:   Mon Mar 2 06:53:23 2009 -0700

    Use gnulib execute module instead of system(3).
    
    * m4/gnulib-cache.m4: Import execute module.
    * src/builtin.c (m4_sysval): Move computation...
    (m4_esyscmd): ...into caller.
    (m4_syscmd): Rewrite with execute module.
    Resolves a failure on AIX, reported by Gary V. Vaughan.
    
    Signed-off-by: Eric Blake <address@hidden>

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

Summary of changes:
 ChangeLog          |   34 +++++++++++
 NEWS               |    3 +
 README             |   10 +++-
 checks/get-them    |   19 ++++---
 configure.ac       |   68 +++++++++++-----------
 doc/m4.texinfo     |   21 +++++++-
 m4/gnulib-cache.m4 |    5 +-
 src/builtin.c      |  159 ++++++++++++++++++++++++++++------------------------
 8 files changed, 200 insertions(+), 119 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a276ec1..cf9aa91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2009-03-12  Eric Blake  <address@hidden>
+
+       Fix awk script portability.
+       * checks/get-them: In gsub, properly escape {.  Close all files
+       before exiting.
+       Reported by Gary V. Vaughan.
+
+2009-03-05  Eric Blake  <address@hidden>
+
+       Allow configuration choice in syscmd shell.
+       * configure.ac (SYSCMD_SHELL): New test.
+       * src/builtin.c (m4_syscmd, m4_esyscmd): Use it to avoid
+       hard-coding the shell location.
+       * doc/m4.texinfo (Syscmd, Esyscmd): Document this.
+       * README: Document new configure option.
+       * NEWS: Likewise.
+
+       Remove cruft now that gnulib modules do the work.
+       * configure.ac (M4_cv_func_system_consistent): Delete.
+       * src/builtin.c (M4SYSVAL_EXITBITS, M4SYSVAL_TERMSIGBITS):
+       Delete.
+
+       Use gnulib pipe module instead of popen(3).
+       * m4/gnulib-cache.m4: Import pipe and wait-process modules.
+       * src/builtin.c (m4_esyscmd): Rewrite with pipe module.
+       Resolves a failure on AIX, reported by Gary V. Vaughan.
+
+       Use gnulib execute module instead of system(3).
+       * m4/gnulib-cache.m4: Import execute module.
+       * src/builtin.c (m4_sysval): Move computation...
+       (m4_esyscmd): ...into caller.
+       (m4_syscmd): Rewrite with execute module.
+       Resolves a failure on AIX, reported by Gary V. Vaughan.
+
 2009-03-03  Eric Blake  <address@hidden>
 
        Try to tolerate spaces in directory names in testsuite.
diff --git a/NEWS b/NEWS
index 22ea347..fa6832b 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,9 @@ Software Foundation, Inc.
    `m4 --debugfile=trace file', not `m4 file --debugfile trace'.  This
    change does not affect the deprecated `-o'/`--error-output' option.
 
+** The `syscmd' and `esyscmd' builtins can be configured to use an
+   alternate shell, via the new `configure' option `--with-syscmd-shell'.
+
 ** A number of portability improvements inherited from gnulib.
 
 * Noteworthy changes in Version 1.4.12 (2008-10-10) [stable]
diff --git a/README b/README
index 49275d2..2197a2c 100644
--- a/README
+++ b/README
@@ -44,6 +44,12 @@ See file `INSTALL' for compilation and installation 
instructions.
 See file `NEWS' for a list of major changes in the current release.
 See file `THANKS' for a list of contributors.
 
+By default, the `syscmd' and `esyscmd' macros try to use the first
+instance of `sh' found by `command -p getconf PATH' at configure time,
+with a default of `/bin/sh'.  If that default is inappropriate, you
+can use `./configure --with-syscmd-shell=location' to specify the
+shell to use.
+
 By using `./configure --enable-changeword', you get an experimental
 feature which allows for changing the syntax of what is a "word" in
 `m4'.  This feature will not be present in m4 2.0, but will be
@@ -57,8 +63,8 @@ solution, from which the problem might be uneasy to infer.
 
 ========================================================================
 
-Copyright (C) 2000, 2005, 2006, 2007, 2008 Free Software Foundation,
-Inc.
+Copyright (C) 2000, 2005, 2006, 2007, 2008, 2009 Free Software
+Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.2 or
diff --git a/checks/get-them b/checks/get-them
index 6e571f0..50735d3 100755
--- a/checks/get-them
+++ b/checks/get-them
@@ -1,8 +1,8 @@
 #!/bin/sh
 # -*- AWK -*-
 # Extract all examples from the manual source.
-# Copyright (C) 1992, 2005, 2006, 2007, 2008 Free Software Foundation,
-# Inc.
+# Copyright (C) 1992, 2005, 2006, 2007, 2008, 2009 Free Software
+# Foundation, Inc.
 #
 # This file is part of GNU M4.
 #
@@ -19,7 +19,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# This script is for use with GNU awk.
+# This script was designed under GNU awk, but hopefully portable to
+# other implementations.
 
 FILE=${1-/dev/null}
 : ${AWK=awk}
@@ -94,8 +95,8 @@ BEGIN {
     printf("dnl @ %s:%d: Origin of test\n"\
           "dnl @ expected status: %d\n"\
           "dnl @ extra options: %s\n"\
-          "dnl @ Copyright (C) 2006, 2007, 2008 Free Software Foundation,\n"\
-          "dnl @ Inc.\n"\
+          "dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software\n"\
+          "dnl @ Foundation, Inc.\n"\
           "dnl @ This file is free software; the Free Software Foundation\n"\
           "dnl @ gives unlimited permission to copy and/or distribute it\n"\
           "dnl @ with or without modifications, as long as this notice\n"\
@@ -122,14 +123,16 @@ BEGIN {
   else
     prefix = "";
   gsub("@@", "@", $0);
-  gsub("@{", "{", $0);
+  gsub("@[{]", "{", $0);
   gsub("@}", "}", $0);
-  gsub("@w{ }", " ", $0);
-  gsub("@tabchar{}", "\t", $0);
+  gsub("@w[{] }", " ", $0);
+  gsub("@tabchar[{]}", "\t", $0);
   printf("%s%s\n", prefix, $0) >> file;
 }
 
 END {
   printf("\n");
+  if (count > 0)
+    close(file);
 }
 ' $FILE
diff --git a/configure.ac b/configure.ac
index f728b52..e2595b5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 # Configure template for GNU M4.                       -*-Autoconf-*-
-# Copyright (C) 1991, 1993, 1994, 2004, 2005, 2006, 2007, 2008 Free
-# Software Foundation, Inc.
+# Copyright (C) 1991, 1993, 1994, 2004, 2005, 2006, 2007, 2008, 2009
+# Free Software Foundation, Inc.
 #
 # This file is part of GNU M4.
 #
@@ -49,38 +49,6 @@ fi
 
 M4_INIT
 
-AC_CACHE_CHECK([if system() agrees with pclose()],
-  [M4_cv_func_system_consistent],
-  [AC_RUN_IFELSE([AC_LANG_PROGRAM([
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-], [int i1, i2;
-  FILE *f;
-  i1 = system ("exit 2");
-  if (i1 == -1)
-    return 1;
-  f = popen ("exit 2", "r");
-  if (!f)
-    return 1;
-  i2 = pclose (f);
-  return i1 != i2;])],
-  [M4_cv_func_system_consistent=yes], [M4_cv_func_system_consistent=no],
-  [AC_COMPILE_IFELSE([
-/* EMX on OS/2 defines WEXITSTATUS to be (x>>8)&0xff, and uses that for
-   pclose(), but for system() it uses x&0xff instead.  Otherwise, we assume
-   your system is sane and that pclose() and system() are consistent in their
-   values.  If this heuristic is wrong for your platform, report it as a bug
-   to address@hidden  */
-#ifdef __EMX__
-choke me
-#endif
-], [M4_cv_func_system_consistent=yes], [M4_cv_func_system_consistent=no])])])
-if test "$M4_cv_func_system_consistent" = no ; then
-  AC_DEFINE([FUNC_SYSTEM_BROKEN], [1],
-    [Define to 1 if the return value of system() disagrees with pclose().])
-fi
-
 AC_CACHE_CHECK([whether an open file can be renamed],
   [M4_cv_func_rename_open_file_works],
   [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
@@ -115,6 +83,38 @@ AC_ARG_ENABLE([changeword],
     AC_MSG_RESULT([no])
   fi], [AC_MSG_RESULT([no])])
 
+AC_MSG_CHECKING([[which shell to use for syscmd]])
+AC_ARG_WITH([syscmd-shell],
+  [AS_HELP_STRING([--with-syscmd-shell], [shell used by syscmd [/bin/sh]])],
+  [case $withval in
+    yes[)] with_syscmd_shell=no;;
+   esac], [with_syscmd_shell=no])
+if test "$with_syscmd_shell" = no ; then
+  with_syscmd_shell=/bin/sh
+  if test "$cross_compiling" != yes ; then
+dnl Give mingw a default that is more likely to be available.
+    AS_IF([AS_EXECUTABLE_P([/bin/sh])], [],
+      [if (cmd /c) 2>/dev/null; then with_syscmd_shell=cmd; fi])
+dnl Too bad _AS_PATH_WALK is not public.
+    M4_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+    for M4_dir in `if (command -p getconf PATH) 2>/dev/null ; then
+       command -p getconf PATH
+      else
+       echo "/bin$PATH_SEPARATOR$PATH"
+      fi`
+    do
+      IFS=$M4_save_IFS
+      test -z "$M4_dir" && continue
+      AS_EXECUTABLE_P(["$M4_dir/sh"]) \
+       && { with_syscmd_shell=$M4_dir/sh; break; }
+    done
+    IFS=$M4_save_IFS
+  fi
+fi
+AC_MSG_RESULT([$with_syscmd_shell])
+AC_DEFINE_UNQUOTED([SYSCMD_SHELL], ["$with_syscmd_shell"],
+  [Shell used by syscmd and esyscmd, must accept -c argument.])
+
 M4_WITH_DMALLOC
 
 AC_CONFIG_COMMANDS([stamp-h], [[test -z "$CONFIG_HEADERS" || date > stamp-h]])
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index f07b9ae..3243b51 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -4552,7 +4552,8 @@ changecom(`/*', `*/')
 @quotation
 The macro @code{changeword} and all associated functionality is
 experimental.  It is only available if the @option{--enable-changeword}
-option was given to @code{configure}, at @acronym{GNU} @code{m4} installation
+option was given to @command{configure}, at @acronym{GNU} @code{m4}
+installation
 time.  The functionality will go away in the future, to be replaced by
 other new features that are more efficient at providing the same
 capabilities.  @emph{Do not rely on it}.  Please direct your comments
@@ -6477,6 +6478,15 @@ Prior to executing the command, @code{m4} flushes its 
buffers.
 The default standard input, output and error of @var{shell-command} are
 the same as those of @code{m4}.
 
+By default, the @var{shell-command} will be used as the argument to the
address@hidden option of the @command{/bin/sh} shell (or the version of
address@hidden specified by @samp{command -p getconf PATH}, if your system
+supports that).  If you prefer a different shell, the
address@hidden script can be given the option
address@hidden@var{location}} to set the location of an
+alternative shell at @acronym{GNU} @code{m4} installation; the
+alternative shell must still support @option{-c}.
+
 The macro @code{syscmd} is recognized only with parameters.
 @end deffn
 
@@ -6545,6 +6555,15 @@ the same as those of @code{m4}.  The error output of 
@var{shell-command}
 is not a part of the expansion: it will appear along with the error
 output of @code{m4}.
 
+By default, the @var{shell-command} will be used as the argument to the
address@hidden option of the @command{/bin/sh} shell (or the version of
address@hidden specified by @samp{command -p getconf PATH}, if your system
+supports that).  If you prefer a different shell, the
address@hidden script can be given the option
address@hidden@var{location}} to set the location of an
+alternative shell at @acronym{GNU} @code{m4} installation; the
+alternative shell must still support @option{-c}.
+
 The macro @code{esyscmd} is recognized only with parameters.
 @end deffn
 
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 4ed53d0..3c59620 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 --tests-base=tests 
--aux-dir=build-aux --with-tests --avoid=lock-tests --avoid=tls-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-1.3 fflush filenamecat fopen fopen-safer fseeko gendocs getopt 
git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 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 --avoid=lock-tests --avoid=tls-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 execute fdl-1.3 fflush filenamecat fopen fopen-safer fseeko gendocs 
getopt git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 mkstemp 
obstack pipe progname regex sigaction stdbool stdint stdlib-safer strsignal 
strstr strtod strtol unlocked-io verror version-etc version-etc-fsf 
wait-process xalloc xprintf xvasprintf-posix
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([local])
@@ -33,6 +33,7 @@ gl_MODULES([
   config-h
   dirname
   error
+  execute
   fdl-1.3
   fflush
   filenamecat
@@ -49,6 +50,7 @@ gl_MODULES([
   memchr2
   mkstemp
   obstack
+  pipe
   progname
   regex
   sigaction
@@ -63,6 +65,7 @@ gl_MODULES([
   verror
   version-etc
   version-etc-fsf
+  wait-process
   xalloc
   xprintf
   xvasprintf-posix
diff --git a/src/builtin.c b/src/builtin.c
index 6378fb7..05146df 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -24,14 +24,11 @@
 
 #include "m4.h"
 
-extern FILE *popen ();
-
+#include "execute.h"
 #include "memchr2.h"
+#include "pipe.h"
 #include "regex.h"
-
-#if HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
+#include "wait-process.h"
 
 #define ARG(i) (argc > (i) ? TOKEN_DATA_TEXT (argv[i]) : "")
 
@@ -940,42 +937,17 @@ builtin `%s' requested by frozen file is not supported", 
ARG (i)));
 | and "sysval".  "esyscmd" is GNU specific.                              |
 `------------------------------------------------------------------------*/
 
-/* Helper macros for readability.  */
-#if UNIX || defined WEXITSTATUS
-# define M4SYSVAL_EXITBITS(status)                       \
-   (WIFEXITED (status) ? WEXITSTATUS (status) : 0)
-# define M4SYSVAL_TERMSIGBITS(status)                    \
-   (WIFSIGNALED (status) ? WTERMSIG (status) << 8 : 0)
-
-#else /* ! UNIX && ! defined WEXITSTATUS */
-/* Platforms such as mingw do not support the notion of reporting
-   which signal terminated a process.  Furthermore if WEXITSTATUS was
-   not provided, then the exit value is in the low eight bits.  */
-# define M4SYSVAL_EXITBITS(status) status
-# define M4SYSVAL_TERMSIGBITS(status) 0
-#endif /* ! UNIX && ! defined WEXITSTATUS */
-
-/* Fallback definitions if <stdlib.h> or <sys/wait.h> are inadequate.  */
-#ifndef WEXITSTATUS
-# define WEXITSTATUS(status) (((status) >> 8) & 0xff)
-#endif
-#ifndef WTERMSIG
-# define WTERMSIG(status) ((status) & 0x7f)
-#endif
-#ifndef WIFSIGNALED
-# define WIFSIGNALED(status) (WTERMSIG (status) != 0)
-#endif
-#ifndef WIFEXITED
-# define WIFEXITED(status) (WTERMSIG (status) == 0)
-#endif
-
 /* Exit code from last "syscmd" command.  */
 static int sysval;
 
 static void
 m4_syscmd (struct obstack *obs, int argc, token_data **argv)
 {
-  if (bad_argc (argv[0], argc, 2, 2))
+  const char *cmd = ARG (1);
+  int status;
+  int sig_status;
+  const char *prog_args[4] = { "sh", "-c" };
+  if (bad_argc (argv[0], argc, 2, 2) || !*cmd)
     {
       /* The empty command is successful.  */
       sysval = 0;
@@ -983,25 +955,42 @@ m4_syscmd (struct obstack *obs, int argc, token_data 
**argv)
     }
 
   debug_flush_files ();
-  sysval = system (ARG (1));
-#if FUNC_SYSTEM_BROKEN
-  /* OS/2 has a buggy system() that returns exit status in the lowest eight
-     bits, although pclose() and WEXITSTATUS are defined to return exit
-     status in the next eight bits.  This approach can't detect signals, but
-     at least syscmd(`ls') still works when stdout is a terminal.  An
-     alternate approach is popen/insert_file/pclose, but that makes stdout
-     a pipe, which can change how some child processes behave.  */
-  if (sysval != -1)
-    sysval <<= 8;
-#endif /* FUNC_SYSTEM_BROKEN */
+#if W32_NATIVE
+  if (strstr (SYSCMD_SHELL, "cmd"))
+    {
+      prog_args[0] = "cmd";
+      prog_args[1] = "/c";
+    }
+#endif
+  prog_args[2] = cmd;
+  errno = 0;
+  status = execute (ARG (0), SYSCMD_SHELL, (char **) prog_args, false,
+                   false, false, false, true, false, &sig_status);
+  if (sig_status)
+    {
+      assert (status == 127);
+      sysval = sig_status << 8;
+    }
+  else
+    {
+      if (status == 127 && errno)
+       M4ERROR ((warning_status, errno, "cannot run command `%s'", cmd));
+      sysval = status;
+    }
 }
 
 static void
 m4_esyscmd (struct obstack *obs, int argc, token_data **argv)
 {
+  const char *cmd = ARG (1);
+  const char *prog_args[4] = { "sh", "-c" };
+  pid_t child;
+  int fd;
   FILE *pin;
+  int status;
+  int sig_status;
 
-  if (bad_argc (argv[0], argc, 2, 2))
+  if (bad_argc (argv[0], argc, 2, 2) || !*cmd)
     {
       /* The empty command is successful.  */
       sysval = 0;
@@ -1009,45 +998,69 @@ m4_esyscmd (struct obstack *obs, int argc, token_data 
**argv)
     }
 
   debug_flush_files ();
+#if W32_NATIVE
+  if (strstr (SYSCMD_SHELL, "cmd"))
+    {
+      prog_args[0] = "cmd";
+      prog_args[1] = "/c";
+    }
+#endif
+  prog_args[2] = cmd;
   errno = 0;
-  pin = popen (ARG (1), "r");
+  child = create_pipe_in (ARG (0), SYSCMD_SHELL, (char **) prog_args,
+                         NULL, false, true, false, &fd);
+  if (child == -1)
+    {
+      M4ERROR ((warning_status, errno, "cannot run command `%s'", cmd));
+      sysval = 127;
+      return;
+    }
+  pin = fdopen (fd, "r");
   if (pin == NULL)
     {
-      M4ERROR ((warning_status, errno,
-               "cannot open pipe to command `%s'", ARG (1)));
-      sysval = -1;
+      M4ERROR ((warning_status, errno, "cannot run command `%s'", cmd));
+      sysval = 127;
+      close (fd);
+      return;
     }
-  else
+  while (1)
     {
-      while (1)
+      size_t avail = obstack_room (obs);
+      size_t len;
+      if (!avail)
        {
-         size_t avail = obstack_room (obs);
-         size_t len;
-         if (!avail)
-           {
-             int ch = getc (pin);
-             if (ch == EOF)
-               break;
-             obstack_1grow (obs, ch);
-             continue;
-           }
-         len = fread (obstack_next_free (obs), 1, avail, pin);
-         if (len <= 0)
+         int ch = getc (pin);
+         if (ch == EOF)
            break;
-         obstack_blank_fast (obs, len);
+         obstack_1grow (obs, ch);
+         continue;
        }
-      if (ferror (pin))
-       M4ERROR ((EXIT_FAILURE, errno, "cannot read pipe"));
-      sysval = pclose (pin);
+      len = fread (obstack_next_free (obs), 1, avail, pin);
+      if (len <= 0)
+       break;
+      obstack_blank_fast (obs, len);
+    }
+  if (ferror (pin) || fclose (pin))
+    M4ERROR ((EXIT_FAILURE, errno, "cannot read pipe"));
+  status = wait_subprocess (child, ARG (0), false, false, true, false,
+                           &sig_status);
+  if (sig_status)
+    {
+      assert (status == 127);
+      sysval = sig_status << 8;
+    }
+  else
+    {
+      if (status == 127 && errno)
+       M4ERROR ((warning_status, errno, "cannot run command `%s'", cmd));
+      sysval = status;
     }
 }
 
 static void
 m4_sysval (struct obstack *obs, int argc, token_data **argv)
 {
-  shipout_int (obs, (sysval == -1 ? 127
-                    : (M4SYSVAL_EXITBITS (sysval)
-                       | M4SYSVAL_TERMSIGBITS (sysval))));
+  shipout_int (obs, sysval);
 }
 
 /*-------------------------------------------------------------------------.


hooks/post-receive
--
GNU M4 source repository




reply via email to

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