Mercurial > octave
annotate libinterp/corefcn/sysdep.cc @ 32086:3c608abd55f5
Move "same_file" from liboctinterp to liboctave (bug #63803).
* libinterp/corefcn/utils.cc, utils.h (same_file): Deprecate function.
* libinterp/corefcn/sysdep.cc, sysdep.h (same_file_internal): Remove function.
* liboctave/system/lo-sysdep.cc, lo-sysdep.h (same_file): Move function from
liboctinterp to liboctave.
* libgui/src/m-editor/file-editor.cc (file_editor::find_tab_widget),
libinterp/corefcn/fcn-info.cc (file_editor::find_tab_widget),
libinterp/corefcn/interpreter.cc (interpreter::execute_startup_files),
libinterp/corefcn/load-path.cc (load_path::append): Use function in updated
namespace.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sat, 06 May 2023 17:48:27 +0200 |
parents | e25bf4beb488 |
children | 85255746fc21 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
31706
597f3ee61a48
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31607
diff
changeset
|
3 // Copyright (C) 1993-2023 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
1 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21662
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
1 | 28 #endif |
29 | |
23662
bd77ab816e43
eliminate obsolete file lo-math.h
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
30 #include <cmath> |
1343 | 31 #include <cstddef> |
32 | |
3503 | 33 #include <iostream> |
1728 | 34 #include <string> |
35 | |
1430 | 36 #if defined (HAVE_TERMIOS_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
37 # include <termios.h> |
1430 | 38 #elif defined (HAVE_TERMIO_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
39 # include <termio.h> |
1430 | 40 #elif defined (HAVE_SGTTY_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
41 # include <sgtty.h> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
42 #endif |
4067 | 43 |
44 #if defined (HAVE_CONIO_H) | |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
45 # include <conio.h> |
1430 | 46 #endif |
47 | |
3248 | 48 #if defined (HAVE_SYS_IOCTL_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
49 # include <sys/ioctl.h> |
3248 | 50 #endif |
51 | |
1463 | 52 #if defined (HAVE_FLOATINGPOINT_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
53 # include <floatingpoint.h> |
1463 | 54 #endif |
55 | |
2508 | 56 #if defined (HAVE_IEEEFP_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
57 # include <ieeefp.h> |
2508 | 58 #endif |
59 | |
21554
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
60 #if defined (HAVE_OMP_H) |
21556 | 61 # include <omp.h> |
21554
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
62 #endif |
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
63 |
2926 | 64 #include "cmd-edit.h" |
65 #include "file-ops.h" | |
2893 | 66 #include "lo-mappers.h" |
24714
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
67 #include "lo-sysinfo.h" |
2317 | 68 #include "mach-info.h" |
2926 | 69 #include "oct-env.h" |
25530
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
70 #include "uniconv-wrappers.h" |
21910
4d723ba06b4a
provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
71 #include "unistd-wrappers.h" |
1769 | 72 |
22097
5ad67277b007
include builtin-defun-decls.h as needed
John W. Eaton <jwe@octave.org>
parents:
22096
diff
changeset
|
73 #include "builtin-defun-decls.h" |
6208 | 74 #include "Cell.h" |
1352 | 75 #include "defun.h" |
76 #include "error.h" | |
21115
629643522cc0
include errwarn.h in all files that use gripe_disabled_feature
John W. Eaton <jwe@octave.org>
parents:
21109
diff
changeset
|
77 #include "errwarn.h" |
529 | 78 #include "input.h" |
27301
a2b1ba6c92d5
eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
79 #include "interpreter-private.h" |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
80 #include "octave.h" |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
81 #include "ov.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
82 #include "ovl.h" |
3234 | 83 #include "pager.h" |
6419 | 84 #include "parse.h" |
5770 | 85 #include "sighandlers.h" |
1352 | 86 #include "sysdep.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
87 #include "interpreter.h" |
529 | 88 #include "utils.h" |
6598 | 89 #include "file-stat.h" |
529 | 90 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21662
diff
changeset
|
91 #if ! defined (STDIN_FILENO) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
92 # define STDIN_FILENO 1 |
529 | 93 #endif |
444 | 94 |
22019
2d8e9bdf5683
Dont use OCTAVE_USE_WINDOWS_API for w32_XXXX function definitions (Bug #48352)
John Donoghue
parents:
21989
diff
changeset
|
95 #if defined (__MINGW32__) || defined (_MSC_VER) |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
96 |
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
97 #define WIN32_LEAN_AND_MEAN |
21949
baeffde5c87d
fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents:
21910
diff
changeset
|
98 #include <windows.h> |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
99 #include <tlhelp32.h> |
28371
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
100 #include <psapi.h> |
21949
baeffde5c87d
fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents:
21910
diff
changeset
|
101 #include <shellapi.h> |
29354
6c2fa2293242
Increase Windows API version to Windows 7 (bug #60014).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29117
diff
changeset
|
102 #include <shobjidl.h> |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
103 |
5451 | 104 #endif |
105 | |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
106 OCTAVE_BEGIN_NAMESPACE(octave) |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
107 |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
108 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
109 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
110 static void |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
111 BSD_init () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
112 { |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
113 # if defined (HAVE_FLOATINGPOINT_H) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
114 // Disable trapping on common exceptions. |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
115 # if ! defined (FP_X_DNML) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
116 # define FP_X_DNML 0 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
117 # endif |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
118 fpsetmask (~(FP_X_OFL|FP_X_INV|FP_X_DZ|FP_X_DNML|FP_X_UFL|FP_X_IMP)); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
119 # endif |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
120 } |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
121 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
122 #endif |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
123 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
124 #if defined (__MINGW32__) || defined (_MSC_VER) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
125 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
126 static void |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
127 w32_set_octave_home () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
128 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
129 std::string bin_dir; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
130 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
131 HANDLE h = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
132 #if defined (TH32CS_SNAPMODULE32) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
133 | TH32CS_SNAPMODULE32 |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
134 #endif |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
135 , 0); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
136 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
137 if (h != INVALID_HANDLE_VALUE) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
138 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
139 MODULEENTRY32W mod_info; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
140 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
141 ZeroMemory (&mod_info, sizeof (mod_info)); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
142 mod_info.dwSize = sizeof (mod_info); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
143 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
144 if (Module32FirstW (h, &mod_info)) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
145 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
146 do |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
147 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
148 std::string mod_name (sys::u8_from_wstring (mod_info.szModule)); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
149 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
150 if (mod_name.find ("octinterp") != std::string::npos) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
151 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
152 bin_dir = sys::u8_from_wstring (mod_info.szExePath); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
153 if (! bin_dir.empty () && bin_dir.back () != '\\') |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
154 bin_dir.push_back ('\\'); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
155 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
156 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
157 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
158 while (Module32NextW (h, &mod_info)); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
159 } |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
160 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
161 CloseHandle (h); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
162 } |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
163 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
164 if (! bin_dir.empty ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
165 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
166 std::size_t pos = bin_dir.rfind (R"(\bin\)"); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
167 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
168 if (pos != std::string::npos) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
169 sys::env::putenv ("OCTAVE_HOME", bin_dir.substr (0, pos)); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
170 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
171 } |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
172 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
173 static void |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
174 w32_init () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
175 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
176 w32_set_octave_home (); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
177 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
178 command_editor::prefer_env_winsize (true); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
179 } |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
180 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
181 #endif |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
182 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
183 void set_application_id () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
184 { |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
185 #if defined (__MINGW32__) || defined (_MSC_VER) |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
186 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
187 SetCurrentProcessExplicitAppUserModelID (L"gnu.octave." VERSION); |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
188 |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
189 #endif |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
190 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
191 |
19856
5c1a38089f89
Change open_with_system_app to internal function.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
192 DEFUN (__open_with_system_app__, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
193 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
194 @deftypefn {} {@var{status} =} __open_with_system_app__ (@var{file}) |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
195 Return 1 on successful system call and 0 otherwise. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
196 @end deftypefn */) |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
197 { |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
198 if (args.length () != 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
199 print_usage (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
200 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
201 std::string file = args(0).xstring_value ("__open_with_system_app__: argument must be a filename"); |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
202 |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
203 #if defined (OCTAVE_USE_WINDOWS_API) |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
204 std::wstring wfile = sys::u8_to_wstring (file); |
28175
b895daca20e2
Avoid potential lifetime issues with temporary std::wstring objects.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27932
diff
changeset
|
205 HINSTANCE status = ShellExecuteW (0, 0, wfile.c_str (), 0, 0, SW_SHOWNORMAL); |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
206 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
207 // ShellExecute returns a value greater than 32 if successful. |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
208 return octave_value (reinterpret_cast<std::ptrdiff_t> (status) > 32); |
27143
64ff1053ffbf
F__open_with_system_app__: Consistent return value for all platforms.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
27126
diff
changeset
|
209 #else |
27346
1effc78e7cd1
open.m: Allow files with space in their path to be open.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27335
diff
changeset
|
210 // Quote file path |
28752
810eb29fc227
maint: Use C++ raw string literals to simplify backlsashing.
Rik <rik@octave.org>
parents:
28371
diff
changeset
|
211 file = '"' + file + '"'; |
27346
1effc78e7cd1
open.m: Allow files with space in their path to be open.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27335
diff
changeset
|
212 |
27143
64ff1053ffbf
F__open_with_system_app__: Consistent return value for all platforms.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
27126
diff
changeset
|
213 # if defined (__APPLE__) |
64ff1053ffbf
F__open_with_system_app__: Consistent return value for all platforms.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
27126
diff
changeset
|
214 # define FSYSTEM_OPEN_STR "open " |
64ff1053ffbf
F__open_with_system_app__: Consistent return value for all platforms.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
27126
diff
changeset
|
215 # else |
64ff1053ffbf
F__open_with_system_app__: Consistent return value for all platforms.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
27126
diff
changeset
|
216 # define FSYSTEM_OPEN_STR "xdg-open " |
64ff1053ffbf
F__open_with_system_app__: Consistent return value for all platforms.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
27126
diff
changeset
|
217 # endif |
20961
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
218 octave_value_list tmp |
27143
64ff1053ffbf
F__open_with_system_app__: Consistent return value for all platforms.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
27126
diff
changeset
|
219 = Fsystem (ovl (FSYSTEM_OPEN_STR + file + " 2> /dev/null", |
20961
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
220 false, "async"), |
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
221 1); |
27143
64ff1053ffbf
F__open_with_system_app__: Consistent return value for all platforms.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
27126
diff
changeset
|
222 # undef FSYSTEM_OPEN_STR |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
223 |
27143
64ff1053ffbf
F__open_with_system_app__: Consistent return value for all platforms.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
27126
diff
changeset
|
224 // Asynchronous Fsystem calls return the new child process identifier, |
64ff1053ffbf
F__open_with_system_app__: Consistent return value for all platforms.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
27126
diff
changeset
|
225 // which must be greater than 1 if successful. |
64ff1053ffbf
F__open_with_system_app__: Consistent return value for all platforms.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
27126
diff
changeset
|
226 return octave_value (tmp(0).double_value () > 1); |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
227 #endif |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
228 } |
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
229 |
28260
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
230 DEFUN (__is_elevated_process__, args, , |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
231 doc: /* -*- texinfo -*- |
28753 | 232 @deftypefn {} {@var{retval} =} __is_elevated_process__ () |
28260
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
233 Check if current process has elevated rights. |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
234 |
28753 | 235 On Windows, return true if the current process has elevated right. Otherwise, |
28260
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
236 return false. |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
237 On non-Windows platforms, this function fails with an error. |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
238 @end deftypefn */) |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
239 { |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
240 #if defined (OCTAVE_USE_WINDOWS_API) |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
241 if (args.length () != 0) |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
242 print_usage (); |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
243 |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
244 bool retval = false; |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
245 HANDLE h_token = nullptr; |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
246 |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
247 if (OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &h_token)) |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
248 { |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
249 TOKEN_ELEVATION elevation; |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
250 DWORD return_length = sizeof (TOKEN_ELEVATION); |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
251 if (GetTokenInformation (h_token, TokenElevation, &elevation, |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
252 sizeof (elevation), &return_length)) |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
253 retval = elevation.TokenIsElevated; |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
254 } |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
255 |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
256 if (h_token) |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
257 CloseHandle (h_token); |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
258 |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
259 return ovl (retval); |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
260 |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
261 #else |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
262 octave_unused_parameter (args); |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
263 error ("__is_elevated_process__: " |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
264 "Function is only supported on Windows platforms."); |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
265 #endif |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
266 } |
ec77c790fce2
pkg.m: Install packages globally if process has elevated rights (bug #44548).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28175
diff
changeset
|
267 |
28371
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
268 DEFUN (__wmemory__, args, , |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
269 doc: /* -*- texinfo -*- |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
270 @deftypefn {} {[@var{proc}, @var{sys}] =} __wmemory__ () |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
271 Return memory information on Windows. |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
272 |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
273 On non-Windows platforms, this function fails with an error. |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
274 @end deftypefn */) |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
275 { |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
276 #if defined (OCTAVE_USE_WINDOWS_API) |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
277 if (args.length () != 0) |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
278 print_usage (); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
279 |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
280 // Get memory usage of the current process |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
281 octave_scalar_map proc_struct; |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
282 |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
283 HANDLE h_proc = GetCurrentProcess (); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
284 if (h_proc == nullptr) |
28905
89a425f2c202
maint: Use Octave convention that error() messages don't end with a period.
Rik <rik@octave.org>
parents:
28857
diff
changeset
|
285 error ("__wmemory__: Couldn't open handle to own process"); |
28371
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
286 |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
287 PROCESS_MEMORY_COUNTERS proc_mem_count; |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
288 if (GetProcessMemoryInfo (h_proc, &proc_mem_count, sizeof (proc_mem_count))) |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
289 { |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
290 proc_struct.setfield ("PageFaultCount", |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
291 proc_mem_count.PageFaultCount); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
292 proc_struct.setfield ("PeakWorkingSetSize", |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
293 proc_mem_count.PeakWorkingSetSize); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
294 proc_struct.setfield ("WorkingSetSize", |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
295 proc_mem_count.WorkingSetSize); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
296 proc_struct.setfield ("QuotaPeakPagedPoolUsage", |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
297 proc_mem_count.QuotaPeakPagedPoolUsage); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
298 proc_struct.setfield ("QuotaPagedPoolUsage", |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
299 proc_mem_count.QuotaPagedPoolUsage); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
300 proc_struct.setfield ("QuotaPeakNonPagedPoolUsage", |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
301 proc_mem_count.QuotaPeakNonPagedPoolUsage); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
302 proc_struct.setfield ("QuotaNonPagedPoolUsage", |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
303 proc_mem_count.QuotaNonPagedPoolUsage); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
304 proc_struct.setfield ("PagefileUsage", |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
305 proc_mem_count.PagefileUsage); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
306 proc_struct.setfield ("PeakPagefileUsage", |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
307 proc_mem_count.PeakPagefileUsage); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
308 } |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
309 else |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
310 { |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
311 proc_struct.setfield ("PageFaultCount", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
312 proc_struct.setfield ("PeakWorkingSetSize", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
313 proc_struct.setfield ("WorkingSetSize", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
314 proc_struct.setfield ("QuotaPeakPagedPoolUsage", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
315 proc_struct.setfield ("QuotaPagedPoolUsage", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
316 proc_struct.setfield ("QuotaPeakNonPagedPoolUsage", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
317 proc_struct.setfield ("QuotaNonPagedPoolUsage", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
318 proc_struct.setfield ("PagefileUsage", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
319 proc_struct.setfield ("PeakPagefileUsage", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
320 } |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
321 |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
322 CloseHandle (h_proc); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
323 |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
324 // Get system memory usage |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
325 octave_scalar_map sys_struct; |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
326 |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
327 MEMORYSTATUSEX mem_stat; |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
328 |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
329 mem_stat.dwLength = sizeof (mem_stat); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
330 |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
331 if (GlobalMemoryStatusEx (&mem_stat)) |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
332 { |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
333 sys_struct.setfield ("MemoryLoad", mem_stat.dwMemoryLoad); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
334 sys_struct.setfield ("TotalPhys", mem_stat.ullTotalPhys); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
335 sys_struct.setfield ("AvailPhys", mem_stat.ullAvailPhys); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
336 sys_struct.setfield ("TotalPageFile", mem_stat.ullTotalPageFile); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
337 sys_struct.setfield ("AvailPageFile", mem_stat.ullAvailPageFile); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
338 sys_struct.setfield ("TotalVirtual", mem_stat.ullTotalVirtual); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
339 sys_struct.setfield ("AvailVirtual", mem_stat.ullAvailVirtual); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
340 sys_struct.setfield ("AvailExtendedVirtual", |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
341 mem_stat.ullAvailExtendedVirtual); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
342 } |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
343 else |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
344 { |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
345 sys_struct.setfield ("MemoryLoad", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
346 sys_struct.setfield ("TotalPhys", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
347 sys_struct.setfield ("AvailPhys", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
348 sys_struct.setfield ("TotalPageFile", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
349 sys_struct.setfield ("AvailPageFile", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
350 sys_struct.setfield ("TotalVirtual", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
351 sys_struct.setfield ("AvailVirtual", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
352 sys_struct.setfield ("AvailExtendedVirtual", 0); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
353 } |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
354 |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
355 return ovl (proc_struct, sys_struct); |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
356 |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
357 #else |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
358 octave_unused_parameter (args); |
28905
89a425f2c202
maint: Use Octave convention that error() messages don't end with a period.
Rik <rik@octave.org>
parents:
28857
diff
changeset
|
359 error ("__wmemory__: Function is only supported on Windows platforms"); |
28371
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
360 #endif |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
361 } |
401599248e4d
Add function to query memory information on Windows (patch #9924).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28261
diff
changeset
|
362 |
5451 | 363 #if defined (__MINGW32__) |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
364 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
365 static void |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
366 MINGW_init () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
367 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
368 w32_init (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
369 } |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
370 |
5451 | 371 #endif |
372 | |
6080 | 373 #if defined (_MSC_VER) |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
374 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
375 static void |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
376 MSVC_init () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
377 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
378 w32_init (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
379 } |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
380 |
6080 | 381 #endif |
382 | |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
383 // Return TRUE if NAME refers to an existing drive letter or UNC share |
26995
ab5bfee22d18
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26844
diff
changeset
|
384 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
385 bool drive_or_unc_share (const std::string& name) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
386 { |
26843
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
387 #if defined (OCTAVE_USE_WINDOWS_API) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
388 std::size_t len = name.length (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
389 bool candidate = false; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
390 if (len > 1 && isalpha(name[0]) && name[1]==':' |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
391 && (len == 2 || (len == 3 && name[2] == '\\'))) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
392 candidate = true; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
393 if (len > 4 && name[0] == '\\' && name[1] == '\\') |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
394 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
395 // It starts with two slashes. Find the next slash. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
396 std::size_t next_slash = name.find ('\\', 3); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
397 if (next_slash != std::string::npos && len > next_slash+1) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
398 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
399 // Check if it ends with the share |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
400 std::size_t last_slash = name.find ('\\', next_slash+1); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
401 if (last_slash == std::string::npos |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
402 || (len > next_slash+2 && last_slash == len-1)) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
403 candidate = true; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
404 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
405 } |
26843
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
406 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
407 if (candidate) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
408 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
409 // Open a handle to the file. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
410 std::wstring wname = sys::u8_to_wstring (name); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
411 HANDLE h |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
412 = CreateFileW (wname.c_str (), FILE_READ_ATTRIBUTES, |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
413 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
414 nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
415 nullptr); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
416 if (h != INVALID_HANDLE_VALUE) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
417 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
418 CloseHandle (h); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
419 return true; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
420 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
421 } |
26843
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
422 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
423 return false; |
26843
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
424 |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
425 #else |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
426 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
427 octave_unused_parameter (name); |
26843
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
428 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
429 return false; |
26843
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
430 |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
431 #endif |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
432 } |
26995
ab5bfee22d18
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26844
diff
changeset
|
433 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
434 void sysdep_init () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
435 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
436 // Use a function from libgomp to force loading of OpenMP library. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
437 // Otherwise, a dynamically loaded library making use of OpenMP such |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
438 // as GraphicsMagick will segfault on exit (bug #41699). |
21554
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
439 #if defined (HAVE_OMP_GET_NUM_THREADS) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
440 omp_get_num_threads (); |
21554
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
441 #endif |
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
442 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14445
diff
changeset
|
443 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
444 BSD_init (); |
5451 | 445 #elif defined (__MINGW32__) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
446 MINGW_init (); |
6080 | 447 #elif defined (_MSC_VER) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
448 MSVC_init (); |
1 | 449 #endif |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
450 } |
1 | 451 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
452 void sysdep_cleanup () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
453 { |
21989
6bce4d23af6b
eliminate OCTAVE_USE_WINDOWS_API and OCTAVE_USE_OS_X_API from header files
John W. Eaton <jwe@octave.org>
parents:
21979
diff
changeset
|
454 #if defined (OCTAVE_USE_WINDOWS_API) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
455 // Let us fail immediately without displaying any dialog. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
456 SetProcessShutdownParameters (0x280, SHUTDOWN_NORETRY); |
21989
6bce4d23af6b
eliminate OCTAVE_USE_WINDOWS_API and OCTAVE_USE_OS_X_API from header files
John W. Eaton <jwe@octave.org>
parents:
21979
diff
changeset
|
457 #endif |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
458 } |
5451 | 459 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
460 // Set terminal in raw mode. From less-177. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
461 // |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
462 // Change terminal to "raw mode", or restore to "normal" mode. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
463 // "Raw mode" means |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
464 // 1. An outstanding read will complete on receipt of a single keystroke. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
465 // 2. Input is not echoed. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
466 // 3. On output, \n is mapped to \r\n. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
467 // 4. \t is NOT expanded into spaces. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
468 // 5. Signal-causing characters such as ctrl-C (interrupt), |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
469 // etc. are NOT disabled. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
470 // It doesn't matter whether an input \n is mapped to \r, or vice versa. |
767 | 471 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
472 void raw_mode (bool on, bool wait) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
473 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
474 static bool curr_on = false; |
529 | 475 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
476 int tty_fd = STDIN_FILENO; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
477 if (! octave_isatty_wrapper (tty_fd)) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
478 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
479 interpreter& interp = __get_interpreter__ (); |
27301
a2b1ba6c92d5
eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
480 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
481 if (interp.interactive () && ! application::forced_interactive ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
482 error ("stdin is not a tty!"); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
483 } |
529 | 484 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
485 if (on == curr_on) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
486 return; |
529 | 487 |
488 #if defined (HAVE_TERMIOS_H) | |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
489 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
490 struct termios s; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
491 static struct termios save_term; |
529 | 492 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
493 if (on) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
494 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
495 // Get terminal modes. |
529 | 496 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
497 tcgetattr (tty_fd, &s); |
529 | 498 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
499 // Save modes and set certain variables dependent on modes. |
529 | 500 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
501 save_term = s; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
502 // ospeed = s.c_cflag & CBAUD; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
503 // erase_char = s.c_cc[VERASE]; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
504 // kill_char = s.c_cc[VKILL]; |
529 | 505 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
506 // Set the modes to the way we want them. |
529 | 507 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
508 s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
509 s.c_oflag |= (OPOST | ONLCR); |
529 | 510 #if defined (OCRNL) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
511 s.c_oflag &= ~(OCRNL); |
529 | 512 #endif |
513 #if defined (ONOCR) | |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
514 s.c_oflag &= ~(ONOCR); |
529 | 515 #endif |
516 #if defined (ONLRET) | |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
517 s.c_oflag &= ~(ONLRET); |
529 | 518 #endif |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
519 s.c_cc[VMIN] = (wait ? 1 : 0); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
520 s.c_cc[VTIME] = 0; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
521 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
522 else |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
523 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
524 // Restore saved modes. |
1358 | 525 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
526 s = save_term; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
527 } |
3658 | 528 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
529 tcsetattr (tty_fd, wait ? TCSAFLUSH : TCSADRAIN, &s); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
530 } |
529 | 531 #elif defined (HAVE_TERMIO_H) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
532 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
533 struct termio s; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
534 static struct termio save_term; |
529 | 535 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
536 if (on) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
537 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
538 // Get terminal modes. |
529 | 539 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
540 ioctl (tty_fd, TCGETA, &s); |
529 | 541 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
542 // Save modes and set certain variables dependent on modes. |
529 | 543 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
544 save_term = s; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
545 // ospeed = s.c_cflag & CBAUD; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
546 // erase_char = s.c_cc[VERASE]; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
547 // kill_char = s.c_cc[VKILL]; |
529 | 548 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
549 // Set the modes to the way we want them. |
529 | 550 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
551 s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
552 s.c_oflag |= (OPOST | ONLCR); |
529 | 553 #if defined (OCRNL) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
554 s.c_oflag &= ~(OCRNL); |
529 | 555 #endif |
556 #if defined (ONOCR) | |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
557 s.c_oflag &= ~(ONOCR); |
529 | 558 #endif |
559 #if defined (ONLRET) | |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
560 s.c_oflag &= ~(ONLRET); |
529 | 561 #endif |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
562 s.c_cc[VMIN] = (wait ? 1 : 0); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
563 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
564 else |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
565 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
566 // Restore saved modes. |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
567 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
568 s = save_term; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
569 } |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
570 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
571 ioctl (tty_fd, TCSETAW, &s); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
572 } |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
573 #elif defined (HAVE_SGTTY_H) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
574 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
575 octave_unused_parameter (wait); |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
576 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
577 struct sgttyb s; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
578 static struct sgttyb save_term; |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
579 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
580 if (on) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
581 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
582 // Get terminal modes. |
1358 | 583 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
584 ioctl (tty_fd, TIOCGETP, &s); |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
585 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
586 // Save modes and set certain variables dependent on modes. |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
587 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
588 save_term = s; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
589 // ospeed = s.sg_ospeed; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
590 // erase_char = s.sg_erase; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
591 // kill_char = s.sg_kill; |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
592 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
593 // Set the modes to the way we want them. |
3658 | 594 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
595 s.sg_flags |= CBREAK; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
596 s.sg_flags &= ~(ECHO); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
597 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
598 else |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
599 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
600 // Restore saved modes. |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
601 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
602 s = save_term; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
603 } |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
604 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
605 ioctl (tty_fd, TIOCSETN, &s); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
606 } |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
607 #else |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
608 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
609 octave_unused_parameter (wait); |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23812
diff
changeset
|
610 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
611 warn_disabled_feature ("", "raw mode console I/O"); |
529 | 612 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
613 // Make sure the current mode doesn't toggle. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
614 on = curr_on; |
529 | 615 #endif |
616 | |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
617 curr_on = on; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
618 } |
529 | 619 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
620 FILE * popen (const char *command, const char *mode) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
621 { |
6726 | 622 #if defined (__MINGW32__) || defined (_MSC_VER) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
623 std::wstring wcommand = sys::u8_to_wstring (command); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
624 std::wstring wmode = sys::u8_to_wstring (mode); |
25530
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
625 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
626 // Use binary mode on Windows if unspecified |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
627 if (wmode.length () < 2) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
628 wmode += L'b'; |
6726 | 629 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
630 return _wpopen (wcommand.c_str (), wmode.c_str ()); |
6726 | 631 #else |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
632 return ::popen (command, mode); |
6726 | 633 #endif |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
634 } |
6726 | 635 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
636 int pclose (FILE *f) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
637 { |
6726 | 638 #if defined (__MINGW32__) || defined (_MSC_VER) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
639 return ::_pclose (f); |
6726 | 640 #else |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
641 return ::pclose (f); |
6726 | 642 #endif |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
643 } |
6726 | 644 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
645 // Read one character from the terminal. |
767 | 646 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
647 int kbhit (bool wait) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
648 { |
20788
a2b96b523472
Rewrite a8ee668e7fd7 to use #if defined rather than #ifdef.
Rik <rik@octave.org>
parents:
20786
diff
changeset
|
649 #if defined (HAVE__KBHIT) && defined (HAVE__GETCH) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
650 // This essentially means we are on a Windows system. |
27045
7894624afc47
Fix pause() with no arguments called on Windows (bug #55943)
Mike Miller <mtmiller@octave.org>
parents:
27011
diff
changeset
|
651 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
652 // The value to return when wait is false and no input is ready. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
653 static constexpr int eof = std::istream::traits_type::eof (); |
27045
7894624afc47
Fix pause() with no arguments called on Windows (bug #55943)
Mike Miller <mtmiller@octave.org>
parents:
27011
diff
changeset
|
654 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
655 int c; |
20786
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
656 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
657 if (wait) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
658 c = _getch (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
659 else |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
660 c = (! _kbhit ()) ? eof : _getch (); |
20786
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
661 |
4067 | 662 #else |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
663 raw_mode (true, wait); |
3658 | 664 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
665 // Get current handler. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
666 interrupt_handler saved_interrupt_handler |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
667 = ignore_interrupts (); |
5770 | 668 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
669 // Restore it, disabling system call restarts (if possible) so the |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
670 // read can be interrupted. |
5770 | 671 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
672 set_interrupt_handler (saved_interrupt_handler, false); |
5770 | 673 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
674 int c = std::cin.get (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
675 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
676 if (std::cin.fail () || std::cin.eof ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
677 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
678 std::cin.clear (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
679 clearerr (stdin); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
680 } |
3658 | 681 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
682 // Restore it, enabling system call restarts (if possible). |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
683 set_interrupt_handler (saved_interrupt_handler, true); |
5770 | 684 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
685 raw_mode (false, true); |
4067 | 686 #endif |
3658 | 687 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
688 return c; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
689 } |
529 | 690 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
691 std::string get_P_tmpdir () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
692 { |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
693 #if defined (OCTAVE_USE_WINDOWS_API) |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
694 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
695 std::string retval; |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
696 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
697 #if defined (P_tmpdir) |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
698 retval = P_tmpdir; |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
699 #endif |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
700 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
701 // Apparently some versions of MinGW and MSVC either don't define |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
702 // P_tmpdir, or they define it to a single backslash, neither of which |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
703 // is particularly helpful. |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
704 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
705 if (retval.empty () || retval == R"(\)") |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
706 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
707 retval = sys::env::getenv ("TEMP"); |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
708 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
709 if (retval.empty ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
710 retval = sys::env::getenv ("TMP"); |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
711 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
712 if (retval.empty ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
713 retval = R"(c:\temp)"; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
714 } |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
715 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
716 return retval; |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
717 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
718 #elif defined (P_tmpdir) |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
719 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
720 return P_tmpdir; |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
721 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
722 #else |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
723 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
724 return "/tmp"; |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
725 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
726 #endif |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
727 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
728 |
1957 | 729 DEFUN (clc, , , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
730 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
731 @deftypefn {} {} clc () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
732 @deftypefnx {} {} home () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
733 Clear the terminal screen and move the cursor to the upper left corner. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
734 @end deftypefn */) |
529 | 735 { |
16537
106a38d7b396
optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents:
16404
diff
changeset
|
736 bool skip_redisplay = true; |
106a38d7b396
optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents:
16404
diff
changeset
|
737 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
738 command_editor::clear_screen (skip_redisplay); |
529 | 739 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
740 return ovl (); |
529 | 741 } |
742 | |
549 | 743 DEFALIAS (home, clc); |
744 | |
1957 | 745 DEFUN (getenv, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
746 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
747 @deftypefn {} {@var{val} =} getenv ("@var{var}") |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
748 Return the value of the environment variable @var{var}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
749 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
750 For example, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
751 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
752 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
753 getenv ("PATH") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
754 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
755 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
756 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
757 returns a string containing the value of your path. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
758 @seealso{setenv, unsetenv} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
759 @end deftypefn */) |
529 | 760 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
761 if (args.length () != 1) |
5823 | 762 print_usage (); |
529 | 763 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
764 std::string name = args(0).string_value (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
765 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
766 return ovl (sys::env::getenv (name)); |
529 | 767 } |
768 | |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
769 /* |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
770 %!assert (ischar (getenv ("OCTAVE_HOME"))) |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
771 */ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
772 |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
773 DEFUN (setenv, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
774 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
775 @deftypefn {} {} setenv ("@var{var}", @var{value}) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
776 @deftypefnx {} {} setenv (@var{var}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
777 @deftypefnx {} {} putenv (@dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
778 Set the value of the environment variable @var{var} to @var{value}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
779 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
780 If no @var{value} is specified then the variable will be assigned the null |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
781 string. |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
782 |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
783 Programming Note: @code{putenv} is an alias for @code{setenv} and can be used |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
784 interchangeably. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
785 @seealso{unsetenv, getenv} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
786 @end deftypefn */) |
1706 | 787 { |
788 int nargin = args.length (); | |
789 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
790 if (nargin < 1 || nargin > 2) |
5823 | 791 print_usage (); |
1706 | 792 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
793 std::string var = args(0).xstring_value ("setenv: VAR must be a string"); |
1706 | 794 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
795 std::string val = (nargin == 2 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
796 ? args(1).xstring_value ("setenv: VALUE must be a string") |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20990
diff
changeset
|
797 : ""); |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
798 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
799 sys::env::putenv (var, val); |
1706 | 800 |
21078
49852ff04747
maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
801 return ovl (); |
1706 | 802 } |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
803 |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
804 DEFALIAS (putenv, setenv); |
1706 | 805 |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
806 /* |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
807 %!test |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
808 %! setenv ("dummy_variable_that_cannot_matter", "foobar"); |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
809 %! assert (getenv ("dummy_variable_that_cannot_matter"), "foobar"); |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
810 %! unsetenv ("dummy_variable_that_cannot_matter"); |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
811 %! assert (getenv ("dummy_variable_that_cannot_matter"), ""); |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
812 */ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
813 |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
814 DEFUN (unsetenv, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
815 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
816 @deftypefn {} {@var{status} =} unsetenv (@var{var}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
817 Delete the environment variable @var{var}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
818 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
819 Return 0 if the variable was deleted, or did not exist, and -1 if an error |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
820 occurred. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
821 @seealso{setenv, getenv} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
822 @end deftypefn */) |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
823 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
824 if (args.length () != 1) |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
825 print_usage (); |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
826 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
827 std::string tmp = args(0).string_value (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
828 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
829 return ovl (sys::unsetenv_wrapper (tmp)); |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
830 } |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
831 |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
832 /* |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
833 ## Test for unsetenv is in setenv test |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
834 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
835 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
836 #if defined (OCTAVE_USE_WINDOWS_API) |
24710
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
837 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
838 static void |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
839 reg_close_key_wrapper (HKEY key) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
840 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
841 RegCloseKey (key); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
842 } |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
843 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
844 // This function is also used in ov-java.cc, so don't declare static. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
845 // Maybe the functions that use it should be here instead? |
27126
3d9e72cac668
allow Windows build to work again
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
846 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
847 LONG |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
848 get_regkey_value (HKEY h_rootkey, const std::string subkey, |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
849 const std::string name, octave_value& value) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
850 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
851 LONG result; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
852 HKEY h_subkey; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
853 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
854 std::wstring wsubkey = sys::u8_to_wstring (subkey); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
855 result = RegOpenKeyExW (h_rootkey, wsubkey.c_str (), 0, KEY_READ, |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
856 &h_subkey); |
28175
b895daca20e2
Avoid potential lifetime issues with temporary std::wstring objects.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27932
diff
changeset
|
857 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
858 if (result != ERROR_SUCCESS) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
859 return result; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
860 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
861 unwind_action restore_keys ([=] () { reg_close_key_wrapper (h_subkey); }); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
862 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
863 std::wstring wname = sys::u8_to_wstring (name); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
864 DWORD length = 0; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
865 result = RegQueryValueExW (h_subkey, wname.c_str (), nullptr, nullptr, |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
866 nullptr, &length); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
867 if (result != ERROR_SUCCESS) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
868 return result; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
869 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
870 DWORD type = 0; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
871 OCTAVE_LOCAL_BUFFER (BYTE, data, length); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
872 result = RegQueryValueExW (h_subkey, wname.c_str (), nullptr, &type, |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
873 data, &length); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
874 if (result != ERROR_SUCCESS) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
875 return result; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
876 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
877 if (type == REG_DWORD) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
878 value = octave_int32 (*(reinterpret_cast<DWORD *> (data))); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
879 else if (type == REG_SZ || type == REG_EXPAND_SZ) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
880 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
881 // strings in registry might not be zero terminated |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
882 wchar_t *dataw = reinterpret_cast<wchar_t *> (data); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
883 DWORD lengthw = length / sizeof (wchar_t); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
884 std::wstring reg_string |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
885 = std::wstring (dataw, lengthw - (dataw[lengthw-1]==0)); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
886 value = string_vector (sys::u8_from_wstring (reg_string)); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
887 } |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
888 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
889 return result; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
890 } |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
891 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
892 static LONG |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
893 get_regkey_names (HKEY h_rootkey, const std::string subkey, |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
894 std::list<std::string>& fields) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
895 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
896 LONG retval; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
897 HKEY h_subkey; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
898 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
899 fields.clear (); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
900 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
901 std::wstring wsubkey = sys::u8_to_wstring (subkey); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
902 retval = RegOpenKeyExW (h_rootkey, wsubkey.c_str (), 0, KEY_READ, |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
903 &h_subkey); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
904 if (retval != ERROR_SUCCESS) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
905 return retval; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
906 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
907 DWORD idx = 0; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
908 const int MAX_VALUE_NAME_SIZE = 32766; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
909 wchar_t value_name[MAX_VALUE_NAME_SIZE+1]; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
910 DWORD value_name_size = MAX_VALUE_NAME_SIZE; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
911 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
912 while (true) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
913 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
914 retval = RegEnumValueW (h_subkey, idx, value_name, &value_name_size, |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
915 nullptr, nullptr, nullptr, nullptr); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
916 if (retval != ERROR_SUCCESS) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
917 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
918 fields.push_back (sys::u8_from_wstring (value_name)); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
919 value_name_size = MAX_VALUE_NAME_SIZE; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
920 idx++; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
921 } |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
922 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
923 if (retval == ERROR_NO_MORE_ITEMS) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
924 retval = ERROR_SUCCESS; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
925 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
926 RegCloseKey (h_subkey); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27046
diff
changeset
|
927 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
928 return retval; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
929 } |
24710
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
930 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
931 #endif |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
932 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
933 DEFUN (winqueryreg, args, , |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
934 doc: /* -*- texinfo -*- |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
935 @deftypefn {} {@var{value} =} winqueryreg (@var{rootkey}, @var{subkey}, @var{valuename}) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
936 @deftypefnx {} {@var{value} =} winqueryreg (@var{rootkey}, @var{subkey}) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
937 @deftypefnx {} {@var{names} =} winqueryreg (@code{"name"}, @var{rootkey}, @var{subkey}) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
938 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
939 Query names or value from the Windows registry. |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
940 |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
941 On Windows, return the value of the registry key @var{subkey} from the root key |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
942 @var{rootkey}. You can specify the name of the queried registry value with the |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
943 optional argument @var{valuename}. Otherwise, if called with only two |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
944 arguments or @var{valuename} is empty, then the default value of @var{subkey} |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
945 is returned. If the registry value is of type @nospell{@qcode{"REG_DWORD"}} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
946 then @var{value} is of class int32. If the value is of the type |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
947 @nospell{@qcode{"REG_SZ"}} or @nospell{@qcode{"REG_EXPAND_SZ"}} a string is |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
948 returned. |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
949 |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
950 If the first argument is @qcode{"name"}, a cell array of strings with the names |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
951 of the values at that key is returned. |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
952 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
953 The variable @var{rootkey} must be a string with a valid root key identifier: |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
954 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
955 @table @asis |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
956 @item @nospell{HKCR} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
957 @itemx @nospell{HKEY_CLASSES_ROOT} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
958 |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
959 @item @nospell{HKEY_CURRENT_CONFIG} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
960 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
961 @item @nospell{HKCU} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
962 @itemx @nospell{HKEY_CURRENT_USER} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
963 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
964 @item @nospell{HKLM} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
965 @itemx @nospell{HKEY_LOCAL_MACHINE} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
966 |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
967 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
968 @item @nospell{HKU} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
969 @itemx @nospell{HKEY_USERS} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
970 |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
971 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
972 @item @nospell{HKEY_PERFORMANCE_DATA} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
973 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
974 @end table |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
975 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
976 Examples: |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
977 |
29117
10a35049bad7
doc: Cleanup Texinfo macros use in documentation.
Rik <rik@octave.org>
parents:
28930
diff
changeset
|
978 Get a list of value names at the key |
10a35049bad7
doc: Cleanup Texinfo macros use in documentation.
Rik <rik@octave.org>
parents:
28930
diff
changeset
|
979 @nospell{@qcode{'HKCU@backslashchar{}Environment'}}: |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
980 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
981 @example |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
982 @group |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
983 @var{valuenames} = winqueryreg ("name", "HKEY_CURRENT_USER", ... |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
984 "Environment"); |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
985 @end group |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
986 @end example |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
987 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
988 For each @var{valuenames}, display the value: |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
989 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
990 @example |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
991 @group |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
992 for @var{k} = 1:numel (@var{valuenames}) |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
993 @var{val} = winqueryreg ("HKEY_CURRENT_USER", "Environment", ... |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
994 @var{valuenames}@{@var{k}@}); |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
995 @var{str} = sprintf ("%s = %s", @var{valuenames}@{@var{k}@}, num2str (@var{val})); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
996 disp (@var{str}); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
997 endfor |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
998 @end group |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
999 @end example |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1000 |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1001 On non-Windows platforms this function fails with an error. |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1002 @end deftypefn */) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1003 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1004 #if defined (OCTAVE_USE_WINDOWS_API) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1005 if ((args.length () < 2) || (args.length () > 3)) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1006 print_usage (); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1007 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1008 // Input check |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
1009 std::string rootkey_name |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
1010 = args(0).xstring_value ("winqueryreg: the first argument must be 'name' " |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
1011 "or a valid ROOTKEY identifier"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1012 std::string subkey_name = ""; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1013 std::string value_name = ""; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1014 bool get_names = false; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1015 if (rootkey_name.compare ("name") == 0) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1016 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1017 if (args.length () < 3) |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1018 error ("winqueryreg: if the first argument is 'name', " |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
1019 "ROOTKEY and SUBKEY must be given"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1020 get_names = true; |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
1021 rootkey_name |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
1022 = args(1).xstring_value ("winqueryreg: ROOTKEY must be a string"); |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
1023 subkey_name |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
1024 = args(2).xstring_value ("winqueryreg: SUBKEY must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1025 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1026 else |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1027 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
1028 subkey_name |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
1029 = args(1).xstring_value ("winqueryreg: SUBKEY must be a string"); |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
1030 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1031 if (args.length () == 3) |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
1032 value_name |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
1033 = args(2).xstring_value ("winqueryreg: VALUENAME must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1034 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1035 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1036 // Get rootkey handle |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1037 HKEY h_rootkey; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1038 if (rootkey_name == "HKEY_CLASSES_ROOT" || rootkey_name == "HKCR") |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1039 h_rootkey = HKEY_CLASSES_ROOT; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1040 else if (rootkey_name == "HKEY_CURRENT_CONFIG") |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1041 h_rootkey = HKEY_CURRENT_CONFIG; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1042 else if (rootkey_name == "HKEY_CURRENT_USER" || rootkey_name == "HKCU") |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1043 h_rootkey = HKEY_CURRENT_USER; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1044 else if (rootkey_name == "HKEY_LOCAL_MACHINE" || rootkey_name == "HKLM") |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1045 h_rootkey = HKEY_LOCAL_MACHINE; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1046 else if (rootkey_name == "HKEY_PERFORMANCE_DATA") |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1047 h_rootkey = HKEY_PERFORMANCE_DATA; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1048 else if (rootkey_name == "HKEY_USERS" || rootkey_name == "HKU") |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1049 h_rootkey = HKEY_USERS; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1050 else |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1051 error ("winqueryreg: ROOTKEY is not a valid root key identifier"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1052 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1053 if (get_names) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1054 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1055 std::list<std::string> fields; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1056 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1057 LONG retval = get_regkey_names (h_rootkey, subkey_name, fields); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1058 if (retval != ERROR_SUCCESS) |
26162
ef1ef6364a6a
Silence compiler warnings about incorrect format specifiers cross-compiling (bug #55046).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26046
diff
changeset
|
1059 error ("winqueryreg: error %ld reading names from registry", retval); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1060 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1061 Cell fieldnames (dim_vector (1, fields.size ())); |
31803
e25bf4beb488
Replace various iterators with range-based loops (bug #63738)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31771
diff
changeset
|
1062 std::size_t i = 0; |
e25bf4beb488
Replace various iterators with range-based loops (bug #63738)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31771
diff
changeset
|
1063 for (const auto& it : fields) |
e25bf4beb488
Replace various iterators with range-based loops (bug #63738)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31771
diff
changeset
|
1064 fieldnames(i++) = it; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1065 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1066 return ovl (fieldnames); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1067 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1068 else |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1069 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1070 octave_value key_val; |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1071 LONG retval = get_regkey_value (h_rootkey, subkey_name, |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30265
diff
changeset
|
1072 value_name, key_val); |
24720
48f22c5b22aa
winqueryreg: Fix error on Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24714
diff
changeset
|
1073 if (retval == ERROR_FILE_NOT_FOUND) |
28905
89a425f2c202
maint: Use Octave convention that error() messages don't end with a period.
Rik <rik@octave.org>
parents:
28857
diff
changeset
|
1074 error ("winqueryreg: no value found for '%s' at %s\\%s", |
24720
48f22c5b22aa
winqueryreg: Fix error on Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24714
diff
changeset
|
1075 value_name.c_str (), rootkey_name.c_str (), |
48f22c5b22aa
winqueryreg: Fix error on Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24714
diff
changeset
|
1076 subkey_name.c_str ()); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1077 if (retval != ERROR_SUCCESS) |
26162
ef1ef6364a6a
Silence compiler warnings about incorrect format specifiers cross-compiling (bug #55046).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26046
diff
changeset
|
1078 error ("winqueryreg: error %ld reading the specified key", retval); |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1079 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1080 return ovl (key_val); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1081 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1082 #else |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1083 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1084 octave_unused_parameter (args); |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1085 |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1086 error ("winqueryreg: function is only supported on Windows platforms"); |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1087 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1088 #endif |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1089 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1090 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1091 /* |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1092 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1093 %! assert (ischar (winqueryreg ("HKEY_LOCAL_MACHINE", |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1094 %! 'SOFTWARE\Microsoft\Windows\CurrentVersion', |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1095 %! "ProgramFilesDir"))); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1096 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1097 %! assert (isa (winqueryreg ("HKEY_LOCAL_MACHINE", |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1098 %! 'SYSTEM\CurrentControlSet\Control\FileSystem', |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1099 %! "Win31FileSystem"), "int32")); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1100 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1101 %! assert (iscellstr (winqueryreg ("name", "HKEY_LOCAL_MACHINE", |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1102 %! 'SOFTWARE\Microsoft\Windows\CurrentVersion'))); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1103 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1104 %! fail ('winqueryreg (1, ''SOFTWARE\Microsoft\Windows\CurrentVersion'')', |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1105 %! "first argument must be 'name' or a valid ROOTKEY identifier"); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1106 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1107 %! fail ('winqueryreg ("HKEY_LOCAL_MACHINE", 1)', "SUBKEY must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1108 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1109 %! fail (['winqueryreg ("HKEY_LOCAL_MACHINE", ', ... |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1110 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'', 1)'], |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1111 %! "VALUENAME must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1112 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1113 %! fail (['winqueryreg ("FOO", ', ... |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1114 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'')'], |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1115 %! "ROOTKEY is not a valid root key identifier"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1116 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1117 %! fail ('winqueryreg ("HKEY_LOCAL_MACHINE", ''FOO\bar'')', |
24720
48f22c5b22aa
winqueryreg: Fix error on Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24714
diff
changeset
|
1118 %! "no value found for"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1119 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1120 %! fail (['winqueryreg ("HKEY_LOCAL_MACHINE", ', ... |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1121 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'', "foo")'], |
24720
48f22c5b22aa
winqueryreg: Fix error on Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24714
diff
changeset
|
1122 %! "no value found for"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1123 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1124 %! fail ('winqueryreg ("name", "HKEY_LOCAL_MACHINE")', |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1125 %! "if the first argument is 'name', ROOTKEY and SUBKEY must be given"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1126 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1127 %! fail (['winqueryreg ("name", 1, ', ... |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1128 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'')'], |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1129 %! "ROOTKEY must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1130 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1131 %! fail ('winqueryreg ("name", "HKEY_LOCAL_MACHINE", 1)', |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1132 %! "SUBKEY must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1133 */ |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1134 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1135 // FIXME: perhaps kbhit should also be able to print a prompt? |
3372 | 1136 |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27301
diff
changeset
|
1137 DEFMETHOD (kbhit, interp, args, , |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27301
diff
changeset
|
1138 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1139 @deftypefn {} {@var{c} =} kbhit () |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1140 @deftypefnx {} {@var{c} =} kbhit (1) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1141 Read a single keystroke from the keyboard. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1142 |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1143 If called with an argument (typically 1), don't wait for a keypress and |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1144 immediately return the next keystroke in the keyboard input buffer or an empty |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1145 string ("") if no keystroke is available. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1146 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1147 For example, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1148 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1149 @example |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1150 c = kbhit (); |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1151 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1152 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1153 @noindent |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1154 will set @var{c} to the next character typed at the keyboard as soon as it is |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1155 typed. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1156 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1157 @example |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1158 c = kbhit (1); |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1159 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1160 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1161 @noindent |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1162 is identical to the above example, but doesn't wait for a keypress, returning |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1163 the empty string if no key is available. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1164 @seealso{input, pause} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1165 @end deftypefn */) |
529 | 1166 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1167 // FIXME: add timeout and default value args? |
529 | 1168 |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27301
diff
changeset
|
1169 Fdrawnow (interp); |
6423 | 1170 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1171 int c = kbhit (args.length () == 0); |
3657 | 1172 |
25311
10ec5795bd06
allow kbhit to work in command-line scripts (bug #53412)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1173 if (c == -1) |
10ec5795bd06
allow kbhit to work in command-line scripts (bug #53412)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1174 c = 0; |
16015 | 1175 |
25311
10ec5795bd06
allow kbhit to work in command-line scripts (bug #53412)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1176 char s[2] = { static_cast<char> (c), '\0' }; |
529 | 1177 |
25311
10ec5795bd06
allow kbhit to work in command-line scripts (bug #53412)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1178 return octave_value (s); |
529 | 1179 } |
1180 | |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1181 // State of the pause system |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1182 static bool Vpause_enabled = true; |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1183 |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27301
diff
changeset
|
1184 DEFMETHOD (pause, interp, args, nargout, |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27301
diff
changeset
|
1185 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1186 @deftypefn {} {} pause () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1187 @deftypefnx {} {} pause (@var{n}) |
26046
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1188 @deftypefnx {} {@var{old_state} =} pause ("on") |
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1189 @deftypefnx {} {@var{old_state} =} pause ("off") |
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1190 @deftypefnx {} {@var{old_state} =} pause ("query") |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1191 Suspend the execution of the program or change the state of the pause function. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1192 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1193 If invoked without an input arguments then the program is suspended until a |
26046
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1194 character is typed. If argument @var{n} is a positive real value, it indicates |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1195 the number of seconds the program shall be suspended, for example: |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1196 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1197 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1198 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1199 tic; pause (0.05); toc |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1200 @print{} Elapsed time is 0.05039 seconds. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1201 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1202 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1203 |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1204 The following example prints a message and then waits 5 seconds before clearing |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1205 the screen. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1206 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1207 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1208 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1209 disp ("wait please..."); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1210 pause (5); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1211 clc; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1212 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1213 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1214 |
26046
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1215 If invoked with a string argument @qcode{"on"}, @qcode{"off"}, or |
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1216 @qcode{"query"}, the state of the pause function is changed or queried. When |
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1217 the state is @qcode{"off"}, the pause function returns immediately. The |
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1218 optional return value contains the previous state of the pause function. In |
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1219 the following example pause is disabled locally: |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1220 |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1221 @example |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1222 @group |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1223 old_state = pause ("off"); |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1224 tic; pause (0.05); toc |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1225 @print{} Elapsed time is 3.00407e-05 seconds. |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1226 pause (old_state); |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1227 @end group |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1228 @end example |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1229 |
26046
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1230 While the program is suspended Octave still handles figures painting and |
25961
f7b205562f1d
Allow graphics events to be processed while pause is active (bug #53729)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25916
diff
changeset
|
1231 graphics callbacks execution. |
f7b205562f1d
Allow graphics events to be processed while pause is active (bug #53729)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25916
diff
changeset
|
1232 |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1233 @seealso{kbhit} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1234 @end deftypefn */) |
529 | 1235 { |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1236 octave_value_list retval; |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1237 |
529 | 1238 int nargin = args.length (); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1239 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
1240 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
1241 print_usage (); |
529 | 1242 |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1243 if (nargin == 1 && args(0).is_string ()) |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1244 { |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1245 bool saved_state = Vpause_enabled; |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1246 std::string state = args(0).string_value (); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1247 |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1248 if (state == "on") |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1249 Vpause_enabled = true; |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1250 else if (state == "off") |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1251 Vpause_enabled = false; |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1252 else if (state == "query") |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1253 ;// Do nothing |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1254 else |
28752
810eb29fc227
maint: Use C++ raw string literals to simplify backlsashing.
Rik <rik@octave.org>
parents:
28371
diff
changeset
|
1255 error (R"(pause: first argument must be "on", "off", or "query")"); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1256 |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1257 if (nargout > 0 || state == "query") |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1258 retval.append (saved_state ? "on" : "off"); |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1259 } |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1260 else if (Vpause_enabled) |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1261 { |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1262 double dval; |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1263 |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1264 if (nargin == 0) |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1265 dval = octave_Inf; |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1266 else |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1267 dval = args(0).xdouble_value ("pause: N must be a scalar real value"); |
6419 | 1268 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1269 if (math::isnan (dval)) |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1270 warning ("pause: NaN is an invalid delay"); |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1271 else |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1272 { |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27301
diff
changeset
|
1273 Fdrawnow (interp); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1274 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1275 sleep (dval, true); |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1276 } |
3234 | 1277 } |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1278 |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1279 return retval; |
2630 | 1280 } |
1281 | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1282 /* |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1283 %!test |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1284 %! pause (1); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1285 |
28930
2883b3d08b7e
maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
1286 %!error pause (1, 2) |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1287 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1288 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1289 // FIXME: maybe this should only return 1 if IEEE floating |
862 | 1290 // point functions really work. |
1291 | |
1957 | 1292 DEFUN (isieee, , , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1293 doc: /* -*- texinfo -*- |
30559
841a10208c38
doc: Use TF for output variable in documentation for isXXX functions in libinterp/ directory.
Rik <rik@octave.org>
parents:
30390
diff
changeset
|
1294 @deftypefn {} {@var{tf} =} isieee () |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1295 Return true if your computer @emph{claims} to conform to the IEEE standard |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1296 for floating point calculations. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1297 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1298 No actual tests are performed. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1299 @end deftypefn */) |
862 | 1300 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1301 mach_info::float_format flt_fmt = mach_info::native_float_format (); |
2317 | 1302 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1303 return ovl (flt_fmt == mach_info::flt_fmt_ieee_little_endian |
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1304 || flt_fmt == mach_info::flt_fmt_ieee_big_endian); |
862 | 1305 } |
1306 | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1307 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1308 %!assert (islogical (isieee ())) |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1309 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1310 |
4600 | 1311 DEFUN (native_float_format, , , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1312 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1313 @deftypefn {} {@var{fmtstr} =} native_float_format () |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1314 Return the native floating point format as a string. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1315 @end deftypefn */) |
4600 | 1316 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1317 mach_info::float_format flt_fmt = mach_info::native_float_format (); |
4600 | 1318 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1319 return ovl (mach_info::float_format_as_string (flt_fmt)); |
4600 | 1320 } |
1321 | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1322 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1323 %!assert (ischar (native_float_format ())) |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1324 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1325 |
1957 | 1326 DEFUN (tilde_expand, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1327 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1328 @deftypefn {} {@var{newstr} =} tilde_expand (@var{string}) |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1329 @deftypefnx {} {@var{newcstr} =} tilde_expand (@var{cellstr}) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1330 Perform tilde expansion on @var{string}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1331 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1332 If @var{string} begins with a tilde character, (@samp{~}), all of the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1333 characters preceding the first slash (or all characters, if there is no |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1334 slash) are treated as a possible user name, and the tilde and the following |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1335 characters up to the slash are replaced by the home directory of the named |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1336 user. If the tilde is followed immediately by a slash, the tilde is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1337 replaced by the home directory of the user running Octave. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1338 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1339 If the input is a cell array of strings @var{cellstr} then tilde expansion |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1340 is performed on each string element. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1341 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1342 Examples: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1343 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1344 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1345 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1346 tilde_expand ("~joeuser/bin") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1347 @result{} "/home/joeuser/bin" |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1348 tilde_expand ("~/bin") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1349 @result{} "/home/jwe/bin" |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1350 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1351 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1352 @end deftypefn */) |
1750 | 1353 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
1354 if (args.length () != 1) |
5823 | 1355 print_usage (); |
1750 | 1356 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
1357 octave_value arg = args(0); |
6116 | 1358 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
1359 string_vector sv = |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
1360 arg.xstring_vector_value ("tilde_expand: argument must be char or cellstr object"); |
6116 | 1361 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1362 sv = sys::file_ops::tilde_expand (sv); |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
1363 |
23575
e95738a119da
maint: Deprecate is_cellstr and replace with iscellstr.
Rik <rik@octave.org>
parents:
23459
diff
changeset
|
1364 if (arg.iscellstr ()) |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1365 return ovl (Cell (arg.dims (), sv)); |
1750 | 1366 else |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1367 return ovl (sv); |
1750 | 1368 } |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1369 |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1370 /* |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1371 %!test |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1372 %! home = get_home_directory (); |
20064
ab7582167810
Fix failing BIST test for tilde_expand() on Windows (bug #44796).
Rik <rik@octave.org>
parents:
20024
diff
changeset
|
1373 %! assert (tilde_expand ("~/foobar"), [home "/foobar"]); |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1374 %! assert (tilde_expand ("/foo/bar"), "/foo/bar"); |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1375 %! assert (tilde_expand ("foo/bar"), "foo/bar"); |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1376 */ |
17851
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
1377 |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1378 DEFUN (get_home_directory, , , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1379 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1380 @deftypefn {} {@var{homedir} =} get_home_directory () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1381 Return the current home directory. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1382 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1383 On most systems, this is equivalent to @code{getenv ("HOME")}. On Windows |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1384 systems, if the environment variable @env{HOME} is not set then it is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1385 equivalent to |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1386 @code{fullfile (getenv ("HOMEDRIVE"), getenv ("HOMEPATH"))} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1387 @seealso{getenv} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1388 @end deftypefn */) |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1389 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1390 return ovl (sys::env::get_home_directory ()); |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1391 } |
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1392 |
20024
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1393 /* |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1394 %!test |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1395 %! if (! ispc ()) |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20172
diff
changeset
|
1396 %! assert (get_home_directory (), getenv ("HOME")); |
20024
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1397 %! endif |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1398 */ |
24714
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1399 |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1400 DEFUN (__blas_version__, , , |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1401 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1402 @deftypefn {} {@var{verstr} =} __blas_version__ () |
24714
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1403 Undocumented internal function. |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1404 @end deftypefn */) |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1405 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1406 return ovl (sys::blas_version ()); |
24714
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1407 } |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1408 |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1409 DEFUN (__lapack_version__, , , |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1410 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30632
diff
changeset
|
1411 @deftypefn {} {@var{verstr} =} __lapack_version__ () |
24714
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1412 Undocumented internal function. |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1413 @end deftypefn */) |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1414 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1415 return ovl (sys::lapack_version ()); |
24714
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1416 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
1417 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
1418 OCTAVE_END_NAMESPACE(octave) |