# HG changeset patch # User John W. Eaton # Date 1383200747 14400 # Node ID 0a887758d1ccaf78fd32ca4670fb7ac937955ac6 # Parent fffd0c0ca2dc99d8ebc0ecb43b923104522b4dc7 fix compilation of main.cc on Windows * main.in.cc: Do use ifdefs. We can't compile some of this code on Windows systems. Correct test for Cygwin. diff -r fffd0c0ca2dc -r 0a887758d1cc src/main.in.cc --- a/src/main.in.cc Wed Oct 30 21:55:14 2013 -0700 +++ b/src/main.in.cc Thu Oct 31 02:25:47 2013 -0400 @@ -39,14 +39,8 @@ #include #include -// From gnulib, so OK for Windows too. #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" #if defined (__WIN32__) && ! defined (_POSIX_VERSION) @@ -108,9 +102,14 @@ #endif -#if ! defined (__WIN32__) && ! defined (__CYGWIN__) +#if ! defined (__WIN32__) || defined (__CYGWIN__) #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); @@ -141,12 +140,9 @@ return oact.sa_handler; } -#endif - static void install_signal_handlers (void) { -#if ! defined (__WIN32__) && ! defined (__CYGWIN__) #ifdef SIGINT octave_set_signal_handler (SIGINT, gui_driver_sig_handler); @@ -263,17 +259,13 @@ octave_set_signal_handler (SIGXFSZ, gui_driver_sig_handler); #endif -#endif } - static bool have_controlling_terminal (void) { int retval = false; -#if ! defined (__WIN32__) && ! defined (__CYGWIN__) - #if defined (HAVE_CTERMID) const char *ctty = ctermid (0); #else @@ -289,11 +281,11 @@ retval = true; } -#endif - return retval; } +#endif + #ifndef OCTAVE_BINDIR #define OCTAVE_BINDIR %OCTAVE_BINDIR% #endif @@ -398,18 +390,15 @@ { int retval = 0; -#if defined (HAVE_OCTAVE_GUI) +#if (defined (HAVE_OCTAVE_GUI) \ + && (! defined (__WIN32__) || defined (__CYGWIN__))) bool start_gui = true; bool gui_libs = true; -#else - bool start_gui = false; - bool gui_libs = false; #endif std::string octave_bindir = get_octave_bindir (); - std::string file = octave_bindir + dir_sep_char - + (gui_libs ? "octave-gui" : "octave-cli"); + std::string file = octave_bindir + dir_sep_char + "octave-gui"; char **new_argv = new char * [argc + 1]; @@ -426,7 +415,9 @@ // require less memory. Don't pass the --no-gui-libs option // on as that option is not recognized by Octave. +#if ! defined (__WIN32__) || defined (__CYGWIN__) gui_libs = false; +#endif file = octave_bindir + dir_sep_char + "octave-cli"; } else if (! strcmp (argv[i], "--no-gui")) @@ -437,7 +428,9 @@ // if the --no-gui option is given, we may be asked to do some // plotting or ui* calls. +#if ! defined (__WIN32__) || defined (__CYGWIN__) start_gui = false; +#endif new_argv[k++] = argv[i]; } else @@ -446,6 +439,8 @@ new_argv[k] = 0; +#if ! defined (__WIN32__) || defined (__CYGWIN__) + if (gui_libs && start_gui && have_controlling_terminal ()) { install_signal_handlers (); @@ -494,6 +489,12 @@ else retval = octave_exec (file, new_argv); +#else + + retval = octave_exec (file, new_argv); + +#endif + return retval; }