GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
sysdep.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1993-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <cmath>
31 #include <cstddef>
32 
33 #include <iostream>
34 #include <string>
35 
36 #if defined (HAVE_TERMIOS_H)
37 # include <termios.h>
38 #elif defined (HAVE_TERMIO_H)
39 # include <termio.h>
40 #elif defined (HAVE_SGTTY_H)
41 # include <sgtty.h>
42 #endif
43 
44 #if defined (HAVE_CONIO_H)
45 # include <conio.h>
46 #endif
47 
48 #if defined (HAVE_SYS_IOCTL_H)
49 # include <sys/ioctl.h>
50 #endif
51 
52 #if defined (HAVE_FLOATINGPOINT_H)
53 # include <floatingpoint.h>
54 #endif
55 
56 #if defined (HAVE_IEEEFP_H)
57 # include <ieeefp.h>
58 #endif
59 
60 #if defined (HAVE_OMP_H)
61 # include <omp.h>
62 #endif
63 
64 #include "cmd-edit.h"
65 #include "file-ops.h"
66 #include "lo-mappers.h"
67 #include "lo-sysinfo.h"
68 #include "mach-info.h"
69 #include "oct-env.h"
70 #include "uniconv-wrappers.h"
71 #include "unistd-wrappers.h"
72 
73 #include "builtin-defun-decls.h"
74 #include "Cell.h"
75 #include "defun.h"
76 #include "error.h"
77 #include "errwarn.h"
78 #include "input.h"
79 #include "interpreter-private.h"
80 #include "octave.h"
81 #include "ov.h"
82 #include "ovl.h"
83 #include "pager.h"
84 #include "parse.h"
85 #include "sighandlers.h"
86 #include "sysdep.h"
87 #include "interpreter.h"
88 #include "utils.h"
89 #include "file-stat.h"
90 
91 #if ! defined (STDIN_FILENO)
92 # define STDIN_FILENO 1
93 #endif
94 
95 #if defined (__MINGW32__) || defined (_MSC_VER)
96 
97 #define WIN32_LEAN_AND_MEAN
98 #include <windows.h>
99 #include <tlhelp32.h>
100 #include <shellapi.h>
101 
102 #endif
103 
104 namespace octave
105 {
106 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__)
107 
108  static void
109  BSD_init (void)
110  {
111 # if defined (HAVE_FLOATINGPOINT_H)
112  // Disable trapping on common exceptions.
113 # if ! defined (FP_X_DNML)
114 # define FP_X_DNML 0
115 # endif
116  fpsetmask (~(FP_X_OFL|FP_X_INV|FP_X_DZ|FP_X_DNML|FP_X_UFL|FP_X_IMP));
117 # endif
118  }
119 
120 #endif
121 
122 #if defined (__MINGW32__) || defined (_MSC_VER)
123 
124  static void
125  w32_set_octave_home (void)
126  {
127  std::string bin_dir;
128 
129  HANDLE h = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE
130 #if defined (TH32CS_SNAPMODULE32)
131  | TH32CS_SNAPMODULE32
132 #endif
133  , 0);
134 
135  if (h != INVALID_HANDLE_VALUE)
136  {
137  MODULEENTRY32W mod_info;
138 
139  ZeroMemory (&mod_info, sizeof (mod_info));
140  mod_info.dwSize = sizeof (mod_info);
141 
142  if (Module32FirstW (h, &mod_info))
143  {
144  do
145  {
146  std::string mod_name (sys::u8_from_wstring (mod_info.szModule));
147 
148  if (mod_name.find ("octinterp") != std::string::npos)
149  {
150  bin_dir = sys::u8_from_wstring (mod_info.szExePath);
151  if (! bin_dir.empty () && bin_dir.back () != '\\')
152  bin_dir.push_back ('\\');
153  break;
154  }
155  }
156  while (Module32NextW (h, &mod_info));
157  }
158 
159  CloseHandle (h);
160  }
161 
162  if (! bin_dir.empty ())
163  {
164  size_t pos = bin_dir.rfind (R"(\bin\)");
165 
166  if (pos != std::string::npos)
167  sys::env::putenv ("OCTAVE_HOME", bin_dir.substr (0, pos));
168  }
169  }
170 
171  static void
172  w32_init (void)
173  {
174  w32_set_octave_home ();
175 
177  }
178 
179 #endif
180 
181  // Set app id if we have the SetCurrentProcessExplicitAppUserModelID
182  // available (>= Win7). FIXME: Could we check for existence of this
183  // function in the configure script instead of dynamically loading
184  // shell32.dll?
185 
186  void set_application_id (void)
187  {
188 #if defined (__MINGW32__) || defined (_MSC_VER)
189 
190  typedef HRESULT (WINAPI *SETCURRENTAPPID)(PCWSTR AppID);
191 
192  HMODULE hShell = LoadLibrary ("shell32.dll");
193 
194  if (hShell)
195  {
196  SETCURRENTAPPID pfnSetCurrentProcessExplicitAppUserModelID
197  = reinterpret_cast<SETCURRENTAPPID> (GetProcAddress (hShell, "SetCurrentProcessExplicitAppUserModelID"));
198 
199  if (pfnSetCurrentProcessExplicitAppUserModelID)
200  pfnSetCurrentProcessExplicitAppUserModelID (L"gnu.octave." VERSION);
201 
202  FreeLibrary (hShell);
203  }
204 
205 #endif
206  }
207 }
208 
209 DEFUN (__open_with_system_app__, args, ,
210  doc: /* -*- texinfo -*-
211 @deftypefn {} {} __open_with_system_app__ (@var{file})
212 Internal function. Returns 1 on successful system call and 0 otherwise.
213 @end deftypefn */)
214 {
215  if (args.length () != 1)
216  print_usage ();
217 
218  std::string file = args(0).xstring_value ("__open_with_system_app__: argument must be a filename");
219 
220 #if defined (OCTAVE_USE_WINDOWS_API)
221  std::wstring wfile = octave::sys::u8_to_wstring (file);
222  HINSTANCE status = ShellExecuteW (0, 0, wfile.c_str (), 0, 0, SW_SHOWNORMAL);
223 
224  // ShellExecute returns a value greater than 32 if successful.
225  return octave_value (reinterpret_cast<ptrdiff_t> (status) > 32);
226 #else
227  // Quote file path
228  file = "\"" + file + "\"";
229 
230 # if defined (__APPLE__)
231 # define FSYSTEM_OPEN_STR "open "
232 # else
233 # define FSYSTEM_OPEN_STR "xdg-open "
234 # endif
236  = Fsystem (ovl (FSYSTEM_OPEN_STR + file + " 2> /dev/null",
237  false, "async"),
238  1);
239 # undef FSYSTEM_OPEN_STR
240 
241  // Asynchronous Fsystem calls return the new child process identifier,
242  // which must be greater than 1 if successful.
243  return octave_value (tmp(0).double_value () > 1);
244 #endif
245 }
246 
247 DEFUN (__is_elevated_process__, args, ,
248  doc: /* -*- texinfo -*-
249 @deftypefn {} {@var{retval} =} __is_elevated_process__ ()
250 Check if current process has elevated rights.
251 
252 On Windows, return true if the current process has elevated right. Otherwise,
253 return false.
254 On non-Windows platforms, this function fails with an error.
255 @end deftypefn */)
256 {
257 #if defined (OCTAVE_USE_WINDOWS_API)
258  if (args.length () != 0)
259  print_usage ();
260 
261  bool retval = false;
262  HANDLE h_token = nullptr;
263 
264  if (OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &h_token))
265  {
266  TOKEN_ELEVATION elevation;
267  DWORD return_length = sizeof (TOKEN_ELEVATION);
268  if (GetTokenInformation (h_token, TokenElevation, &elevation,
269  sizeof (elevation), &return_length))
270  retval = elevation.TokenIsElevated;
271  }
272 
273  if (h_token)
274  CloseHandle (h_token);
275 
276  return ovl (retval);
277 
278 #else
279  octave_unused_parameter (args);
280  error ("__is_elevated_process__: "
281  "Function is only supported on Windows platforms.");
282 #endif
283 }
284 
285 namespace octave
286 {
287 #if defined (__MINGW32__)
288 
289  static void
290  MINGW_init (void)
291  {
292  w32_init ();
293  }
294 
295 #endif
296 
297 #if defined (_MSC_VER)
298 
299  static void
300  MSVC_init (void)
301  {
302  w32_init ();
303  }
304 
305 #endif
306 
307  // Return TRUE if FILE1 and FILE2 refer to the same (physical) file.
308 
309  bool same_file_internal (const std::string& file1, const std::string& file2)
310  {
311 #if defined (OCTAVE_USE_WINDOWS_API)
312 
313  // FIXME: When Octave switches to C++17, consider replacing this function
314  // by https://en.cppreference.com/w/cpp/filesystem/equivalent.
315 
316  bool retval = false;
317 
318  std::wstring file1w = sys::u8_to_wstring (file1);
319  std::wstring file2w = sys::u8_to_wstring (file2);
320  const wchar_t *f1 = file1w.c_str ();
321  const wchar_t *f2 = file2w.c_str ();
322 
323  bool f1_is_dir = GetFileAttributesW (f1) & FILE_ATTRIBUTE_DIRECTORY;
324  bool f2_is_dir = GetFileAttributesW (f2) & FILE_ATTRIBUTE_DIRECTORY;
325 
326  // Windows native code
327  // Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx
328 
329  DWORD share = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE;
330 
331  HANDLE hfile1
332  = CreateFileW (f1, 0, share, 0, OPEN_EXISTING,
333  f1_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0);
334 
335  if (hfile1 != INVALID_HANDLE_VALUE)
336  {
337  HANDLE hfile2
338  = CreateFileW (f2, 0, share, 0, OPEN_EXISTING,
339  f2_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0);
340 
341  if (hfile2 != INVALID_HANDLE_VALUE)
342  {
343  BY_HANDLE_FILE_INFORMATION hfi1;
344  BY_HANDLE_FILE_INFORMATION hfi2;
345 
346  if (GetFileInformationByHandle (hfile1, &hfi1)
347  && GetFileInformationByHandle (hfile2, &hfi2))
348  {
349  retval = (hfi1.dwVolumeSerialNumber == hfi2.dwVolumeSerialNumber
350  && hfi1.nFileIndexHigh == hfi2.nFileIndexHigh
351  && hfi1.nFileIndexLow == hfi2.nFileIndexLow
352  && hfi1.nFileSizeHigh == hfi2.nFileSizeHigh
353  && hfi1.nFileSizeLow == hfi2.nFileSizeLow
354  && hfi1.ftLastWriteTime.dwLowDateTime
355  == hfi2.ftLastWriteTime.dwLowDateTime
356  && hfi1.ftLastWriteTime.dwHighDateTime
357  == hfi2.ftLastWriteTime.dwHighDateTime);
358  }
359 
360  CloseHandle (hfile2);
361  }
362 
363  CloseHandle (hfile1);
364  }
365 
366  return retval;
367 
368 #else
369 
370  // POSIX Code
371 
372  sys::file_stat fs_file1 (file1);
373  sys::file_stat fs_file2 (file2);
374 
375  return (fs_file1 && fs_file2
376  && fs_file1.ino () == fs_file2.ino ()
377  && fs_file1.dev () == fs_file2.dev ());
378 
379 #endif
380  }
381 
382  // Return TRUE if NAME refers to an existing drive letter or UNC share
383 
384  bool drive_or_unc_share (const std::string& name)
385  {
386 #if defined (OCTAVE_USE_WINDOWS_API)
387  size_t len = name.length ();
388  bool candidate = false;
389  if (len > 1 && isalpha(name[0]) && name[1]==':'
390  && (len == 2 || (len == 3 && name[2] == '\\')))
391  candidate = true;
392  if (len > 4 && name[0] == '\\' && name[1] == '\\')
393  {
394  // It starts with two slashes. Find the next slash.
395  size_t next_slash = name.find ("\\", 3);
396  if (next_slash != std::string::npos && len > next_slash+1)
397  {
398  // Check if it ends with the share
399  size_t last_slash = name.find ("\\", next_slash+1);
400  if (last_slash == std::string::npos
401  || (len > next_slash+2 && last_slash == len-1))
402  candidate = true;
403  }
404  }
405 
406  if (candidate)
407  {
408  // Open a handle to the file.
409  std::wstring wname = sys::u8_to_wstring (name);
410  HANDLE h
411  = CreateFileW (wname.c_str (), FILE_READ_ATTRIBUTES,
412  FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
413  nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS,
414  nullptr);
415  if (h != INVALID_HANDLE_VALUE)
416  {
417  CloseHandle (h);
418  return true;
419  }
420  }
421 
422  return false;
423 
424 #else
425 
426  octave_unused_parameter (name);
427 
428  return false;
429 
430 #endif
431  }
432 
433  void sysdep_init (void)
434  {
435  // Use a function from libgomp to force loading of OpenMP library.
436  // Otherwise, a dynamically loaded library making use of OpenMP such
437  // as GraphicsMagick will segfault on exit (bug #41699).
438 #if defined (HAVE_OMP_GET_NUM_THREADS)
439  omp_get_num_threads ();
440 #endif
441 
442 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__)
443  BSD_init ();
444 #elif defined (__MINGW32__)
445  MINGW_init ();
446 #elif defined (_MSC_VER)
447  MSVC_init ();
448 #endif
449  }
450 
451  void sysdep_cleanup (void)
452  {
453 #if defined (OCTAVE_USE_WINDOWS_API)
454  // Let us fail immediately without displaying any dialog.
455  SetProcessShutdownParameters (0x280, SHUTDOWN_NORETRY);
456 #endif
457  }
458 
459  // Set terminal in raw mode. From less-177.
460  //
461  // Change terminal to "raw mode", or restore to "normal" mode.
462  // "Raw mode" means
463  // 1. An outstanding read will complete on receipt of a single keystroke.
464  // 2. Input is not echoed.
465  // 3. On output, \n is mapped to \r\n.
466  // 4. \t is NOT expanded into spaces.
467  // 5. Signal-causing characters such as ctrl-C (interrupt),
468  // etc. are NOT disabled.
469  // It doesn't matter whether an input \n is mapped to \r, or vice versa.
470 
471  void raw_mode (bool on, bool wait)
472  {
473  static bool curr_on = false;
474 
475  int tty_fd = STDIN_FILENO;
476  if (! octave_isatty_wrapper (tty_fd))
477  {
478  interpreter& interp = __get_interpreter__ ("raw_mode");
479 
480  if (interp.interactive () && ! application::forced_interactive ())
481  error ("stdin is not a tty!");
482  }
483 
484  if (on == curr_on)
485  return;
486 
487 #if defined (HAVE_TERMIOS_H)
488  {
489  struct termios s;
490  static struct termios save_term;
491 
492  if (on)
493  {
494  // Get terminal modes.
495 
496  tcgetattr (tty_fd, &s);
497 
498  // Save modes and set certain variables dependent on modes.
499 
500  save_term = s;
501  // ospeed = s.c_cflag & CBAUD;
502  // erase_char = s.c_cc[VERASE];
503  // kill_char = s.c_cc[VKILL];
504 
505  // Set the modes to the way we want them.
506 
507  s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL);
508  s.c_oflag |= (OPOST | ONLCR);
509 #if defined (OCRNL)
510  s.c_oflag &= ~(OCRNL);
511 #endif
512 #if defined (ONOCR)
513  s.c_oflag &= ~(ONOCR);
514 #endif
515 #if defined (ONLRET)
516  s.c_oflag &= ~(ONLRET);
517 #endif
518  s.c_cc[VMIN] = (wait ? 1 : 0);
519  s.c_cc[VTIME] = 0;
520  }
521  else
522  {
523  // Restore saved modes.
524 
525  s = save_term;
526  }
527 
528  tcsetattr (tty_fd, wait ? TCSAFLUSH : TCSADRAIN, &s);
529  }
530 #elif defined (HAVE_TERMIO_H)
531  {
532  struct termio s;
533  static struct termio save_term;
534 
535  if (on)
536  {
537  // Get terminal modes.
538 
539  ioctl (tty_fd, TCGETA, &s);
540 
541  // Save modes and set certain variables dependent on modes.
542 
543  save_term = s;
544  // ospeed = s.c_cflag & CBAUD;
545  // erase_char = s.c_cc[VERASE];
546  // kill_char = s.c_cc[VKILL];
547 
548  // Set the modes to the way we want them.
549 
550  s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL);
551  s.c_oflag |= (OPOST | ONLCR);
552 #if defined (OCRNL)
553  s.c_oflag &= ~(OCRNL);
554 #endif
555 #if defined (ONOCR)
556  s.c_oflag &= ~(ONOCR);
557 #endif
558 #if defined (ONLRET)
559  s.c_oflag &= ~(ONLRET);
560 #endif
561  s.c_cc[VMIN] = (wait ? 1 : 0);
562  }
563  else
564  {
565  // Restore saved modes.
566 
567  s = save_term;
568  }
569 
570  ioctl (tty_fd, TCSETAW, &s);
571  }
572 #elif defined (HAVE_SGTTY_H)
573  {
574  octave_unused_parameter (wait);
575 
576  struct sgttyb s;
577  static struct sgttyb save_term;
578 
579  if (on)
580  {
581  // Get terminal modes.
582 
583  ioctl (tty_fd, TIOCGETP, &s);
584 
585  // Save modes and set certain variables dependent on modes.
586 
587  save_term = s;
588  // ospeed = s.sg_ospeed;
589  // erase_char = s.sg_erase;
590  // kill_char = s.sg_kill;
591 
592  // Set the modes to the way we want them.
593 
594  s.sg_flags |= CBREAK;
595  s.sg_flags &= ~(ECHO);
596  }
597  else
598  {
599  // Restore saved modes.
600 
601  s = save_term;
602  }
603 
604  ioctl (tty_fd, TIOCSETN, &s);
605  }
606 #else
607 
608  octave_unused_parameter (wait);
609 
610  warn_disabled_feature ("", "raw mode console I/O");
611 
612  // Make sure the current mode doesn't toggle.
613  on = curr_on;
614 #endif
615 
616  curr_on = on;
617  }
618 
619  FILE * popen (const char *command, const char *mode)
620  {
621 #if defined (__MINGW32__) || defined (_MSC_VER)
622  wchar_t *wcommand = u8_to_wchar (command);
623  wchar_t *wmode = u8_to_wchar (mode);
624 
625  unwind_protect frame;
626  frame.add_fcn (::free, static_cast<void *> (wcommand));
627  frame.add_fcn (::free, static_cast<void *> (wmode));
628 
629  if (wmode && wmode[0] && ! wmode[1])
630  {
631  // Use binary mode on Windows if unspecified
632  wchar_t tmode[3] = {wmode[0], L'b', L'\0'};
633 
634  return _wpopen (wcommand, tmode);
635  }
636  else
637  return _wpopen (wcommand, wmode);
638 #else
639  return ::popen (command, mode);
640 #endif
641  }
642 
643  int pclose (FILE *f)
644  {
645 #if defined (__MINGW32__) || defined (_MSC_VER)
646  return ::_pclose (f);
647 #else
648  return ::pclose (f);
649 #endif
650  }
651 
652  // Read one character from the terminal.
653 
654  int kbhit (bool wait)
655  {
656 #if defined (HAVE__KBHIT) && defined (HAVE__GETCH)
657  // This essentially means we are on a Windows system.
658 
659  // The value to return when wait is false and no input is ready.
660  static constexpr int eof = std::istream::traits_type::eof ();
661 
662  int c;
663 
664  if (wait)
665  c = _getch ();
666  else
667  c = (! _kbhit ()) ? eof : _getch ();
668 
669 #else
670  raw_mode (true, wait);
671 
672  // Get current handler.
673  interrupt_handler saved_interrupt_handler
674  = ignore_interrupts ();
675 
676  // Restore it, disabling system call restarts (if possible) so the
677  // read can be interrupted.
678 
679  set_interrupt_handler (saved_interrupt_handler, false);
680 
681  int c = std::cin.get ();
682 
683  if (std::cin.fail () || std::cin.eof ())
684  {
685  std::cin.clear ();
686  clearerr (stdin);
687  }
688 
689  // Restore it, enabling system call restarts (if possible).
690  set_interrupt_handler (saved_interrupt_handler, true);
691 
692  raw_mode (false, true);
693 #endif
694 
695  return c;
696  }
697 
698  std::string get_P_tmpdir (void)
699  {
700 #if defined (OCTAVE_USE_WINDOWS_API)
701 
702  std::string retval;
703 
704 #if defined (P_tmpdir)
705  retval = P_tmpdir;
706 #endif
707 
708  // Apparently some versions of MinGW and MSVC either don't define
709  // P_tmpdir, or they define it to a single backslash, neither of which
710  // is particularly helpful.
711 
712  if (retval.empty () || retval == R"(\)")
713  {
714  retval = sys::env::getenv ("TEMP");
715 
716  if (retval.empty ())
717  retval = sys::env::getenv ("TMP");
718 
719  if (retval.empty ())
720  retval = R"(c:\temp)";
721  }
722 
723  return retval;
724 
725 #elif defined (P_tmpdir)
726 
727  return P_tmpdir;
728 
729 #else
730 
731  return "/tmp";
732 
733 #endif
734  }
735 }
736 
737 DEFUN (clc, , ,
738  doc: /* -*- texinfo -*-
739 @deftypefn {} {} clc ()
740 @deftypefnx {} {} home ()
741 Clear the terminal screen and move the cursor to the upper left corner.
742 @end deftypefn */)
743 {
744  bool skip_redisplay = true;
745 
746  octave::command_editor::clear_screen (skip_redisplay);
747 
748  return ovl ();
749 }
750 
751 DEFALIAS (home, clc);
752 
753 DEFUN (getenv, args, ,
754  doc: /* -*- texinfo -*-
755 @deftypefn {} {} getenv (@var{var})
756 Return the value of the environment variable @var{var}.
757 
758 For example,
759 
760 @example
761 getenv ("PATH")
762 @end example
763 
764 @noindent
765 returns a string containing the value of your path.
766 @seealso{setenv, unsetenv}
767 @end deftypefn */)
768 {
769  if (args.length () != 1)
770  print_usage ();
771 
772  std::string name = args(0).string_value ();
773 
774  return ovl (octave::sys::env::getenv (name));
775 }
776 
777 /*
778 %!assert (ischar (getenv ("OCTAVE_HOME")))
779 */
780 
781 DEFUN (setenv, args, ,
782  doc: /* -*- texinfo -*-
783 @deftypefn {} {} setenv (@var{var}, @var{value})
784 @deftypefnx {} {} setenv (@var{var})
785 @deftypefnx {} {} putenv (@dots{})
786 Set the value of the environment variable @var{var} to @var{value}.
787 
788 If no @var{value} is specified then the variable will be assigned the null
789 string.
790 @seealso{unsetenv, getenv}
791 @end deftypefn */)
792 {
793  int nargin = args.length ();
794 
795  if (nargin < 1 || nargin > 2)
796  print_usage ();
797 
798  std::string var = args(0).xstring_value ("setenv: VAR must be a string");
799 
800  std::string val = (nargin == 2
801  ? args(1).xstring_value ("setenv: VALUE must be a string")
802  : "");
803 
804  octave::sys::env::putenv (var, val);
805 
806  return ovl ();
807 }
808 
809 DEFALIAS (putenv, setenv);
810 
811 /*
812 %!test
813 %! setenv ("dummy_variable_that_cannot_matter", "foobar");
814 %! assert (getenv ("dummy_variable_that_cannot_matter"), "foobar");
815 %! unsetenv ("dummy_variable_that_cannot_matter");
816 %! assert (getenv ("dummy_variable_that_cannot_matter"), "");
817 */
818 
819 DEFUN (unsetenv, args, ,
820  doc: /* -*- texinfo -*-
821 @deftypefn {} {@var{status} =} unsetenv (@var{var})
822 Delete the environment variable @var{var}.
823 
824 Return 0 if the variable was deleted, or did not exist, and -1 if an error
825 occurred.
826 @seealso{setenv, getenv}
827 @end deftypefn */)
828 {
829  if (args.length () != 1)
830  print_usage ();
831 
832  std::string tmp = args(0).string_value ();
833 
834  return ovl (octave::sys::unsetenv_wrapper (tmp));
835 }
836 
837 /*
838 ## Test for unsetenv is in setenv test
839 */
840 
841 #if defined (OCTAVE_USE_WINDOWS_API)
842 
843 namespace octave
844 {
845  static void
846  reg_close_key_wrapper (HKEY key)
847  {
848  RegCloseKey (key);
849  }
850 
851  // This function is also used in ov-java.cc, so don't declare static.
852  // Maybe the functions that use it should be here instead?
853 
854  LONG
855  get_regkey_value (HKEY h_rootkey, const std::string subkey,
856  const std::string name, octave_value& value)
857  {
858  LONG result;
859  HKEY h_subkey;
860 
861  std::wstring wsubkey = sys::u8_to_wstring (subkey);
862  result = RegOpenKeyExW (h_rootkey, wsubkey.c_str (), 0, KEY_READ,
863  &h_subkey);
864 
865  if (result != ERROR_SUCCESS)
866  return result;
867 
868  unwind_protect frame;
869 
870  frame.add_fcn (reg_close_key_wrapper, h_subkey);
871 
872  std::wstring wname = sys::u8_to_wstring (name);
873  DWORD length = 0;
874  result = RegQueryValueExW (h_subkey, wname.c_str (), nullptr, nullptr,
875  nullptr, &length);
876  if (result != ERROR_SUCCESS)
877  return result;
878 
879  DWORD type = 0;
880  OCTAVE_LOCAL_BUFFER (BYTE, data, length);
881  result = RegQueryValueExW (h_subkey, wname.c_str (), nullptr, &type,
882  data, &length);
883  if (result != ERROR_SUCCESS)
884  return result;
885 
886  if (type == REG_DWORD)
887  value = octave_int32 (*(reinterpret_cast<DWORD *> (data)));
888  else if (type == REG_SZ || type == REG_EXPAND_SZ)
889  value = string_vector (sys::u8_from_wstring (reinterpret_cast<wchar_t *> (data)));
890 
891  return result;
892  }
893 
894  static LONG
895  get_regkey_names (HKEY h_rootkey, const std::string subkey,
896  std::list<std::string> &fields)
897  {
898  LONG retval;
899  HKEY h_subkey;
900 
901  fields.clear ();
902 
903  std::wstring wsubkey = sys::u8_to_wstring (subkey);
904  retval = RegOpenKeyExW (h_rootkey, wsubkey.c_str (), 0, KEY_READ,
905  &h_subkey);
906  if (retval != ERROR_SUCCESS)
907  return retval;
908 
909  DWORD idx = 0;
910  const int MAX_VALUE_NAME_SIZE = 32766;
911  wchar_t value_name[MAX_VALUE_NAME_SIZE+1];
912  DWORD value_name_size = MAX_VALUE_NAME_SIZE;
913 
914  while (true)
915  {
916  retval = RegEnumValueW (h_subkey, idx, value_name, &value_name_size,
917  nullptr, nullptr, nullptr, nullptr);
918  if (retval != ERROR_SUCCESS)
919  break;
920  fields.push_back (sys::u8_from_wstring (value_name));
921  value_name_size = MAX_VALUE_NAME_SIZE;
922  idx++;
923  }
924 
925  if (retval == ERROR_NO_MORE_ITEMS)
926  retval = ERROR_SUCCESS;
927 
928  RegCloseKey (h_subkey);
929 
930  return retval;
931  }
932 }
933 
934 #endif
935 
936 DEFUN (winqueryreg, args, ,
937  doc: /* -*- texinfo -*-
938 @deftypefn {} {@var{value} =} winqueryreg (@var{rootkey}, @var{subkey}, @var{valuename})
939 @deftypefnx {} {@var{value} =} winqueryreg (@var{rootkey}, @var{subkey})
940 @deftypefnx {} {@var{names} =} winqueryreg (@code{"name"}, @var{rootkey}, @var{subkey})
941 
942 Query names or value from the Windows registry.
943 
944 On Windows, return the value of the registry key @var{subkey} from the root key
945 @var{rootkey}. You can specify the name of the queried registry value with the
946 optional argument @var{valuename}. Otherwise, if called with only two
947 arguments or @var{valuename} is empty, then the default value of @var{subkey}
948 is returned. If the registry value is of type @nospell{@qcode{"REG_DWORD"}}
949 then @var{value} is of class int32. If the value is of the type
950 @nospell{@qcode{"REG_SZ"}} or @nospell{@qcode{"REG_EXPAND_SZ"}} a string is
951 returned.
952 
953 If the first argument is @qcode{"name"}, a cell array of strings with the names
954 of the values at that key is returned.
955 
956 The variable @var{rootkey} must be a string with a valid root key identifier:
957 
958 @table @asis
959 @item @nospell{HKCR}
960 @itemx @nospell{HKEY_CLASSES_ROOT}
961 
962 @item @nospell{HKEY_CURRENT_CONFIG}
963 
964 @item @nospell{HKCU}
965 @itemx @nospell{HKEY_CURRENT_USER}
966 
967 @item @nospell{HKLM}
968 @itemx @nospell{HKEY_LOCAL_MACHINE}
969 
970 
971 @item @nospell{HKU}
972 @itemx @nospell{HKEY_USERS}
973 
974 
975 @item @nospell{HKEY_PERFORMANCE_DATA}
976 
977 @end table
978 
979 Examples:
980 
981 Get a list of value names at the key @nospell{@qcode{'HKCU\Environment'}}:
982 
983 @example
984 @group
985 @var{valuenames} = winqueryreg ("name", "HKEY_CURRENT_USER", ...
986  "Environment");
987 @end group
988 @end example
989 
990 For each @var{valuenames}, display the value:
991 
992 @example
993 @group
994 for @var{k} = 1:numel (@var{valuenames})
995  @var{val} = winqueryreg ("HKEY_CURRENT_USER", "Environment", ...
996  @var{valuenames}@{@var{k}@});
997  @var{str} = sprintf ("%s = %s", @var{valuenames}@{@var{k}@}, num2str (@var{val}));
998  disp (@var{str});
999 endfor
1000 @end group
1001 @end example
1002 
1003 On non-Windows platforms this function fails with an error.
1004 @end deftypefn */)
1005 {
1006 #if defined (OCTAVE_USE_WINDOWS_API)
1007  if ((args.length () < 2) || (args.length () > 3))
1008  print_usage ();
1009 
1010  // Input check
1011  std::string rootkey_name
1012  = args(0).xstring_value ("winqueryreg: the first argument must be 'name' "
1013  "or a valid ROOTKEY identifier");
1014  std::string subkey_name = "";
1015  std::string value_name = "";
1016  bool get_names = false;
1017  if (rootkey_name.compare ("name") == 0)
1018  {
1019  if (args.length () < 3)
1020  error ("winqueryreg: if the first argument is 'name', "
1021  "ROOTKEY and SUBKEY must be given");
1022  get_names = true;
1023  rootkey_name
1024  = args(1).xstring_value ("winqueryreg: ROOTKEY must be a string");
1025  subkey_name
1026  = args(2).xstring_value ("winqueryreg: SUBKEY must be a string");
1027  }
1028  else
1029  {
1030  subkey_name
1031  = args(1).xstring_value ("winqueryreg: SUBKEY must be a string");
1032 
1033  if (args.length () == 3)
1034  value_name
1035  = args(2).xstring_value ("winqueryreg: VALUENAME must be a string");
1036  }
1037 
1038  // Get rootkey handle
1039  HKEY h_rootkey;
1040  if (rootkey_name == "HKEY_CLASSES_ROOT" || rootkey_name == "HKCR")
1041  h_rootkey = HKEY_CLASSES_ROOT;
1042  else if (rootkey_name == "HKEY_CURRENT_CONFIG")
1043  h_rootkey = HKEY_CURRENT_CONFIG;
1044  else if (rootkey_name == "HKEY_CURRENT_USER" || rootkey_name == "HKCU")
1045  h_rootkey = HKEY_CURRENT_USER;
1046  else if (rootkey_name == "HKEY_LOCAL_MACHINE" || rootkey_name == "HKLM")
1047  h_rootkey = HKEY_LOCAL_MACHINE;
1048  else if (rootkey_name == "HKEY_PERFORMANCE_DATA")
1049  h_rootkey = HKEY_PERFORMANCE_DATA;
1050  else if (rootkey_name == "HKEY_USERS" || rootkey_name == "HKU")
1051  h_rootkey = HKEY_USERS;
1052  else
1053  error ("winqueryreg: ROOTKEY is not a valid root key identifier");
1054 
1055  if (get_names)
1056  {
1057  std::list<std::string> fields;
1058 
1059  LONG retval = octave::get_regkey_names (h_rootkey, subkey_name, fields);
1060  if (retval != ERROR_SUCCESS)
1061  error ("winqueryreg: error %ld reading names from registry", retval);
1062 
1063  Cell fieldnames (dim_vector (1, fields.size ()));
1064  size_t i;
1065  std::list<std::string>::const_iterator it;
1066  for (i = 0, it = fields.begin (); it != fields.end (); ++it, ++i)
1067  fieldnames(i) = *it;
1068 
1069  return ovl (fieldnames);
1070  }
1071  else
1072  {
1073  octave_value key_val;
1074  LONG retval = octave::get_regkey_value (h_rootkey, subkey_name,
1075  value_name, key_val);
1076  if (retval == ERROR_FILE_NOT_FOUND)
1077  error ("winqueryreg: no value found for '%s' at %s\\%s.",
1078  value_name.c_str (), rootkey_name.c_str (),
1079  subkey_name.c_str ());
1080  if (retval != ERROR_SUCCESS)
1081  error ("winqueryreg: error %ld reading the specified key", retval);
1082 
1083  return ovl (key_val);
1084  }
1085 #else
1086 
1087  octave_unused_parameter (args);
1088 
1089  error ("winqueryreg: function is only supported on Windows platforms");
1090 
1091 #endif
1092 }
1093 
1094 /*
1095 %!testif ; ispc ()
1096 %! assert (ischar (winqueryreg ("HKEY_LOCAL_MACHINE",
1097 %! 'SOFTWARE\Microsoft\Windows\CurrentVersion',
1098 %! "ProgramFilesDir")));
1099 %!testif ; ispc ()
1100 %! assert (isa (winqueryreg ("HKEY_LOCAL_MACHINE",
1101 %! 'SYSTEM\CurrentControlSet\Control\FileSystem',
1102 %! "Win31FileSystem"), "int32"));
1103 %!testif ; ispc ()
1104 %! assert (iscellstr (winqueryreg ("name", "HKEY_LOCAL_MACHINE",
1105 %! 'SOFTWARE\Microsoft\Windows\CurrentVersion')));
1106 %!testif ; ispc ()
1107 %! fail ('winqueryreg (1, ''SOFTWARE\Microsoft\Windows\CurrentVersion'')',
1108 %! "first argument must be 'name' or a valid ROOTKEY identifier");
1109 %!testif ; ispc ()
1110 %! fail ('winqueryreg ("HKEY_LOCAL_MACHINE", 1)', "SUBKEY must be a string");
1111 %!testif ; ispc ()
1112 %! fail (['winqueryreg ("HKEY_LOCAL_MACHINE", ', ...
1113 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'', 1)'],
1114 %! "VALUENAME must be a string");
1115 %!testif ; ispc ()
1116 %! fail (['winqueryreg ("FOO", ', ...
1117 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'')'],
1118 %! "ROOTKEY is not a valid root key identifier");
1119 %!testif ; ispc ()
1120 %! fail ('winqueryreg ("HKEY_LOCAL_MACHINE", ''FOO\bar'')',
1121 %! "no value found for");
1122 %!testif ; ispc ()
1123 %! fail (['winqueryreg ("HKEY_LOCAL_MACHINE", ', ...
1124 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'', "foo")'],
1125 %! "no value found for");
1126 %!testif ; ispc ()
1127 %! fail ('winqueryreg ("name", "HKEY_LOCAL_MACHINE")',
1128 %! "if the first argument is 'name', ROOTKEY and SUBKEY must be given");
1129 %!testif ; ispc ()
1130 %! fail (['winqueryreg ("name", 1, ', ...
1131 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'')'],
1132 %! "ROOTKEY must be a string");
1133 %!testif ; ispc ()
1134 %! fail ('winqueryreg ("name", "HKEY_LOCAL_MACHINE", 1)',
1135 %! "SUBKEY must be a string");
1136 */
1137 
1138 // FIXME: perhaps kbhit should also be able to print a prompt?
1139 
1140 DEFMETHOD (kbhit, interp, args, ,
1141  doc: /* -*- texinfo -*-
1142 @deftypefn {} {} kbhit ()
1143 @deftypefnx {} {} kbhit (1)
1144 Read a single keystroke from the keyboard.
1145 
1146 If called with an argument, don't wait for a keypress.
1147 
1148 For example,
1149 
1150 @example
1151 x = kbhit ();
1152 @end example
1153 
1154 @noindent
1155 will set @var{x} to the next character typed at the keyboard as soon as
1156 it is typed.
1157 
1158 @example
1159 x = kbhit (1);
1160 @end example
1161 
1162 @noindent
1163 is identical to the above example, but doesn't wait for a keypress,
1164 returning the empty string if no key is available.
1165 @seealso{input, pause}
1166 @end deftypefn */)
1167 {
1168  // FIXME: add timeout and default value args?
1169 
1170  Fdrawnow (interp);
1171 
1172  int c = octave::kbhit (args.length () == 0);
1173 
1174  if (c == -1)
1175  c = 0;
1176 
1177  char s[2] = { static_cast<char> (c), '\0' };
1178 
1179  return octave_value (s);
1180 }
1181 
1182 // State of the pause system
1183 static bool Vpause_enabled = true;
1184 
1185 DEFMETHOD (pause, interp, args, nargout,
1186  doc: /* -*- texinfo -*-
1187 @deftypefn {} {} pause ()
1188 @deftypefnx {} {} pause (@var{n})
1189 @deftypefnx {} {@var{old_state} =} pause ("on")
1190 @deftypefnx {} {@var{old_state} =} pause ("off")
1191 @deftypefnx {} {@var{old_state} =} pause ("query")
1192 Suspend the execution of the program or change the state of the pause function.
1193 
1194 If invoked without an input arguments then the program is suspended until a
1195 character is typed. If argument @var{n} is a positive real value, it indicates
1196 the number of seconds the program shall be suspended, for example:
1197 
1198 @example
1199 @group
1200 tic; pause (0.05); toc
1201  @print{} Elapsed time is 0.05039 seconds.
1202 @end group
1203 @end example
1204 
1205 The following example prints a message and then waits 5 seconds before
1206 clearing the screen.
1207 
1208 @example
1209 @group
1210 disp ("wait please...");
1211 pause (5);
1212 clc;
1213 @end group
1214 @end example
1215 
1216 If invoked with a string argument @qcode{"on"}, @qcode{"off"}, or
1217 @qcode{"query"}, the state of the pause function is changed or queried. When
1218 the state is @qcode{"off"}, the pause function returns immediately. The
1219 optional return value contains the previous state of the pause function. In
1220 the following example pause is disabled locally:
1221 
1222 @example
1223 @group
1224 old_state = pause ("off");
1225 tic; pause (0.05); toc
1226  @print{} Elapsed time is 3.00407e-05 seconds.
1227 pause (old_state);
1228 @end group
1229 @end example
1230 
1231 While the program is suspended Octave still handles figures painting and
1232 graphics callbacks execution.
1233 
1234 @seealso{kbhit}
1235 @end deftypefn */)
1236 {
1238 
1239  int nargin = args.length ();
1240 
1241  if (nargin > 1)
1242  print_usage ();
1243 
1244  if (nargin == 1 && args(0).is_string ())
1245  {
1246  bool saved_state = Vpause_enabled;
1247  std::string state = args(0).string_value ();
1248 
1249  if (state == "on")
1250  Vpause_enabled = true;
1251  else if (state == "off")
1252  Vpause_enabled = false;
1253  else if (state == "query")
1254  ;// Do nothing
1255  else
1256  error ("pause: first argument must be \"on\", \"off\" or \"query\"");
1257 
1258  if (nargout > 0 || state == "query")
1259  retval.append (saved_state ? "on" : "off");
1260  }
1261  else if (Vpause_enabled)
1262  {
1263  double dval;
1264 
1265  if (nargin == 0)
1266  dval = octave_Inf;
1267  else
1268  dval = args(0).xdouble_value ("pause: N must be a scalar real value");
1269 
1270  if (octave::math::isnan (dval))
1271  warning ("pause: NaN is an invalid delay");
1272  else
1273  {
1274  Fdrawnow (interp);
1275 
1276  octave::sleep (dval, true);
1277  }
1278  }
1279 
1280  return retval;
1281 }
1282 
1283 /*
1284 %!test
1285 %! pause (1);
1286 
1287 %!error (pause (1, 2))
1288 */
1289 
1290 // FIXME: maybe this should only return 1 if IEEE floating
1291 // point functions really work.
1292 
1293 DEFUN (isieee, , ,
1294  doc: /* -*- texinfo -*-
1295 @deftypefn {} {} isieee ()
1296 Return true if your computer @emph{claims} to conform to the IEEE standard
1297 for floating point calculations.
1298 
1299 No actual tests are performed.
1300 @end deftypefn */)
1301 {
1304 
1307 }
1308 
1309 /*
1310 %!assert (islogical (isieee ()))
1311 */
1312 
1314  doc: /* -*- texinfo -*-
1315 @deftypefn {} {} native_float_format ()
1316 Return the native floating point format as a string.
1317 @end deftypefn */)
1318 {
1321 
1323 }
1324 
1325 /*
1326 %!assert (ischar (native_float_format ()))
1327 */
1328 
1329 DEFUN (tilde_expand, args, ,
1330  doc: /* -*- texinfo -*-
1331 @deftypefn {} {} tilde_expand (@var{string})
1332 @deftypefnx {} {} tilde_expand (@var{cellstr})
1333 Perform tilde expansion on @var{string}.
1334 
1335 If @var{string} begins with a tilde character, (@samp{~}), all of the
1336 characters preceding the first slash (or all characters, if there is no
1337 slash) are treated as a possible user name, and the tilde and the following
1338 characters up to the slash are replaced by the home directory of the named
1339 user. If the tilde is followed immediately by a slash, the tilde is
1340 replaced by the home directory of the user running Octave.
1341 
1342 If the input is a cell array of strings @var{cellstr} then tilde expansion
1343 is performed on each string element.
1344 
1345 Examples:
1346 
1347 @example
1348 @group
1349 tilde_expand ("~joeuser/bin")
1350  @result{} "/home/joeuser/bin"
1351 tilde_expand ("~/bin")
1352  @result{} "/home/jwe/bin"
1353 @end group
1354 @end example
1355 @end deftypefn */)
1356 {
1357  if (args.length () != 1)
1358  print_usage ();
1359 
1360  octave_value arg = args(0);
1361 
1362  string_vector sv = arg.xstring_vector_value ("tilde_expand: argument must be char or cellstr object");
1363 
1365 
1366  if (arg.iscellstr ())
1367  return ovl (Cell (arg.dims (), sv));
1368  else
1369  return ovl (sv);
1370 }
1371 
1372 /*
1373 %!test
1374 %! home = get_home_directory ();
1375 %! assert (tilde_expand ("~/foobar"), [home "/foobar"]);
1376 %! assert (tilde_expand ("/foo/bar"), "/foo/bar");
1377 %! assert (tilde_expand ("foo/bar"), "foo/bar");
1378 */
1379 
1380 DEFUN (get_home_directory, , ,
1381  doc: /* -*- texinfo -*-
1382 @deftypefn {} {@var{homedir} =} get_home_directory ()
1383 Return the current home directory.
1384 
1385 On most systems, this is equivalent to @code{getenv ("HOME")}. On Windows
1386 systems, if the environment variable @env{HOME} is not set then it is
1387 equivalent to
1388 @code{fullfile (getenv ("HOMEDRIVE"), getenv ("HOMEPATH"))}
1389 @seealso{getenv}
1390 @end deftypefn */)
1391 {
1393 }
1394 
1395 /*
1396 %!test
1397 %! if (! ispc ())
1398 %! assert (get_home_directory (), getenv ("HOME"));
1399 %! endif
1400 */
1401 
1402 DEFUN (__blas_version__, , ,
1403  doc: /* -*- texinfo -*-
1404 @deftypefn {} {} __blas_version__ ()
1405 Undocumented internal function.
1406 @end deftypefn */)
1407 {
1408  return ovl (octave::sys::blas_version ());
1409 }
1410 
1411 DEFUN (__lapack_version__, , ,
1412  doc: /* -*- texinfo -*-
1413 @deftypefn {} {} __lapack_version__ ()
1414 Undocumented internal function.
1415 @end deftypefn */)
1416 {
1417  return ovl (octave::sys::lapack_version ());
1418 }
void clear(void)
Definition: Array.cc:87
Definition: Cell.h:43
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:95
void add_fcn(void(*fcn)(Params...), Args &&... args)
static bool forced_interactive(void)
Definition: octave.cc:280
static void clear_screen(bool skip_redisplay=false)
Definition: cmd-edit.cc:1248
static bool prefer_env_winsize(bool)
Definition: cmd-edit.cc:1610
bool interactive(void) const
Definition: interpreter.h:158
dev_t dev(void) const
Definition: file-stat.h:121
ino_t ino(void) const
Definition: file-stat.h:120
static std::string getenv(const std::string &name)
Definition: oct-env.cc:271
static std::string get_home_directory(void)
Definition: oct-env.cc:147
static void putenv(const std::string &name, const std::string &value)
Definition: oct-env.cc:278
string_vector xstring_vector_value(const char *fmt,...) const
bool iscellstr(void) const
Definition: ov.h:563
dim_vector dims(void) const
Definition: ov.h:500
OCTINTERP_API void print_usage(void)
Definition: defun.cc:53
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Definition: defun.h:138
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition: defun.h:56
#define DEFALIAS(alias, name)
Macro to define an alias for another existing function name.
Definition: defun.h:214
void warning(const char *fmt,...)
Definition: error.cc:1050
void error(const char *fmt,...)
Definition: error.cc:968
void warn_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
Definition: errwarn.cc:318
OCTAVE_EXPORT octave_value_list Fdrawnow(octave::interpreter &interp, const octave_value_list &args, int)
Definition: graphics.cc:13698
QString name
#define octave_Inf
Definition: lo-ieee.h:38
std::string bin_dir(void)
Definition: defaults.cc:171
std::string float_format_as_string(float_format flt_fmt)
Definition: mach-info.cc:105
float_format native_float_format(void)
Definition: mach-info.cc:65
@ flt_fmt_ieee_little_endian
Definition: mach-info.h:43
bool isnan(bool)
Definition: lo-mappers.h:178
std::string tilde_expand(const std::string &name)
Definition: file-ops.cc:286
std::string blas_version(void)
Definition: lo-sysinfo.cc:45
std::string u8_from_wstring(const std::wstring &wchar_string)
Definition: lo-sysdep.cc:490
int unsetenv_wrapper(const std::string &name)
Definition: lo-sysdep.cc:455
std::string lapack_version(void)
Definition: lo-sysinfo.cc:163
std::wstring u8_to_wstring(const std::string &utf8_string)
Definition: lo-sysdep.cc:468
void set_application_id(void)
Definition: sysdep.cc:186
bool drive_or_unc_share(const std::string &name)
Definition: sysdep.cc:384
static uint32_t state[624]
Definition: randmtzig.cc:190
interrupt_handler set_interrupt_handler(const volatile interrupt_handler &h, bool restart_syscalls)
Definition: sighandlers.cc:344
static double f(double k, double l_nu, double c_pm)
Definition: randpoisson.cc:118
interpreter & __get_interpreter__(const std::string &who)
interrupt_handler ignore_interrupts(void)
Definition: sighandlers.cc:333
bool same_file_internal(const std::string &file1, const std::string &file2)
Definition: sysdep.cc:309
int kbhit(bool wait)
Definition: sysdep.cc:654
FILE * popen(const char *command, const char *mode)
Definition: sysdep.cc:619
void sleep(double seconds, bool do_graphics_events)
Definition: utils.cc:1415
void sysdep_cleanup(void)
Definition: sysdep.cc:451
void sysdep_init(void)
Definition: sysdep.cc:433
int pclose(FILE *f)
Definition: sysdep.cc:643
std::string get_P_tmpdir(void)
Definition: sysdep.cc:698
void raw_mode(bool on, bool wait)
Definition: sysdep.cc:471
octave_int< int32_t > octave_int32
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:44
#define ECHO
void free(void *)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value::octave_value(const Array< char > &chm, char type) return retval
Definition: ov.cc:811
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition: ovl.h:211
static bool Vpause_enabled
Definition: sysdep.cc:1183
#define FSYSTEM_OPEN_STR
#define STDIN_FILENO
Definition: sysdep.cc:92
OCTAVE_EXPORT octave_value_list Fsystem(const octave_value_list &args, int nargout)
Definition: toplev.cc:237
wchar_t * u8_to_wchar(const char *u8)
int octave_isatty_wrapper(int fd)
F77_RET_T len
Definition: xerbla.cc:61