bug-m4
[Top][All Lists]
Advanced

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

portability to BeOS


From: Bruno Haible
Subject: portability to BeOS
Date: Tue, 2 May 2006 16:26:09 +0200
User-agent: KMail/1.5

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))

Here is the fix, ported to the current m4 CVS.


2006-04-30  Bruno Haible  <address@hidden>

        * modules/m4.c (WEXITSTATUS): Provide fallback definition.
        (sysval): Use WEXITSTATUS.
        * modules/gnu.c (esyscmd): Set sysval to 0xffff, to accomodate both
        big-endian and little-endian wait status definitions.

*** modules/m4.c        2005-08-25 22:15:36.000000000 +0200
--- modules/m4.c.new    2006-04-30 00:19:37.000000000 +0200
***************
*** 426,431 ****
--- 426,435 ----
  /* Exit code from last "syscmd" command.  */
  int  m4_sysval = 0;
  
+ #ifndef WEXITSTATUS
+ # define WEXITSTATUS(status) (((status) >> 8) & 0xff)
+ #endif
+ 
  void
  m4_set_sysval (int value)
  {
***************
*** 451,457 ****
  
  M4BUILTIN_HANDLER (sysval)
  {
!   m4_shipout_int (obs, (m4_sysval >> 8) & 0xff);
  }
  
  
--- 455,461 ----
  
  M4BUILTIN_HANDLER (sysval)
  {
!   m4_shipout_int (obs, WEXITSTATUS (m4_sysval));
  }
  
  
*** modules/gnu.c       2005-08-25 22:15:36.000000000 +0200
--- modules/gnu.c.new   2006-04-30 00:18:34.000000000 +0200
***************
*** 1,6 ****
  /* GNU m4 -- A simple macro processor
  
!   Copyright (C) 2000, 2004, 2005 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
--- 1,6 ----
  /* GNU m4 -- A simple macro processor
  
!   Copyright (C) 2000, 2004-2006 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
***************
*** 557,563 ****
        {
          M4ERROR ((m4_get_warning_status_opt (context), errno,
                    _("Cannot open pipe to command `%s'"), M4ARG (1)));
!         m4_set_sysval (0xff << 8);
        }
        else
        {
--- 557,563 ----
        {
          M4ERROR ((m4_get_warning_status_opt (context), errno,
                    _("Cannot open pipe to command `%s'"), M4ARG (1)));
!         m4_set_sysval (0xffff);
        }
        else
        {





reply via email to

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