changeset 25649:85c3e315bd43

move libinterp/corefcn/sysdep functions inside octave namespace * libinterp/corefcn/sysdep.cc, changed libinterp/corefcn/sysdep.h: Move functions inside octave namespace. Change all uses.
author John W. Eaton <jwe@octave.org>
date Fri, 20 Jul 2018 09:01:15 -0400
parents 178f6d18c9a8
children 336267b16a3d
files libinterp/corefcn/file-io.cc libinterp/corefcn/gl2ps-print.cc libinterp/corefcn/oct-prcstrm.cc libinterp/corefcn/sysdep.cc libinterp/corefcn/sysdep.h
diffstat 5 files changed, 355 insertions(+), 289 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc	Fri Jul 20 08:25:47 2018 -0400
+++ b/libinterp/corefcn/file-io.cc	Fri Jul 20 09:01:15 2018 -0400
@@ -3079,7 +3079,7 @@
   if (args.length () != 0)
     print_usage ();
 
-  return ovl (get_P_tmpdir ());
+  return ovl (octave::get_P_tmpdir ());
 }
 
 // NOTE: the values of SEEK_SET, SEEK_CUR, and SEEK_END have to be
--- a/libinterp/corefcn/gl2ps-print.cc	Fri Jul 20 08:25:47 2018 -0400
+++ b/libinterp/corefcn/gl2ps-print.cc	Fri Jul 20 09:01:15 2018 -0400
@@ -54,7 +54,7 @@
   safe_pclose (FILE *f)
   {
     if (f)
-      octave_pclose (f);
+      octave::pclose (f);
   }
 
   static void
@@ -1105,7 +1105,7 @@
 
         std::string cmd = stream.substr (1);
 
-        fp = octave_popen (cmd.c_str (), "w");
+        fp = octave::popen (cmd.c_str (), "w");
 
         if (! fp)
           error (R"(print: failed to open pipe "%s")", stream.c_str ());
--- a/libinterp/corefcn/oct-prcstrm.cc	Fri Jul 20 08:25:47 2018 -0400
+++ b/libinterp/corefcn/oct-prcstrm.cc	Fri Jul 20 09:01:15 2018 -0400
@@ -39,8 +39,8 @@
 octave_iprocstream::octave_iprocstream (const std::string& n,
                                         std::ios::openmode arg_md,
                                         octave::mach_info::float_format ff)
-  : octave_stdiostream (n, octave_popen (n.c_str (), "r"),
-                        arg_md, ff, octave_pclose)
+  : octave_stdiostream (n, octave::popen (n.c_str (), "r"),
+                        arg_md, ff, octave::pclose)
 { }
 
 octave_iprocstream::~octave_iprocstream (void)
@@ -58,8 +58,8 @@
 octave_oprocstream::octave_oprocstream (const std::string& n,
                                         std::ios::openmode arg_md,
                                         octave::mach_info::float_format ff)
-  : octave_stdiostream (n, octave_popen (n.c_str (), "w"),
-                        arg_md, ff, octave_pclose)
+  : octave_stdiostream (n, octave::popen (n.c_str (), "w"),
+                        arg_md, ff, octave::pclose)
 { }
 
 octave_oprocstream::~octave_oprocstream (void)
--- a/libinterp/corefcn/sysdep.cc	Fri Jul 20 08:25:47 2018 -0400
+++ b/libinterp/corefcn/sysdep.cc	Fri Jul 20 09:01:15 2018 -0400
@@ -167,33 +167,35 @@
 
 #endif
 
