comparison src/mkoctfile.in.cc @ 18916:5999e654f256 stable

WIFEXITED and WEXITSTATUS macros for mkoctfile.cc * mkoctfile.in.cc (WIFEXITED, WEXITSTATUS): Define for systems that don't have these macros.
author John W. Eaton <jwe@octave.org>
date Fri, 27 Jun 2014 17:09:28 -0400
parents 3e4e2cfba186
children c4def7ab39e7
comparison
equal deleted inserted replaced
18915:3e4e2cfba186 18916:5999e654f256
34 #include <fstream> 34 #include <fstream>
35 #include <vector> 35 #include <vector>
36 #include <cstdlib> 36 #include <cstdlib>
37 37
38 #include <unistd.h> 38 #include <unistd.h>
39
40 // This mess suggested by the autoconf manual.
41
42 #include <sys/types.h>
43
44 #if defined HAVE_SYS_WAIT_H
45 #include <sys/wait.h>
46 #endif
47
48 #ifndef WIFEXITED
49 #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
50 #endif
51
52 #ifndef WEXITSTATUS
53 #define WEXITSTATUS(stat_val) (static_cast<unsigned> (stat_val) >> 8)
54 #endif
39 55
40 static std::map<std::string, std::string> vars; 56 static std::map<std::string, std::string> vars;
41 57
42 #ifndef OCTAVE_VERSION 58 #ifndef OCTAVE_VERSION
43 #define OCTAVE_VERSION %OCTAVE_CONF_VERSION% 59 #define OCTAVE_VERSION %OCTAVE_CONF_VERSION%
342 static int 358 static int
343 run_command (const std::string& cmd) 359 run_command (const std::string& cmd)
344 { 360 {
345 if (debug) 361 if (debug)
346 std::cout << cmd << std::endl; 362 std::cout << cmd << std::endl;
347 return system (cmd.c_str ()); 363
364 int result = system (cmd.c_str ());
365
366 if (WIFEXITED (result))
367 result = WEXITSTATUS (result);
368
369 return result;
348 } 370 }
349 371
350 bool 372 bool
351 is_true (const std::string& s) 373 is_true (const std::string& s)
352 { 374 {