Skip to content

Commit 0a3035e

Browse files
author
broeker
committed
Use <sys/wait.h> if available.
Provide centralized fall-back of WEXITSTATUS if <sys/wait.h> does not supply it.
1 parent 1455f97 commit 0a3035e

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

ChangeLog

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2017-10-06 Hans-Bernhard Broeker <[email protected]>
2+
3+
* src/command.c: Move WEXITSTATUS fall-back definition away from here.
4+
5+
* src/syscfg.h: Include <sys/wait.h>, if it exists.
6+
(WEXITSTATUS): Provide fall-back definition, if none in
7+
<sys/wait.h>. Move MS Windows specific replacement from command.c
8+
to here.
9+
10+
* configure.ac: Add call to AC_HEADER_SYS_WAIT
11+
112
2017-10-06 Bastian Maerkisch <[email protected]>
213

314
* config/mingw/Makefile: Add helpfiles to "all" target, including
@@ -38,8 +49,8 @@
3849

3950
2017-09-29 Ethan A Merritt <[email protected]>
4051

41-
* src/axis.h src/axis.c (axis_set_scale_and_range): Incorrect use
42-
of unsigned parameters caused terminal scaling to fail if the axis
52+
* src/axis.h src/axis.c (axis_set_scale_and_range): Incorrect use
53+
of unsigned parameters caused terminal scaling to fail if the axis
4354
range was inverted. The error was introduced by converting from a
4455
macro to a subroutine in the run-up to 5.2.
4556

configure.ac

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dnl Process this file with autoconf to produce a configure script.
22
dnl configure.in for gnuplot on Unix.
33
dnl
4-
dnl $Id: configure.ac,v 1.39 2017-09-04 23:25:00 sfeam Exp $
4+
dnl $Id: configure.ac,v 1.40 2017-10-06 18:35:09 broeker Exp $
55
dnl
66
dnl this is actually major.minor ...
77
dnl note that for a non-beta release, we need to disable DEVELOPMENT_RELEASE
@@ -228,6 +228,8 @@ if test "$ac_cv_header_sys_stat_h" = yes; then
228228
AC_HEADER_STAT
229229
fi
230230

231+
AC_HEADER_SYS_WAIT
232+
231233
dnl Check for external functions plugin infrastructure
232234
AC_ARG_ENABLE(plugins,dnl
233235
[ --disable-plugins disable support for importing external functions],,)

src/command.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef lint
2-
static char *RCSid() { return RCSid("$Id: command.c,v 1.364 2017-10-01 09:01:57 markisch Exp $"); }
2+
static char *RCSid() { return RCSid("$Id: command.c,v 1.365 2017-10-06 18:35:09 broeker Exp $"); }
33
#endif
44

55
/* GNUPLOT - command.c */
@@ -3621,10 +3621,6 @@ do_system_func(const char *cmd, char **output)
36213621

36223622
}
36233623

3624-
#if defined(_WIN32) && !defined(WEXITSTATUS)
3625-
#define WEXITSTATUS(error) (error)
3626-
#endif
3627-
36283624
static int
36293625
report_error(int ierr)
36303626
{

src/syscfg.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Id: syscfg.h,v 1.65 2017-07-29 08:35:44 markisch Exp $
2+
* $Id: syscfg.h,v 1.66 2017-10-06 18:35:09 broeker Exp $
33
*/
44

55
/* GNUPLOT - syscfg.h */
@@ -257,11 +257,23 @@ FILE * win_popen(const char *filename, const char *mode);
257257
#define GPHUGE /* nothing */
258258
#define GPFAR /* nothing */
259259

260+
#if defined(HAVE_SYS_TYPES_H)
261+
# include <sys/types.h>
262+
# if defined(HAVE_SYS_WAIT_H)
263+
# include <sys/wait.h>
264+
# endif
265+
#endif
266+
267+
#if !defined(WEXITSTATUS)
268+
# if defined(_WIN32)
269+
# define WEXITSTATUS(stat_val) (stat_val)
270+
# else
271+
# define WEXITSTATUS(stat_val) ((unsigned int)(stat_val) >> 8)
272+
# endif
273+
#endif
274+
260275
/* LFS support */
261276
#if !defined(HAVE_FSEEKO) || !defined(HAVE_OFF_T)
262-
# if defined(HAVE_SYS_TYPES_H)
263-
# include <sys/types.h>
264-
# endif
265277
# if defined(_MSC_VER)
266278
# define off_t __int64
267279
# elif defined(__MINGW32__)

0 commit comments

Comments
 (0)