-// Set app id if we have the SetCurrentProcessExplicitAppUserModelID
-// available (>= Win7).  FIXME: Could we check for existence of this
-// function in the configure script instead of dynamically loading
-// shell32.dll?
+namespace octave
+{
+  // Set app id if we have the SetCurrentProcessExplicitAppUserModelID
+  // available (>= Win7).  FIXME: Could we check for existence of this
+  // function in the configure script instead of dynamically loading
+  // shell32.dll?
 
-void
-set_application_id (void)
-{
+  void set_application_id (void)
+  {
 #if defined (__MINGW32__) || defined (_MSC_VER)
 
-  typedef HRESULT (WINAPI *SETCURRENTAPPID)(PCWSTR AppID);
+    typedef HRESULT (WINAPI *SETCURRENTAPPID)(PCWSTR AppID);
 
-  HMODULE hShell = LoadLibrary ("shell32.dll");
+    HMODULE hShell = LoadLibrary ("shell32.dll");
 
-  if (hShell)
-    {
-      SETCURRENTAPPID pfnSetCurrentProcessExplicitAppUserModelID =
-        reinterpret_cast<SETCURRENTAPPID> (GetProcAddress (hShell,
-                                           "SetCurrentProcessExplicitAppUserModelID"));
+    if (hShell)
+      {
+        SETCURRENTAPPID pfnSetCurrentProcessExplicitAppUserModelID =
+          reinterpret_cast<SETCURRENTAPPID> (GetProcAddress (hShell,
+                                                             "SetCurrentProcessExplicitAppUserModelID"));
 
-      if (pfnSetCurrentProcessExplicitAppUserModelID)
-        pfnSetCurrentProcessExplicitAppUserModelID (L"gnu.octave." VERSION);
+        if (pfnSetCurrentProcessExplicitAppUserModelID)
+          pfnSetCurrentProcessExplicitAppUserModelID (L"gnu.octave." VERSION);
 
-      FreeLibrary (hShell);
-    }
+        FreeLibrary (hShell);
+      }
 
 #endif
+  }
 }
 
 DEFUN (__open_with_system_app__, args, ,
@@ -251,371 +253,366 @@
 }
 #endif
 
-// Return TRUE if FILE1 and FILE2 refer to the same (physical) file.
+namespace octave
+{
+  // Return TRUE if FILE1 and FILE2 refer to the same (physical) file.
 
-bool
-same_file_internal (const std::string& file1, const std::string& file2)
-{
+  bool same_file_internal (const std::string& file1, const std::string& file2)
+  {
 #if defined (OCTAVE_USE_WINDOWS_API)
 
-  bool retval = false;
+    bool retval = false;
 
-  const wchar_t *f1 = octave::sys::u8_to_wstring (file1).c_str ();
-  const wchar_t *f2 = octave::sys::u8_to_wstring (file2).c_str ();
+    const wchar_t *f1 = octave::sys::u8_to_wstring (file1).c_str ();
+    const wchar_t *f2 = octave::sys::u8_to_wstring (file2).c_str ();
 
-  bool f1_is_dir = GetFileAttributesW (f1) & FILE_ATTRIBUTE_DIRECTORY;
-  bool f2_is_dir = GetFileAttributesW (f2) & FILE_ATTRIBUTE_DIRECTORY;
+    bool f1_is_dir = GetFileAttributesW (f1) & FILE_ATTRIBUTE_DIRECTORY;
+    bool f2_is_dir = GetFileAttributesW (f2) & FILE_ATTRIBUTE_DIRECTORY;
 
-  // Windows native code
-  // Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx
+    // Windows native code
+    // Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx
 
-  DWORD share = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE;
+    DWORD share = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE;
 
-  HANDLE hfile1
-    = CreateFileW (f1, 0, share, 0, OPEN_EXISTING,
-                   f1_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0);
+    HANDLE hfile1
+      = CreateFileW (f1, 0, share, 0, OPEN_EXISTING,
+                     f1_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0);
 
-  if (hfile1 != INVALID_HANDLE_VALUE)
-    {
-      HANDLE hfile2
-        = CreateFileW (f2, 0, share, 0, OPEN_EXISTING,
-                       f2_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0);
+    if (hfile1 != INVALID_HANDLE_VALUE)
+      {
+        HANDLE hfile2
+          = CreateFileW (f2, 0, share, 0, OPEN_EXISTING,
+                         f2_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0);
 
-      if (hfile2 != INVALID_HANDLE_VALUE)
-        {
-          BY_HANDLE_FILE_INFORMATION hfi1;
-          BY_HANDLE_FILE_INFORMATION hfi2;
+        if (hfile2 != INVALID_HANDLE_VALUE)
+          {
+            BY_HANDLE_FILE_INFORMATION hfi1;
+            BY_HANDLE_FILE_INFORMATION hfi2;
 
-          if (GetFileInformationByHandle (hfile1, &hfi1)
-              && GetFileInformationByHandle (hfile2, &hfi2))
-            {
-              retval = (hfi1.dwVolumeSerialNumber == hfi2.dwVolumeSerialNumber
-                        && hfi1.nFileIndexHigh == hfi2.nFileIndexHigh
-                        && hfi1.nFileIndexLow == hfi2.nFileIndexLow);
-            }
+            if (GetFileInformationByHandle (hfile1, &hfi1)
+                && GetFileInformationByHandle (hfile2, &hfi2))
+              {
+                retval = (hfi1.dwVolumeSerialNumber == hfi2.dwVolumeSerialNumber
+                          && hfi1.nFileIndexHigh == hfi2.nFileIndexHigh
+                          && hfi1.nFileIndexLow == hfi2.nFileIndexLow);
+              }
 
-          CloseHandle (hfile2);
-        }
+            CloseHandle (hfile2);
+          }
 
-      CloseHandle (hfile1);
-    }
+        CloseHandle (hfile1);
+      }
 
-  return retval;
+    return retval;
 
 #else
 
-  // POSIX Code
+    // POSIX Code
 
-  octave::sys::file_stat fs_file1 (file1);
-  octave::sys::file_stat fs_file2 (file2);
+    octave::sys::file_stat fs_file1 (file1);
+    octave::sys::file_stat fs_file2 (file2);
 
-  return (fs_file1 && fs_file2
-          && fs_file1.ino () == fs_file2.ino ()
-          && fs_file1.dev () == fs_file2.dev ());
+    return (fs_file1 && fs_file2
+            && fs_file1.ino () == fs_file2.ino ()
+            && fs_file1.dev () == fs_file2.dev ());
 
 #endif
-}
+  }
 
-void
-sysdep_init (void)
-{
-  // Use a function from libgomp to force loading of OpenMP library.
-  // Otherwise, a dynamically loaded library making use of OpenMP such
-  // as GraphicsMagick will segfault on exit (bug #41699).
+  void sysdep_init (void)
+  {
+    // Use a function from libgomp to force loading of OpenMP library.
+    // Otherwise, a dynamically loaded library making use of OpenMP such
+    // as GraphicsMagick will segfault on exit (bug #41699).
 #if defined (HAVE_OMP_GET_NUM_THREADS)
-  omp_get_num_threads ();
+    omp_get_num_threads ();
 #endif
 
 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__)
-  BSD_init ();
+    BSD_init ();
 #elif defined (__MINGW32__)
-  MINGW_init ();
+    MINGW_init ();
 #elif defined (_MSC_VER)
-  MSVC_init ();
+    MSVC_init ();
 #endif
-}
+  }
 
-void
-sysdep_cleanup (void)
-{
+  void sysdep_cleanup (void)
+  {
 #if defined (OCTAVE_USE_WINDOWS_API)
-  // Let us fail immediately without displaying any dialog.
-  SetProcessShutdownParameters (0x280, SHUTDOWN_NORETRY);
+    // Let us fail immediately without displaying any dialog.
+    SetProcessShutdownParameters (0x280, SHUTDOWN_NORETRY);
 #endif
-}
+  }
 
-// Set terminal in raw mode.  From less-177.
-//
-// Change terminal to "raw mode", or restore to "normal" mode.
-// "Raw mode" means
-//      1. An outstanding read will complete on receipt of a single keystroke.
-//      2. Input is not echoed.
-//      3. On output, \n is mapped to \r\n.
-//      4. \t is NOT expanded into spaces.
-//      5. Signal-causing characters such as ctrl-C (interrupt),
-//         etc. are NOT disabled.
-// It doesn't matter whether an input \n is mapped to \r, or vice versa.
+  // Set terminal in raw mode.  From less-177.
+  //
+  // Change terminal to "raw mode", or restore to "normal" mode.
+  // "Raw mode" means
+  //      1. An outstanding read will complete on receipt of a single keystroke.
+  //      2. Input is not echoed.
+  //      3. On output, \n is mapped to \r\n.
+  //      4. \t is NOT expanded into spaces.
+  //      5. Signal-causing characters such as ctrl-C (interrupt),
+  //         etc. are NOT disabled.
+  // It doesn't matter whether an input \n is mapped to \r, or vice versa.
 
-void
-raw_mode (bool on, bool wait)
-{
-  static bool curr_on = false;
+  void raw_mode (bool on, bool wait)
+  {
+    static bool curr_on = false;
 
-  int tty_fd = STDIN_FILENO;
-  if (! octave_isatty_wrapper (tty_fd))
-    {
-      if (octave::application::interactive ()
-          && ! octave::application::forced_interactive ())
-        error ("stdin is not a tty!");
-    }
+    int tty_fd = STDIN_FILENO;
+    if (! octave_isatty_wrapper (tty_fd))
+      {
+        if (octave::application::interactive ()
+            && ! octave::application::forced_interactive ())
+          error ("stdin is not a tty!");
+      }
 
-  if (on == curr_on)
-    return;
+    if (on == curr_on)
+      return;
 
 #if defined (HAVE_TERMIOS_H)
-  {
-    struct termios s;
-    static struct termios save_term;
+    {
+      struct termios s;
+      static struct termios save_term;
 
-    if (on)
-      {
-        // Get terminal modes.
+      if (on)
+        {
+          // Get terminal modes.
 
-        tcgetattr (tty_fd, &s);
+          tcgetattr (tty_fd, &s);
 
-        // Save modes and set certain variables dependent on modes.
+          // Save modes and set certain variables dependent on modes.
 
-        save_term = s;
-//      ospeed = s.c_cflag & CBAUD;
-//      erase_char = s.c_cc[VERASE];
-//      kill_char = s.c_cc[VKILL];
+          save_term = s;
+          //      ospeed = s.c_cflag & CBAUD;
+          //      erase_char = s.c_cc[VERASE];
+          //      kill_char = s.c_cc[VKILL];
 
-        // Set the modes to the way we want them.
+          // Set the modes to the way we want them.
 
-        s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL);
-        s.c_oflag |=  (OPOST | ONLCR);
+          s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL);
+          s.c_oflag |=  (OPOST | ONLCR);
 #if defined (OCRNL)
-        s.c_oflag &= ~(OCRNL);
+          s.c_oflag &= ~(OCRNL);
 #endif
 #if defined (ONOCR)
-        s.c_oflag &= ~(ONOCR);
+          s.c_oflag &= ~(ONOCR);
 #endif
 #if defined (ONLRET)
-        s.c_oflag &= ~(ONLRET);
+          s.c_oflag &= ~(ONLRET);
 #endif
-        s.c_cc[VMIN] = (wait ? 1 : 0);
-        s.c_cc[VTIME] = 0;
-      }
-    else
-      {
-        // Restore saved modes.
+          s.c_cc[VMIN] = (wait ? 1 : 0);
+          s.c_cc[VTIME] = 0;
+        }
+      else
+        {
+          // Restore saved modes.
 
-        s = save_term;
-      }
+          s = save_term;
+        }
 
-    tcsetattr (tty_fd, wait ? TCSAFLUSH : TCSADRAIN, &s);
-  }
+      tcsetattr (tty_fd, wait ? TCSAFLUSH : TCSADRAIN, &s);
+    }
 #elif defined (HAVE_TERMIO_H)
-  {
-    struct termio s;
-    static struct termio save_term;
+    {
+      struct termio s;
+      static struct termio save_term;
 
-    if (on)
-      {
-        // Get terminal modes.
+      if (on)
+        {
+          // Get terminal modes.
 
-        ioctl (tty_fd, TCGETA, &s);
+          ioctl (tty_fd, TCGETA, &s);
 
-        // Save modes and set certain variables dependent on modes.
+          // Save modes and set certain variables dependent on modes.
 
-        save_term = s;
-//      ospeed = s.c_cflag & CBAUD;
-//      erase_char = s.c_cc[VERASE];
-//      kill_char = s.c_cc[VKILL];
+          save_term = s;
+          //      ospeed = s.c_cflag & CBAUD;
+          //      erase_char = s.c_cc[VERASE];
+          //      kill_char = s.c_cc[VKILL];
 
-        // Set the modes to the way we want them.
+          // Set the modes to the way we want them.
 
-        s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL);
-        s.c_oflag |=  (OPOST | ONLCR);
+          s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL);
+          s.c_oflag |=  (OPOST | ONLCR);
 #if defined (OCRNL)
-        s.c_oflag &= ~(OCRNL);
+          s.c_oflag &= ~(OCRNL);
 #endif
 #if defined (ONOCR)
-        s.c_oflag &= ~(ONOCR);
+          s.c_oflag &= ~(ONOCR);
 #endif
 #if defined (ONLRET)
-        s.c_oflag &= ~(ONLRET);
+          s.c_oflag &= ~(ONLRET);
 #endif
-        s.c_cc[VMIN] = (wait ? 1 : 0);
-      }
-    else
-      {
-        // Restore saved modes.
+          s.c_cc[VMIN] = (wait ? 1 : 0);
+        }
+      else
+        {
+          // Restore saved modes.
+
+          s = save_term;
+        }
+
+      ioctl (tty_fd, TCSETAW, &s);
+    }
+#elif defined (HAVE_SGTTY_H)
+    {
+      octave_unused_parameter (wait);
+
+      struct sgttyb s;
+      static struct sgttyb save_term;
+
+      if (on)
+        {
+          // Get terminal modes.
 
-        s = save_term;
-      }
+          ioctl (tty_fd, TIOCGETP, &s);
+
+          // Save modes and set certain variables dependent on modes.
+
+          save_term = s;
+          //      ospeed = s.sg_ospeed;
+          //      erase_char = s.sg_erase;
+          //      kill_char = s.sg_kill;
+
+          // Set the modes to the way we want them.
 
-    ioctl (tty_fd, TCSETAW, &s);
-  }
-#elif defined (HAVE_SGTTY_H)
-  {
+          s.sg_flags |= CBREAK;
+          s.sg_flags &= ~(ECHO);
+        }
+      else
+        {
+          // Restore saved modes.
+
+          s = save_term;
+        }
+
+      ioctl (tty_fd, TIOCSETN, &s);
+    }
+#else
+
     octave_unused_parameter (wait);
 
