m4-patches
[Top][All Lists]
Advanced

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

Re: branch-1_4 - platform recognition macro


From: Eric Blake
Subject: Re: branch-1_4 - platform recognition macro
Date: Thu, 06 Jul 2006 20:39:05 -0600
User-agent: Thunderbird 1.5.0.4 (Windows/20060516)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Andreas Büning on 7/4/2006 12:58 PM:
> Eric Blake wrote:
> 
>> The alternative patch is to still use system(), but shift
>> the value left by 8 if it is not -1; but we then lose the ability to
>> detect signals.
> 
> I'd prefer this one because it's just simpler.

With that recommendation, I'm checking in the following.  Could you please
do a fresh CVS checkout and see if you can run the testsuite now?  One
thing I still wonder about is your platform recognition macro, and the
testsuite does have a test to ensure that exactly one such macro is
defined.  Since we can't detect signals to syscmd, we should not be
defining __unix__ on OS/2 (does your compiler even pre-define __unix__, or
is it just __EMX__?).  But my understanding is that OS/2 does not really
qualify as __windows__, so should I add a third platform macro, __emx__?

2006-07-06  Eric Blake  <address@hidden>

        * configure.ac (FUNC_SYSTEM_BROKEN): New check for OS/2 bug.
        * src/builtin.c (m4_syscmd): Work around OS/2 bug.

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFErclI84KuGfSFAYARAtuoAKCWsYFjB5wEjWs7m+OksbeV+mda5wCglPau
6sAV1SOgbBHdXFjvJXvGQFU=
=Y5ow
-----END PGP SIGNATURE-----
Index: configure.ac
===================================================================
RCS file: /sources/m4/m4/configure.ac,v
retrieving revision 1.36.2.20
diff -u -p -r1.36.2.20 configure.ac
--- configure.ac        30 Jun 2006 18:58:11 -0000      1.36.2.20
+++ configure.ac        7 Jul 2006 02:38:23 -0000
@@ -91,6 +91,38 @@ if test "$M4_cv_use_stackovf" = yes; the
   ]])
 fi
 
+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
+
 dnl Don't let changeword get in our way, if bootstrapping with a version of
 dnl m4 that already turned the feature on.
 m4_ifdef([changeword], [m4_undefine([changeword])])dnl
Index: src/builtin.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/builtin.c,v
retrieving revision 1.1.1.1.2.16
diff -u -p -r1.1.1.1.2.16 builtin.c
--- src/builtin.c       30 Jun 2006 18:58:11 -0000      1.1.1.1.2.16
+++ src/builtin.c       7 Jul 2006 02:38:23 -0000
@@ -813,6 +813,16 @@ m4_syscmd (struct obstack *obs, int argc
 
   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 */
 }
 
 static void

reply via email to

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