changeset 21979:d04da18a407a

use OCTAVE_USE_WINDOWS_API more consistently * octave-gui.cc, thread-manager.cc, welcome-wizard.cc, ft-text-renderer.cc, sighandlers.cc, sighandlers.h, sysdep.cc, sysdep.h, toplev.cc, ov-java.cc, lo-sysdep.cc, kpse.cc, oct-mutex.cc, oct-conf-post.in.h, main.in.cc, mkoctfile.in.cc, shared-fcns.h: Prefer OCTAVE_USE_WINDOWS_API where possible.
author John W. Eaton <jwe@octave.org>
date Sun, 26 Jun 2016 03:50:20 -0400
parents b9c14f756009
children 19cfad4e4112
files libgui/src/octave-gui.cc libgui/src/thread-manager.cc libgui/src/welcome-wizard.cc libinterp/corefcn/ft-text-renderer.cc libinterp/corefcn/sighandlers.cc libinterp/corefcn/sighandlers.h libinterp/corefcn/sysdep.cc libinterp/corefcn/sysdep.h libinterp/corefcn/toplev.cc libinterp/octave-value/ov-java.cc liboctave/system/lo-sysdep.cc liboctave/util/kpse.cc liboctave/util/oct-mutex.cc oct-conf-post.in.h src/main.in.cc src/mkoctfile.in.cc src/shared-fcns.h
diffstat 17 files changed, 44 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/octave-gui.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/libgui/src/octave-gui.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -157,7 +157,7 @@
 
       // We provide specific terminal capabilities, so ensure that TERM is
       // always set appropriately
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
       octave::sys::env::putenv ("TERM", "cygwin");
 #else
       octave::sys::env::putenv ("TERM", "xterm");
--- a/libgui/src/thread-manager.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/libgui/src/thread-manager.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -24,7 +24,7 @@
 #  include "config.h"
 #endif
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
 #  include <windows.h>
 #else
 #  include <pthread.h>