-    struct sgttyb s;
-    static struct sgttyb save_term;
-
-    if (on)
-      {
-        // Get terminal modes.
-
-        ioctl (tty_fd, TIOCGETP, &s);
-
-        // Save modes and set certain variables dependent on modes.
-
-        save_term = s;
-//      ospeed = s.sg_ospeed;
-//      erase_char = s.sg_erase;
-//      kill_char = s.sg_kill;
-
-        // Set the modes to the way we want them.
+    warn_disabled_feature ("", "raw mode console I/O");
 
-        s.sg_flags |= CBREAK;
-        s.sg_flags &= ~(ECHO);
-      }
-    else
-      {
-        // Restore saved modes.
-
-        s = save_term;
-      }
-
-    ioctl (tty_fd, TIOCSETN, &s);
-  }
-#else
-
-  octave_unused_parameter (wait);
-
-  warn_disabled_feature ("", "raw mode console I/O");
-
-  // Make sure the current mode doesn't toggle.
-  on = curr_on;
+    // Make sure the current mode doesn't toggle.
+    on = curr_on;
 #endif
 
-  curr_on = on;
-}
+    curr_on = on;
+  }
 
-FILE *
-octave_popen (const char *command, const char *mode)
-{
+  FILE * popen (const char *command, const char *mode)
+  {
 #if defined (__MINGW32__) || defined (_MSC_VER)
-  wchar_t *wcommand = u8_to_wchar (command);
-  wchar_t *wmode = u8_to_wchar (mode);
+    wchar_t *wcommand = u8_to_wchar (command);
+    wchar_t *wmode = u8_to_wchar (mode);
 
-  octave::unwind_protect frame;
-  frame.add_fcn (::free, static_cast<void *> (wcommand));
-  frame.add_fcn (::free, static_cast<void *> (wmode));
+    octave::unwind_protect frame;
+    frame.add_fcn (::free, static_cast<void *> (wcommand));
+    frame.add_fcn (::free, static_cast<void *> (wmode));
 
-  if (wmode && wmode[0] && ! wmode[1])
-    {
-      // Use binary mode on Windows if unspecified
-      wchar_t tmode[3] = {wmode[0], L'b', L'\0'};
+    if (wmode && wmode[0] && ! wmode[1])
+      {
+        // Use binary mode on Windows if unspecified
+        wchar_t tmode[3] = {wmode[0], L'b', L'\0'};
 
-      return _wpopen (wcommand, tmode);
-    }
-  else
-    return _wpopen (wcommand, wmode);
+        return _wpopen (wcommand, tmode);
+      }
+    else
+      return _wpopen (wcommand, wmode);
 #else
-  return popen (command, mode);
+    return ::popen (command, mode);
 #endif
-}
+  }
 
