# HG changeset patch # User John W. Eaton # Date 1382930025 14400 # Node ID 8b353af4a1ca4757efb9807b1db2fdbcc665e94a # Parent 9244d2a908fdd3e61e3f8fdba1d7fa8649caf5b9 allow octave main program to work on Windows systems * main.in.cc: Simply exec octave-gui or octave-cli on Windows systems. diff -r 9244d2a908fd -r 8b353af4a1ca src/main.in.cc --- a/src/main.in.cc Sun Oct 27 22:06:37 2013 -0400 +++ b/src/main.in.cc Sun Oct 27 23:13:45 2013 -0400 @@ -39,19 +39,18 @@ #include #include -#include -#include -#include -#include +// From gnulib, so OK for Windows too. #include -#ifndef OCTAVE_BINDIR -#define OCTAVE_BINDIR %OCTAVE_BINDIR% -#endif +#if ! defined (__WIN32__) && ! defined (__CYGWIN__) -#ifndef OCTAVE_PREFIX -#define OCTAVE_PREFIX %OCTAVE_PREFIX% -#endif +#include +#include +#include + +// This is a liboctave header, but it doesn't include any other Octave +// headers or declare any functions that are defined in liboctave. +#include "syswait.h" typedef void sig_handler (int); @@ -230,6 +229,16 @@ return retval; } +#endif + +#ifndef OCTAVE_BINDIR +#define OCTAVE_BINDIR %OCTAVE_BINDIR% +#endif + +#ifndef OCTAVE_PREFIX +#define OCTAVE_PREFIX %OCTAVE_PREFIX% +#endif + // Find the directory where the octave binary is supposed to be // installed. @@ -324,12 +333,6 @@ bool start_gui = true; bool cli_only = false; -#if defined (__WIN32__) || defined (__CYGWIN__) - bool no_fork_required = true; -#else - bool no_fork_required = false; -#endif - std::string octave_bindir = get_octave_bindir (); std::string file = octave_bindir + dir_sep_char + "octave-gui"; @@ -369,8 +372,13 @@ new_argv[k] = 0; - if (cli_only || no_fork_required - || (! start_gui && ! have_controlling_terminal ())) +#if defined (__WIN32__) || defined (__CYGWIN__) + + retval = octave_exec (file, new_argv); + +#else + + if (cli_only || (! start_gui && ! have_controlling_terminal ())) { retval = octave_exec (file, new_argv); } @@ -408,7 +416,7 @@ while (1) { - waitpid (gui_pid, &status, 0); + WAITPID (gui_pid, &status, 0); if (WIFEXITED (status)) { @@ -420,6 +428,8 @@ } } +#endif + return retval; }