Hi,
When compiling m4-1.4o on BeOS, I encountered the following problem:
The sysval.1 test failed. More precisely, after running syscmd(`false'),
the variable 'sysval' contains 1 (whereas it contains 256 on Linux).
Now look at the WEXITSTATUS macros:
on BeOS: #define WEXITSTATUS(val) ((val) & 0xff)
on Linux: #define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
#define WEXITSTATUS(status) __WEXITSTATUS(__WAIT_INT(status))
My fix is as follows.
2000-04-17 Bruno Haible <[EMAIL PROTECTED]>
* src/builtin.c (m4_sysval): Use WEXITSTATUS macro if the system
defines it.
(m4_esyscmd): Set sysval to 0xffff, to accomodate both big-endian
and little-endian wait status definitions.
diff -r -c3 m4-1.4o.orig/src/builtin.c m4-1.4o/src/builtin.c
*** m4-1.4o.orig/src/builtin.c Mon Jan 10 05:05:05 2000
--- m4-1.4o/src/builtin.c Mon Apr 17 11:02:48 2000
***************
*** 881,886 ****
--- 881,890 ----
/* Exit code from last "syscmd" command. */
static int sysval;
+ #ifndef WEXITSTATUS
+ #define WEXITSTATUS(status) (((status) >> 8) & 0xff)
+ #endif
+
static void
m4_syscmd (struct obstack *obs, int argc, token_data **argv)
{
***************
*** 906,912 ****
{
M4ERROR ((warning_status, errno,
_("Cannot open pipe to command `%s'"), ARG (1)));
! sysval = 0xff << 8;
}
else
{
--- 910,916 ----
{
M4ERROR ((warning_status, errno,
_("Cannot open pipe to command `%s'"), ARG (1)));
! sysval = 0xffff;
}
else
{
***************
*** 919,925 ****
static void
m4_sysval (struct obstack *obs, int argc, token_data **argv)
{
! shipout_int (obs, (sysval >> 8) & 0xff);
}
/*-------------------------------------------------------------------------.
--- 923,929 ----
static void
m4_sysval (struct obstack *obs, int argc, token_data **argv)
{
! shipout_int (obs, WEXITSTATUS (sysval));
}
/*-------------------------------------------------------------------------.