-int
-octave_pclose (FILE *f)
-{
+  int pclose (FILE *f)
+  {
 #if defined (__MINGW32__) || defined (_MSC_VER)
-  return _pclose (f);
+    return _pclose (f);
 #else
-  return pclose (f);
+    return ::pclose (f);
 #endif
-}
+  }
 
-// Read one character from the terminal.
+  // Read one character from the terminal.
 
-int
-octave_kbhit (bool wait)
-{
+  int kbhit (bool wait)
+  {
 #if defined (HAVE__KBHIT) && defined (HAVE__GETCH)
-  // This essentially means we are on a Windows system.
-  int c;
+    // This essentially means we are on a Windows system.
+    int c;
 
-  if (wait)
-    c = _getch ();
-  else
-    c = (! _kbhit ()) ? 0 : _getch ();
+    if (wait)
+      c = _getch ();
+    else
+      c = (! _kbhit ()) ? 0 : _getch ();
 
 #else
-  raw_mode (true, wait);
+    raw_mode (true, wait);
 
-  // Get current handler.
-  octave::interrupt_handler saved_interrupt_handler
-    = octave::ignore_interrupts ();
+    // Get current handler.
+    octave::interrupt_handler saved_interrupt_handler
+      = octave::ignore_interrupts ();
 
-  // Restore it, disabling system call restarts (if possible) so the
-  // read can be interrupted.
+    // Restore it, disabling system call restarts (if possible) so the
+    // read can be interrupted.
 
-  octave::set_interrupt_handler (saved_interrupt_handler, false);
+    octave::set_interrupt_handler (saved_interrupt_handler, false);
 
-  int c = std::cin.get ();
+    int c = std::cin.get ();
 
-  if (std::cin.fail () || std::cin.eof ())
-    std::cin.clear ();
+    if (std::cin.fail () || std::cin.eof ())
+      std::cin.clear ();
 
-  // Restore it, enabling system call restarts (if possible).
-  octave::set_interrupt_handler (saved_interrupt_handler, true);
+    // Restore it, enabling system call restarts (if possible).
+    octave::set_interrupt_handler (saved_interrupt_handler, true);
 
-  raw_mode (false, true);
+    raw_mode (false, true);
 #endif
 
-  return c;
-}
+    return c;
+  }
 