@@ -34,7 +34,7 @@
 
 #include "thread-manager.h"
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
 
 class windows_thread_manager : public octave_base_thread_manager
 {
@@ -115,7 +115,7 @@
 octave_base_thread_manager *
 octave_thread_manager::create_rep (void)
 {
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
   return new windows_thread_manager ();
 #else
   return new pthread_thread_manager ();
--- a/libgui/src/welcome-wizard.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/libgui/src/welcome-wizard.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -30,7 +30,7 @@
 #include <QHBoxLayout>
 #include <QVBoxLayout>
 
-#if defined (__WIN32__)
+#if defined (OCTAVE_USE_WINDOWS_API)
   #define WIN32_LEAN_AND_MEAN
   #include <windows.h>
 #endif
@@ -289,7 +289,7 @@
 
   show_page ();
 
-#if defined (__WIN32__)
+#if defined (OCTAVE_USE_WINDOWS_API)
   // HACK to forceshow of dialog if started minimized
   ShowWindow((HWND)winId(), SW_SHOWNORMAL);
 #endif
--- a/libinterp/corefcn/ft-text-renderer.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/libinterp/corefcn/ft-text-renderer.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -261,7 +261,7 @@
 
     if (file.empty ())
       {
-#if defined (__WIN32__)
+#if defined (OCTAVE_USE_WINDOWS_API)
         file = "C:/WINDOWS/Fonts/verdana.ttf";
 #else
         // FIXME: find a "standard" font for UNIX platforms
--- a/libinterp/corefcn/sighandlers.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/libinterp/corefcn/sighandlers.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -75,7 +75,7 @@
 // Forward declaration.
 static void user_abort (const char *sig_name, int sig_number);
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -418,7 +418,7 @@
           if (octave_interrupt_state == 0)
             octave_interrupt_state = 1;
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
           w32_interrupt_manager::octave_jump_to_enclosing_context ();
 #else
           octave_jump_to_enclosing_context ();
@@ -450,7 +450,7 @@
 static void
 sigint_handler (int sig)
 {
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
   w32_interrupt_manager::user_abort (octave_strsignal_wrapper (sig), sig);
 #else
   user_abort (octave_strsignal_wrapper (sig), sig);
@@ -475,7 +475,7 @@
 {
   octave_interrupt_handler retval;
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
   w32_interrupt_manager::init ();
 #endif
 
@@ -490,7 +490,7 @@
 {
   octave_interrupt_handler retval;
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
   w32_interrupt_manager::init ();
 #endif
 
@@ -506,7 +506,7 @@
 {
   octave_interrupt_handler retval;
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
   w32_interrupt_manager::init ();
 #endif
 
--- a/libinterp/corefcn/sighandlers.h	Sat Jun 25 19:45:34 2016 -0400
+++ b/libinterp/corefcn/sighandlers.h	Sun Jun 26 03:50:20 2016 -0400
@@ -75,7 +75,7 @@
 octave_set_interrupt_handler (const volatile octave_interrupt_handler&,
                               bool restart_syscalls = true);
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
 extern OCTINTERP_API void w32_raise_sigint (void);
 #endif
 
--- a/libinterp/corefcn/sysdep.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/libinterp/corefcn/sysdep.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -106,7 +106,7 @@
 }
 #endif
 
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+#if defined (OCTAVE_USE_WINDOWS_API)
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -203,7 +203,7 @@
 
   octave_value retval;
 
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+#if defined (OCTAVE_USE_WINDOWS_API)
   HINSTANCE status = ShellExecute (0, 0, file.c_str (), 0, 0,
                                    SW_SHOWNORMAL);
 
@@ -562,7 +562,7 @@
 std::string
 get_P_tmpdir (void)
 {
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+#if defined (OCTAVE_USE_WINDOWS_API)
 
   std::string retval;
 
--- a/libinterp/corefcn/sysdep.h	Sat Jun 25 19:45:34 2016 -0400
+++ b/libinterp/corefcn/sysdep.h	Sun Jun 26 03:50:20 2016 -0400
@@ -47,7 +47,7 @@
 
 extern void w32_set_quiet_shutdown (void);
 
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+#if defined (OCTAVE_USE_WINDOWS_API)
 extern void MINGW_signal_cleanup (void);
 #  define MINGW_SIGNAL_CLEANUP() MINGW_signal_cleanup ()
 #else
--- a/libinterp/corefcn/toplev.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/libinterp/corefcn/toplev.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -35,7 +35,7 @@
 #include <sstream>
 #include <string>
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
 #  define WIN32_LEAN_AND_MEAN 1
 #  include <windows.h>
 #endif
@@ -1142,7 +1142,7 @@
 
   std::string cmd_str = args(0).xstring_value ("system: first argument must be a string");
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
   // Work around weird double-quote handling on Windows systems.
   if (type == et_sync)
     cmd_str = "\"" + cmd_str + "\"";
@@ -1166,7 +1166,7 @@
         }
       else
         retval(0) = pid;
-#elif defined (__WIN32__)
+#elif defined (OCTAVE_USE_WINDOWS_API)
       STARTUPINFO si;
       PROCESS_INFORMATION pi;
       ZeroMemory (&si, sizeof (si));
@@ -1629,7 +1629,7 @@
       bool mac_system = false;
       bool windows_system = false;
 
-#if defined (WIN32)
+#if defined (__WIN32__)
       windows_system = true;
 #if ! defined (__CYGWIN__)
       unix_system = false;
--- a/libinterp/octave-value/ov-java.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/libinterp/octave-value/ov-java.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -276,7 +276,7 @@
   std::list<std::string> java_opts;
 };
 
-#if defined (__WIN32__)
+#if defined (OCTAVE_USE_WINDOWS_API)
 
 static std::string
 read_registry_string (const std::string& key, const std::string& value)
@@ -515,7 +515,7 @@
   const char *static_locale = setlocale (LC_ALL, 0);
   const std::string locale (static_locale);
 
-#if defined (__WIN32__)
+#if defined (OCTAVE_USE_WINDOWS_API)
 
   HMODULE hMod = GetModuleHandle ("jvm.dll");
   std::string jvm_lib_path;
@@ -595,7 +595,7 @@
     error ("unable to load Java Runtime Environment from %s",
            jvm_lib_path.c_str ());
 
-#if defined (__WIN32__)
+#if defined (OCTAVE_USE_WINDOWS_API)
 
   set_dll_directory ();
 
--- a/liboctave/system/lo-sysdep.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/liboctave/system/lo-sysdep.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -60,7 +60,7 @@
     {
       std::string path = octave::sys::file_ops::tilde_expand (path_arg);
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
       if (path.length () == 2 && path[1] == ':')
         path += "\\";
 #endif
--- a/liboctave/util/kpse.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/liboctave/util/kpse.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -49,7 +49,7 @@
 #include "pathsearch.h"
 #include "unistd-wrappers.h"
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
 #  define WIN32_LEAN_AND_MEAN 1
 #  include <windows.h>
 #endif
@@ -166,7 +166,7 @@
    regular file, as it is potentially useful to read fifo's or some
    kinds of devices.  */
 
-#if defined (__WIN32__)
+#if defined (OCTAVE_USE_WINDOWS_API)
 static inline bool
 READABLE (const std::string& fn)
 {
--- a/liboctave/util/oct-mutex.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/liboctave/util/oct-mutex.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -27,7 +27,7 @@
 #include "oct-mutex.h"
 #include "lo-error.h"
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
 #  include <windows.h>
 #elif defined (HAVE_PTHREAD_H)
 #  include <pthread.h>
@@ -53,7 +53,7 @@
   return false;
 }
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
 
 class
 octave_w32_mutex : public octave_base_mutex
@@ -163,7 +163,7 @@
 static octave_base_mutex *
 init_rep (void)
 {
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
   return new octave_w32_mutex ();
 #elif defined (HAVE_PTHREAD_H)
   return new octave_pthread_mutex ();
--- a/oct-conf-post.in.h	Sat Jun 25 19:45:34 2016 -0400
+++ b/oct-conf-post.in.h	Sun Jun 26 03:50:20 2016 -0400
@@ -80,7 +80,12 @@
 #  pragma warning (disable: 4661)
 #endif
 
+/* Define to 1 if we expect to have <windows.h>, Sleep, etc. */
 #if defined (__WIN32__) && ! defined (__CYGWIN__)
+#  define OCTAVE_USE_WINDOWS_API 1
+#endif
+
+#if defined (OCTAVE_USE_WINDOWS_API)
 #  define OCTAVE_HAVE_WINDOWS_FILESYSTEM 1
 #elif defined (__CYGWIN__)
 #  define OCTAVE_HAVE_WINDOWS_FILESYSTEM 1
@@ -89,11 +94,6 @@
 #  define OCTAVE_HAVE_POSIX_FILESYSTEM 1
 #endif
 
-/* Define to 1 if we expect to have <windows.h>, Sleep, etc. */
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
-#  define OCTAVE_USE_WINDOWS_API 1
-#endif
-
 #if defined (__APPLE__) && defined (__MACH__)
 #  define OCTAVE_USE_OS_X_API 1
 #endif
--- a/src/main.in.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/src/main.in.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -64,8 +64,7 @@
 #include "display-available.h"
 #include "shared-fcns.h"
 
-#if (defined (HAVE_OCTAVE_QT_GUI) \
-     && ! defined (__WIN32__) || defined (__CYGWIN__))
+#if defined (HAVE_OCTAVE_QT_GUI) && ! defined (OCTAVE_USE_WINDOWS_API)
 
 // Forward signals to the GUI process.
 
@@ -318,14 +317,13 @@
         }
     }
 
-#if defined (__WIN32__) && ! defined (__CYGWIN__)
+#if defined (OCTAVE_USE_WINDOWS_API)
   file += ".exe";
 #endif
 
   new_argv[0] = strsave (file.c_str ());
 
-#if (defined (HAVE_OCTAVE_QT_GUI) \
-     && ! defined (__WIN32__) || defined (__CYGWIN__))
+#if defined (HAVE_OCTAVE_QT_GUI) && ! defined (OCTAVE_USE_WINDOWS_API)
 
   if (gui_libs && start_gui && have_controlling_terminal ())
     {
--- a/src/mkoctfile.in.cc	Sat Jun 25 19:45:34 2016 -0400
+++ b/src/mkoctfile.in.cc	Sun Jun 26 03:50:20 2016 -0400
@@ -143,7 +143,7 @@
   vars["LIBDIR"] = get_variable ("LIBDIR", DEFAULT_LIBDIR);
   vars["OCTLIBDIR"] = get_variable ("OCTLIBDIR", DEFAULT_OCTLIBDIR);
 
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+#if defined (OCTAVE_USE_WINDOWS_API)
   std::string DEFAULT_INCFLAGS
     = "-I" + quote_path (vars["OCTINCLUDEDIR"] + "\\..")
       + " -I" + quote_path (vars["OCTINCLUDEDIR"]);
@@ -256,7 +256,7 @@
 "\n"
 "  -M, --depend            Generate dependency files (.d) for C and C++\n"
 "                          source files.\n"
-#if ! defined (__WIN32__) || defined (_POSIX_VERSION)
+#if ! defined (OCTAVE_USE_WINDOWS_API)
 "\n"
 "  -pthread                Add -pthread to link command.\n"
 #endif
@@ -498,7 +498,7 @@
         {
           ldflags += (" " + arg);
         }
-#if ! defined (__WIN32__) || defined (_POSIX_VERSION)
+#if ! defined (OCTAVE_USE_WINDOWS_API)
       else if (arg == "-pthread")
         {
           ldflags += (" " + arg);
--- a/src/shared-fcns.h	Sat Jun 25 19:45:34 2016 -0400
+++ b/src/shared-fcns.h	Sun Jun 26 03:50:20 2016 -0400
@@ -23,7 +23,7 @@
 #if ! defined (octave_shared_fcns_h)
 #define octave_shared_fcns_h 1
 
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+#if defined (OCTAVE_USE_WINDOWS_API)
 
 #include <windows.h>
 #include <tlhelp32.h>
@@ -111,7 +111,7 @@
 {
   std::string oh = octave_getenv ("OCTAVE_HOME");
 
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+#if defined (OCTAVE_USE_WINDOWS_API)
   if (oh.empty ())
     oh = w32_get_octave_home ();
 #endif