-std::string
-get_P_tmpdir (void)
-{
+  std::string get_P_tmpdir (void)
+  {
 #if defined (OCTAVE_USE_WINDOWS_API)
 
-  std::string retval;
+    std::string retval;
 
 #if defined (P_tmpdir)
-  retval = P_tmpdir;
+    retval = P_tmpdir;
 #endif
 
-  // Apparently some versions of MinGW and MSVC either don't define
-  // P_tmpdir, or they define it to a single backslash, neither of which
-  // is particularly helpful.
+    // Apparently some versions of MinGW and MSVC either don't define
+    // P_tmpdir, or they define it to a single backslash, neither of which
+    // is particularly helpful.
 
-  if (retval.empty () || retval == R"(\)")
-    {
-      retval = octave::sys::env::getenv ("TEMP");
+    if (retval.empty () || retval == R"(\)")
+      {
+        retval = octave::sys::env::getenv ("TEMP");
 
-      if (retval.empty ())
-        retval = octave::sys::env::getenv ("TMP");
+        if (retval.empty ())
+          retval = octave::sys::env::getenv ("TMP");
 
-      if (retval.empty ())
-        retval = R"(c:\temp)";
-    }
+        if (retval.empty ())
+          retval = R"(c:\temp)";
+      }
 
-  return retval;
+    return retval;
 
 #elif defined (P_tmpdir)
 
-  return P_tmpdir;
+    return P_tmpdir;
 
 #else
 
-  return "/tmp";
+    return "/tmp";
 
 #endif
+  }
 }
 
 DEFUN (clc, , ,
@@ -730,7 +727,7 @@
   RegCloseKey (key);
 }
 
-LONG
+static LONG
 get_regkey_value (HKEY h_rootkey, const std::string subkey,
                   const std::string name, octave_value& value)
 {
@@ -771,7 +768,7 @@
   return result;
 }
 
-LONG
+static LONG
 get_regkey_names (HKEY h_rootkey, const std::string subkey,
                   std::list<std::string> &fields)
 {
@@ -1046,7 +1043,7 @@
 
   Fdrawnow ();
 
-  int c = octave_kbhit (args.length () == 0);
+  int c = octave::kbhit (args.length () == 0);
 
   if (c == -1)
     c = 0;
@@ -1107,7 +1104,7 @@
           if (octave::math::isinf (dval))
             {
               octave::flush_stdout ();
-              octave_kbhit ();
+              octave::kbhit ();
             }
           else
             octave::sleep (dval);
@@ -1117,7 +1114,7 @@
     {
       Fdrawnow ();
       octave::flush_stdout ();
-      octave_kbhit ();
+      octave::kbhit ();
     }
 
   return ovl ();
--- a/libinterp/corefcn/sysdep.h	Fri Jul 20 08:25:47 2018 -0400
+++ b/libinterp/corefcn/sysdep.h	Fri Jul 20 09:01:15 2018 -0400
@@ -32,24 +32,93 @@
 #include "lo-ieee.h"
 #include "lo-sysdep.h"
 
-extern OCTINTERP_API void sysdep_init (void);
+namespace octave
+{
+  extern OCTINTERP_API void sysdep_init (void);
+
+  extern OCTINTERP_API void set_application_id (void);
+
+  extern OCTINTERP_API void sysdep_cleanup (void);
 
-extern OCTINTERP_API void set_application_id (void);
+  extern OCTINTERP_API void raw_mode (bool, bool wait = true);
+
+  extern OCTINTERP_API FILE * popen (const char *command, const char *mode);
+
+  extern OCTINTERP_API int pclose (FILE *f);
+
+  extern OCTINTERP_API int kbhit (bool wait = true);
+
+  extern OCTINTERP_API std::string get_P_tmpdir (void);
 
-extern OCTINTERP_API void sysdep_cleanup (void);
+  extern OCTINTERP_API bool same_file_internal (const std::string&,
+                                                const std::string&);
+}
+
+#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
 
-extern OCTINTERP_API void raw_mode (bool, bool wait = true);
+OCTAVE_DEPRECATED (5, "use 'octave::sysdep_init' instead")
+inline void
+sysdep_init (void)
+{
+  octave::sysdep_init ();
+}
+
+OCTAVE_DEPRECATED (5, "use 'octave::set_application_id' instead")
+inline void
+set_application_id (void)
+{
+  octave::set_application_id ();
+}
 
-extern OCTINTERP_API FILE * octave_popen (const char *command,
-                                          const char *mode);
+OCTAVE_DEPRECATED (5, "use 'octave::sysdep_cleanup' instead")
+inline void
+sysdep_cleanup (void)
+{
+  octave::sysdep_cleanup ();
+}
 
-extern OCTINTERP_API int octave_pclose (FILE *f);
+OCTAVE_DEPRECATED (5, "use 'octave::raw_mode' instead")
+inline void
+raw_mode (bool on, bool wait = true)
+{
+  octave::raw_mode (on, wait);
+}
+
+OCTAVE_DEPRECATED (5, "use 'octave::popen' instead")
+inline FILE *
+octave_popen (const char *command, const char *mode)
+{
+  return octave::popen (command, mode);
+}
 
-extern OCTINTERP_API int octave_kbhit (bool wait = true);
+OCTAVE_DEPRECATED (5, "use 'octave::pclose' instead")
+inline int
+octave_pclose (FILE *f)
+{
+  return octave::pclose (f);
+}
+
+OCTAVE_DEPRECATED (5, "use 'octave::kbhit' instead")
+inline int
+octave_kbhit (bool wait = true)
+{
+  return octave::kbhit (wait);
+}
 
-extern OCTINTERP_API std::string get_P_tmpdir (void);
+OCTAVE_DEPRECATED (5, "use 'octave::get_P_tmpdir' instead")
+inline std::string
+get_P_tmpdir (void)
+{
+  return octave::get_P_tmpdir ();
+}
 
-extern OCTINTERP_API bool same_file_internal (const std::string&,
-                                              const std::string&);
+OCTAVE_DEPRECATED (5, "use 'octave::same_file_internal' instead")
+inline bool
+same_file_internal (const std::string& a, const std::string& b)
+{
+  return octave::same_file_internal (a, b);
+}
 
 #endif
+
+#endif