Mercurial > octave
annotate libinterp/corefcn/sysdep.cc @ 26844:d8712d26d086
Fix error in previous commit.
* sysdep.cc (drive_or_unc_share): Make sure to match entire input string.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 05 Mar 2019 23:26:05 +0100 |
parents | f07542e3a9b9 |
children | ab5bfee22d18 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26162
diff
changeset
|
3 Copyright (C) 1993-2019 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24442
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24442
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
10 (at your option) any later version. |
1 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22417
diff
changeset
|
15 GNU General Public License for more details. |
1 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24442
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
1 | 20 |
21 */ | |
22 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21662
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
24 # include "config.h" |
1 | 25 #endif |
26 | |
23662
bd77ab816e43
eliminate obsolete file lo-math.h
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
27 #include <cmath> |
1343 | 28 #include <cstddef> |
29 | |
3503 | 30 #include <iostream> |
1728 | 31 #include <string> |
32 | |
1430 | 33 #if defined (HAVE_TERMIOS_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
34 # include <termios.h> |
1430 | 35 #elif defined (HAVE_TERMIO_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
36 # include <termio.h> |
1430 | 37 #elif defined (HAVE_SGTTY_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
38 # include <sgtty.h> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
39 #endif |
4067 | 40 |
41 #if defined (HAVE_CONIO_H) | |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
42 # include <conio.h> |
1430 | 43 #endif |
44 | |
3248 | 45 #if defined (HAVE_SYS_IOCTL_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
46 # include <sys/ioctl.h> |
3248 | 47 #endif |
48 | |
1463 | 49 #if defined (HAVE_FLOATINGPOINT_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
50 # include <floatingpoint.h> |
1463 | 51 #endif |
52 | |
2508 | 53 #if defined (HAVE_IEEEFP_H) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
54 # include <ieeefp.h> |
2508 | 55 #endif |
56 | |
21554
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
57 #if defined (HAVE_OMP_H) |
21556 | 58 # include <omp.h> |
21554
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
59 #endif |
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
60 |
2926 | 61 #include "cmd-edit.h" |
62 #include "file-ops.h" | |
2893 | 63 #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
|
64 #include "lo-sysinfo.h" |
2317 | 65 #include "mach-info.h" |
2926 | 66 #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
|
67 #include "uniconv-wrappers.h" |
21910
4d723ba06b4a
provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
68 #include "unistd-wrappers.h" |
1769 | 69 |
22097
5ad67277b007
include builtin-defun-decls.h as needed
John W. Eaton <jwe@octave.org>
parents:
22096
diff
changeset
|
70 #include "builtin-defun-decls.h" |
6208 | 71 #include "Cell.h" |
1352 | 72 #include "defun.h" |
73 #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
|
74 #include "errwarn.h" |
529 | 75 #include "input.h" |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
76 #include "octave.h" |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
77 #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
|
78 #include "ovl.h" |
3234 | 79 #include "pager.h" |
6419 | 80 #include "parse.h" |
5770 | 81 #include "sighandlers.h" |
1352 | 82 #include "sysdep.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
83 #include "interpreter.h" |
529 | 84 #include "utils.h" |
6598 | 85 #include "file-stat.h" |
529 | 86 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21662
diff
changeset
|
87 #if ! defined (STDIN_FILENO) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
88 # define STDIN_FILENO 1 |
529 | 89 #endif |
444 | 90 |
9441
160c564d5d25
initialize floating point values properly for NetBSD systems
Aleksej Saushev <asau@inbox.ru>
parents:
9411
diff
changeset
|
91 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__) |
2508 | 92 static void |
93 BSD_init (void) | |
94 { | |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
95 # if defined (HAVE_FLOATINGPOINT_H) |
2508 | 96 // Disable trapping on common exceptions. |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21662
diff
changeset
|
97 # if ! defined (FP_X_DNML) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
98 # define FP_X_DNML 0 |
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
99 # endif |
2508 | 100 fpsetmask (~(FP_X_OFL|FP_X_INV|FP_X_DZ|FP_X_DNML|FP_X_UFL|FP_X_IMP)); |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21115
diff
changeset
|
101 # endif |
2508 | 102 } |
103 #endif | |
104 | |
22019
2d8e9bdf5683
Dont use OCTAVE_USE_WINDOWS_API for w32_XXXX function definitions (Bug #48352)
John Donoghue
parents:
21989
diff
changeset
|
105 #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
|
106 |
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
107 #define WIN32_LEAN_AND_MEAN |
21949
baeffde5c87d
fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents:
21910
diff
changeset
|
108 #include <windows.h> |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
109 #include <tlhelp32.h> |
21949
baeffde5c87d
fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents:
21910
diff
changeset
|
110 #include <shellapi.h> |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
111 |
6080 | 112 static void |
113 w32_set_octave_home (void) | |
114 { | |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
115 std::string bin_dir; |
6080 | 116 |
13885
2f42a7b0cf94
Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13771
diff
changeset
|
117 HANDLE h = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21662
diff
changeset
|
118 #if defined (TH32CS_SNAPMODULE32) |
13885
2f42a7b0cf94
Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13771
diff
changeset
|
119 | TH32CS_SNAPMODULE32 |
2f42a7b0cf94
Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13771
diff
changeset
|
120 #endif |
2f42a7b0cf94
Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13771
diff
changeset
|
121 , 0); |
6080 | 122 |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
123 if (h != INVALID_HANDLE_VALUE) |
6080 | 124 { |
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
|
125 MODULEENTRY32W mod_info; |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
126 |
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
127 ZeroMemory (&mod_info, sizeof (mod_info)); |
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
128 mod_info.dwSize = sizeof (mod_info); |
13751
be7ff59cbc7a
Fix octinterp DLL searching on Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13282
diff
changeset
|
129 |
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
|
130 if (Module32FirstW (h, &mod_info)) |
14445 | 131 { |
132 do | |
133 { | |
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
|
134 std::string mod_name (octave::sys::u8_from_wstring (mod_info.szModule)); |
6080 | 135 |
14445 | 136 if (mod_name.find ("octinterp") != std::string::npos) |
137 { | |
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
|
138 bin_dir = octave::sys::u8_from_wstring (mod_info.szExePath); |
23812
057a894914df
Use C++11 string fcns back() and pop_back() to simplify code.
Rik <rik@octave.org>
parents:
23809
diff
changeset
|
139 if (! bin_dir.empty () && bin_dir.back () != '\\') |
057a894914df
Use C++11 string fcns back() and pop_back() to simplify code.
Rik <rik@octave.org>
parents:
23809
diff
changeset
|
140 bin_dir.push_back ('\\'); |
14445 | 141 break; |
142 } | |
143 } | |
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
|
144 while (Module32NextW (h, &mod_info)); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
145 } |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
146 |
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
147 CloseHandle (h); |
6080 | 148 } |
149 | |
150 if (! bin_dir.empty ()) | |
151 { | |
23804
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23746
diff
changeset
|
152 size_t pos = bin_dir.rfind (R"(\bin\)"); |
6080 | 153 |
8021 | 154 if (pos != std::string::npos) |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
155 octave::sys::env::putenv ("OCTAVE_HOME", bin_dir.substr (0, pos)); |
6080 | 156 } |
157 } | |
158 | |
19302
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
159 static void |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
160 w32_init (void) |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
161 { |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
162 w32_set_octave_home (); |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
163 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
164 octave::command_editor::prefer_env_winsize (true); |
19302
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
165 } |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
166 |
5451 | 167 #endif |
168 | |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
169 namespace octave |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
170 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
171 // Set app id if we have the SetCurrentProcessExplicitAppUserModelID |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
172 // available (>= Win7). FIXME: Could we check for existence of this |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
173 // function in the configure script instead of dynamically loading |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
174 // shell32.dll? |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
175 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
176 void set_application_id (void) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
177 { |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
178 #if defined (__MINGW32__) || defined (_MSC_VER) |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
179 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
180 typedef HRESULT (WINAPI *SETCURRENTAPPID)(PCWSTR AppID); |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
181 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
182 HMODULE hShell = LoadLibrary ("shell32.dll"); |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
183 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
184 if (hShell) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
185 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
186 SETCURRENTAPPID pfnSetCurrentProcessExplicitAppUserModelID = |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
187 reinterpret_cast<SETCURRENTAPPID> (GetProcAddress (hShell, |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
188 "SetCurrentProcessExplicitAppUserModelID")); |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
189 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
190 if (pfnSetCurrentProcessExplicitAppUserModelID) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
191 pfnSetCurrentProcessExplicitAppUserModelID (L"gnu.octave." VERSION); |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
192 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
193 FreeLibrary (hShell); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
194 } |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
195 |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
196 #endif |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
197 } |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
198 } |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
199 |
19856
5c1a38089f89
Change open_with_system_app to internal function.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
200 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
|
201 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
|
202 @deftypefn {} {} __open_with_system_app__ (@var{file}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
203 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
204 @end deftypefn */) |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
205 { |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
206 if (args.length () != 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
207 print_usage (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
208 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
209 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
|
210 |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
211 octave_value retval; |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
212 |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
213 #if defined (OCTAVE_USE_WINDOWS_API) |
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
|
214 HINSTANCE status = ShellExecuteW (0, 0, |
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
215 octave::sys::u8_to_wstring (file).c_str (), |
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
216 0, 0, SW_SHOWNORMAL); |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
217 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
218 // ShellExecute returns a value greater than 32 if successful. |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
219 retval = (reinterpret_cast<ptrdiff_t> (status) > 32); |
20961
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
220 #elif defined (__APPLE__) |
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
221 octave_value_list tmp |
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
222 = Fsystem (ovl ("open " + file + " 2> /dev/null", |
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
223 false, "async"), |
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
224 1); |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
225 |
20961
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
226 retval = (tmp(0).double_value () == 0); |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
227 #else |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
228 octave_value_list tmp |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
229 = Fsystem (ovl ("xdg-open " + file + " 2> /dev/null", |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
230 false, "async"), |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
231 1); |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
232 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
233 retval = (tmp(0).double_value () == 0); |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
234 #endif |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
235 |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
236 return retval; |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
237 } |
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
238 |
5451 | 239 #if defined (__MINGW32__) |
240 static void | |
241 MINGW_init (void) | |
242 { | |
19302
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
243 w32_init (); |
5451 | 244 } |
245 #endif | |
246 | |
6080 | 247 #if defined (_MSC_VER) |
248 static void | |
249 MSVC_init (void) | |
250 { | |
19302
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
251 w32_init (); |
6080 | 252 } |
253 #endif | |
254 | |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
255 namespace octave |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
256 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
257 // Return TRUE if FILE1 and FILE2 refer to the same (physical) file. |
6598 | 258 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
259 bool same_file_internal (const std::string& file1, const std::string& file2) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
260 { |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21662
diff
changeset
|
261 #if defined (OCTAVE_USE_WINDOWS_API) |
6598 | 262 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
263 bool retval = false; |
6691 | 264 |
25714
ad0b4817c09d
Fix lifetime issue with C string references from C++ strings (bug #54398)
Markus Mützel <markus.muetzel@gmx.de>
parents:
25655
diff
changeset
|
265 std::wstring file1w = octave::sys::u8_to_wstring (file1); |
ad0b4817c09d
Fix lifetime issue with C string references from C++ strings (bug #54398)
Markus Mützel <markus.muetzel@gmx.de>
parents:
25655
diff
changeset
|
266 std::wstring file2w = octave::sys::u8_to_wstring (file2); |
ad0b4817c09d
Fix lifetime issue with C string references from C++ strings (bug #54398)
Markus Mützel <markus.muetzel@gmx.de>
parents:
25655
diff
changeset
|
267 const wchar_t *f1 = file1w.c_str (); |
ad0b4817c09d
Fix lifetime issue with C string references from C++ strings (bug #54398)
Markus Mützel <markus.muetzel@gmx.de>
parents:
25655
diff
changeset
|
268 const wchar_t *f2 = file2w.c_str (); |
16564
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
269 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
270 bool f1_is_dir = GetFileAttributesW (f1) & FILE_ATTRIBUTE_DIRECTORY; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
271 bool f2_is_dir = GetFileAttributesW (f2) & FILE_ATTRIBUTE_DIRECTORY; |
16564
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
272 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
273 // Windows native code |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
274 // Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx |
6598 | 275 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
276 DWORD share = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE; |
16564
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
277 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
278 HANDLE hfile1 |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
279 = CreateFileW (f1, 0, share, 0, OPEN_EXISTING, |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
280 f1_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0); |
6691 | 281 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
282 if (hfile1 != INVALID_HANDLE_VALUE) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
283 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
284 HANDLE hfile2 |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
285 = CreateFileW (f2, 0, share, 0, OPEN_EXISTING, |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
286 f2_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0); |
6598 | 287 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
288 if (hfile2 != INVALID_HANDLE_VALUE) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
289 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
290 BY_HANDLE_FILE_INFORMATION hfi1; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
291 BY_HANDLE_FILE_INFORMATION hfi2; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
292 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
293 if (GetFileInformationByHandle (hfile1, &hfi1) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
294 && GetFileInformationByHandle (hfile2, &hfi2)) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
295 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
296 retval = (hfi1.dwVolumeSerialNumber == hfi2.dwVolumeSerialNumber |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
297 && hfi1.nFileIndexHigh == hfi2.nFileIndexHigh |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
298 && hfi1.nFileIndexLow == hfi2.nFileIndexLow); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
299 } |
6598 | 300 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
301 CloseHandle (hfile2); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
302 } |
6691 | 303 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
304 CloseHandle (hfile1); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
305 } |
6691 | 306 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
307 return retval; |
6598 | 308 |
309 #else | |
310 | |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
311 // POSIX Code |
6598 | 312 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
313 octave::sys::file_stat fs_file1 (file1); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
314 octave::sys::file_stat fs_file2 (file2); |
6598 | 315 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
316 return (fs_file1 && fs_file2 |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
317 && fs_file1.ino () == fs_file2.ino () |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
318 && fs_file1.dev () == fs_file2.dev ()); |
6598 | 319 |
320 #endif | |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
321 } |
6598 | 322 |
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
|
323 // Return TRUE if NAME refers to an existing drive letter or UNC share |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
324 |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
325 bool drive_or_unc_share (const std::string& name) |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
326 { |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
327 #if defined (OCTAVE_USE_WINDOWS_API) |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
328 size_t len = name.length (); |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
329 bool candidate = false; |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
330 if (len > 1 && isalpha(name[0]) && name[1]==':' |
26844
d8712d26d086
Fix error in previous commit.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26843
diff
changeset
|
331 && (len == 2 || (len == 3 && name[2] == '\\'))) |
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
|
332 candidate = true; |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
333 if (len > 4 && name[0] == '\\' && name[1] == '\\') |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
334 { |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
335 // It starts with two slashes. Find the next slash. |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
336 size_t next_slash = name.find ("\\", 3); |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
337 if (next_slash != -1 && len > next_slash+1) |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
338 { |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
339 // Check if it ends with the share |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
340 size_t last_slash = name.find ("\\", next_slash+1); |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
341 if (last_slash == -1 || |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
342 (len > next_slash+2 && last_slash == len-1)) |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
343 candidate = true; |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
344 } |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
345 } |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
346 |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
347 if (candidate) |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
348 { |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
349 // Open a handle to the file. |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
350 std::wstring wname = octave::sys::u8_to_wstring (name); |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
351 HANDLE h = |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
352 CreateFileW (wname.c_str (), FILE_READ_ATTRIBUTES, |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
353 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
354 nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
355 nullptr); |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
356 if (h != INVALID_HANDLE_VALUE) |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
357 { |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
358 CloseHandle (h); |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
359 return true; |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
360 } |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
361 } |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
362 |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
363 return false; |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
364 |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
365 #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
|
366 |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
367 octave_unused_parameter (name); |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
368 |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
369 return false; |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
370 |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
371 #endif |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
372 } |
f07542e3a9b9
Fix "exist" for drive letters and UNC shares on Windows (bug #55824).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26617
diff
changeset
|
373 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
374 void sysdep_init (void) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
375 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
376 // Use a function from libgomp to force loading of OpenMP library. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
377 // Otherwise, a dynamically loaded library making use of OpenMP such |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
378 // 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
|
379 #if defined (HAVE_OMP_GET_NUM_THREADS) |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
380 omp_get_num_threads (); |
21554
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
381 #endif |
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
382 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14445
diff
changeset
|
383 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__) |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
384 BSD_init (); |
5451 | 385 #elif defined (__MINGW32__) |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
386 MINGW_init (); |
6080 | 387 #elif defined (_MSC_VER) |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
388 MSVC_init (); |
1 | 389 #endif |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
390 } |
1 | 391 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
392 void sysdep_cleanup (void) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
393 { |
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
|
394 #if defined (OCTAVE_USE_WINDOWS_API) |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
395 // Let us fail immediately without displaying any dialog. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
396 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
|
397 #endif |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
398 } |
5451 | 399 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
400 // Set terminal in raw mode. From less-177. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
401 // |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
402 // Change terminal to "raw mode", or restore to "normal" mode. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
403 // "Raw mode" means |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
404 // 1. An outstanding read will complete on receipt of a single keystroke. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
405 // 2. Input is not echoed. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
406 // 3. On output, \n is mapped to \r\n. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
407 // 4. \t is NOT expanded into spaces. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
408 // 5. Signal-causing characters such as ctrl-C (interrupt), |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
409 // etc. are NOT disabled. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
410 // It doesn't matter whether an input \n is mapped to \r, or vice versa. |
767 | 411 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
412 void raw_mode (bool on, bool wait) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
413 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
414 static bool curr_on = false; |
529 | 415 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
416 int tty_fd = STDIN_FILENO; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
417 if (! octave_isatty_wrapper (tty_fd)) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
418 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
419 if (octave::application::interactive () |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
420 && ! octave::application::forced_interactive ()) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
421 error ("stdin is not a tty!"); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
422 } |
529 | 423 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
424 if (on == curr_on) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
425 return; |
529 | 426 |
427 #if defined (HAVE_TERMIOS_H) | |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
428 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
429 struct termios s; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
430 static struct termios save_term; |
529 | 431 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
432 if (on) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
433 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
434 // Get terminal modes. |
529 | 435 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
436 tcgetattr (tty_fd, &s); |
529 | 437 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
438 // Save modes and set certain variables dependent on modes. |
529 | 439 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
440 save_term = s; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
441 // ospeed = s.c_cflag & CBAUD; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
442 // erase_char = s.c_cc[VERASE]; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
443 // kill_char = s.c_cc[VKILL]; |
529 | 444 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
445 // Set the modes to the way we want them. |
529 | 446 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
447 s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
448 s.c_oflag |= (OPOST | ONLCR); |
529 | 449 #if defined (OCRNL) |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
450 s.c_oflag &= ~(OCRNL); |
529 | 451 #endif |
452 #if defined (ONOCR) | |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
453 s.c_oflag &= ~(ONOCR); |
529 | 454 #endif |
455 #if defined (ONLRET) | |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
456 s.c_oflag &= ~(ONLRET); |
529 | 457 #endif |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
458 s.c_cc[VMIN] = (wait ? 1 : 0); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
459 s.c_cc[VTIME] = 0; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
460 } |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
461 else |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
462 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
463 // Restore saved modes. |
1358 | 464 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
465 s = save_term; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
466 } |
3658 | 467 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
468 tcsetattr (tty_fd, wait ? TCSAFLUSH : TCSADRAIN, &s); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
469 } |
529 | 470 #elif defined (HAVE_TERMIO_H) |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
471 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
472 struct termio s; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
473 static struct termio save_term; |
529 | 474 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
475 if (on) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
476 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
477 // Get terminal modes. |
529 | 478 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
479 ioctl (tty_fd, TCGETA, &s); |
529 | 480 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
481 // Save modes and set certain variables dependent on modes. |
529 | 482 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
483 save_term = s; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
484 // ospeed = s.c_cflag & CBAUD; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
485 // erase_char = s.c_cc[VERASE]; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
486 // kill_char = s.c_cc[VKILL]; |
529 | 487 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
488 // Set the modes to the way we want them. |
529 | 489 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
490 s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
491 s.c_oflag |= (OPOST | ONLCR); |
529 | 492 #if defined (OCRNL) |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
493 s.c_oflag &= ~(OCRNL); |
529 | 494 #endif |
495 #if defined (ONOCR) | |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
496 s.c_oflag &= ~(ONOCR); |
529 | 497 #endif |
498 #if defined (ONLRET) | |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
499 s.c_oflag &= ~(ONLRET); |
529 | 500 #endif |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
501 s.c_cc[VMIN] = (wait ? 1 : 0); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
502 } |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
503 else |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
504 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
505 // Restore saved modes. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
506 |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
507 s = save_term; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
508 } |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
509 |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
510 ioctl (tty_fd, TCSETAW, &s); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
511 } |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
512 #elif defined (HAVE_SGTTY_H) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
513 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
514 octave_unused_parameter (wait); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
515 |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
516 struct sgttyb s; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
517 static struct sgttyb save_term; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
518 |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
519 if (on) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
520 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
521 // Get terminal modes. |
1358 | 522 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
523 ioctl (tty_fd, TIOCGETP, &s); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
524 |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
525 // Save modes and set certain variables dependent on modes. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
526 |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
527 save_term = s; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
528 // ospeed = s.sg_ospeed; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
529 // erase_char = s.sg_erase; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
530 // kill_char = s.sg_kill; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
531 |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
532 // Set the modes to the way we want them. |
3658 | 533 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
534 s.sg_flags |= CBREAK; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
535 s.sg_flags &= ~(ECHO); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
536 } |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
537 else |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
538 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
539 // Restore saved modes. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
540 |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
541 s = save_term; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
542 } |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
543 |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
544 ioctl (tty_fd, TIOCSETN, &s); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
545 } |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
546 #else |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
547 |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23812
diff
changeset
|
548 octave_unused_parameter (wait); |
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23812
diff
changeset
|
549 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
550 warn_disabled_feature ("", "raw mode console I/O"); |
529 | 551 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
552 // Make sure the current mode doesn't toggle. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
553 on = curr_on; |
529 | 554 #endif |
555 | |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
556 curr_on = on; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
557 } |
529 | 558 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
559 FILE * popen (const char *command, const char *mode) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
560 { |
6726 | 561 #if defined (__MINGW32__) || defined (_MSC_VER) |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
562 wchar_t *wcommand = u8_to_wchar (command); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
563 wchar_t *wmode = u8_to_wchar (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
|
564 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
565 octave::unwind_protect frame; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
566 frame.add_fcn (::free, static_cast<void *> (wcommand)); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
567 frame.add_fcn (::free, static_cast<void *> (wmode)); |
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
|
568 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
569 if (wmode && wmode[0] && ! wmode[1]) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
570 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
571 // Use binary mode on Windows if unspecified |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
572 wchar_t tmode[3] = {wmode[0], L'b', L'\0'}; |
6726 | 573 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
574 return _wpopen (wcommand, tmode); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
575 } |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
576 else |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
577 return _wpopen (wcommand, wmode); |
6726 | 578 #else |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
579 return ::popen (command, mode); |
6726 | 580 #endif |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
581 } |
6726 | 582 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
583 int pclose (FILE *f) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
584 { |
6726 | 585 #if defined (__MINGW32__) || defined (_MSC_VER) |
25655
be7ba25bb5bf
Fix Windows cross-build after 85c3e315bd43.
Markus Mützel <markus.muetzel@gmx.de>
parents:
25649
diff
changeset
|
586 return ::_pclose (f); |
6726 | 587 #else |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
588 return ::pclose (f); |
6726 | 589 #endif |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
590 } |
6726 | 591 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
592 // Read one character from the terminal. |
767 | 593 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
594 int kbhit (bool wait) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
595 { |
20788
a2b96b523472
Rewrite a8ee668e7fd7 to use #if defined rather than #ifdef.
Rik <rik@octave.org>
parents:
20786
diff
changeset
|
596 #if defined (HAVE__KBHIT) && defined (HAVE__GETCH) |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
597 // This essentially means we are on a Windows system. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
598 int c; |
20786
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
599 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
600 if (wait) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
601 c = _getch (); |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
602 else |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
603 c = (! _kbhit ()) ? 0 : _getch (); |
20786
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
604 |
4067 | 605 #else |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
606 raw_mode (true, wait); |
3658 | 607 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
608 // Get current handler. |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
609 octave::interrupt_handler saved_interrupt_handler |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
610 = octave::ignore_interrupts (); |
5770 | 611 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
612 // Restore it, disabling system call restarts (if possible) so the |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
613 // read can be interrupted. |
5770 | 614 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
615 octave::set_interrupt_handler (saved_interrupt_handler, false); |
5770 | 616 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
617 int c = std::cin.get (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
618 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
619 if (std::cin.fail () || std::cin.eof ()) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
620 std::cin.clear (); |
3658 | 621 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
622 // Restore it, enabling system call restarts (if possible). |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
623 octave::set_interrupt_handler (saved_interrupt_handler, true); |
5770 | 624 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
625 raw_mode (false, true); |
4067 | 626 #endif |
3658 | 627 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
628 return c; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
629 } |
529 | 630 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
631 std::string get_P_tmpdir (void) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
632 { |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
633 #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
|
634 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
635 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
|
636 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
637 #if defined (P_tmpdir) |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
638 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
|
639 #endif |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
640 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
641 // Apparently some versions of MinGW and MSVC either don't define |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
642 // P_tmpdir, or they define it to a single backslash, neither of which |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
643 // 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
|
644 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
645 if (retval.empty () || retval == R"(\)") |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
646 { |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
647 retval = octave::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
|
648 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
649 if (retval.empty ()) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
650 retval = octave::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
|
651 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
652 if (retval.empty ()) |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
653 retval = R"(c:\temp)"; |
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
654 } |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
655 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
656 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
|
657 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
658 #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
|
659 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
660 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
|
661 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
662 #else |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
663 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
664 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
|
665 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
666 #endif |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
667 } |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
668 } |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
669 |
1957 | 670 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
|
671 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
|
672 @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
|
673 @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
|
674 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
|
675 @end deftypefn */) |
529 | 676 { |
16537
106a38d7b396
optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents:
16404
diff
changeset
|
677 bool skip_redisplay = true; |
106a38d7b396
optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents:
16404
diff
changeset
|
678 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
679 octave::command_editor::clear_screen (skip_redisplay); |
529 | 680 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
681 return ovl (); |
529 | 682 } |
683 | |
549 | 684 DEFALIAS (home, clc); |
685 | |
1957 | 686 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
|
687 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
|
688 @deftypefn {} {} getenv (@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
|
689 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
|
690 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
691 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
|
692 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
693 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
694 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
|
695 @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
|
696 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
697 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
698 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
|
699 @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
|
700 @end deftypefn */) |
529 | 701 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
702 if (args.length () != 1) |
5823 | 703 print_usage (); |
529 | 704 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
705 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
|
706 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
707 return ovl (octave::sys::env::getenv (name)); |
529 | 708 } |
709 | |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
710 /* |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
711 %!assert (ischar (getenv ("OCTAVE_HOME"))) |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
712 */ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
713 |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
714 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
|
715 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
|
716 @deftypefn {} {} setenv (@var{var}, @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
|
717 @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
|
718 @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
|
719 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
|
720 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
721 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
|
722 string. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
723 @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
|
724 @end deftypefn */) |
1706 | 725 { |
726 int nargin = args.length (); | |
727 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
728 if (nargin < 1 || nargin > 2) |
5823 | 729 print_usage (); |
1706 | 730 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
731 std::string var = args(0).xstring_value ("setenv: VAR must be a string"); |
1706 | 732 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
733 std::string val = (nargin == 2 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
734 ? 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
|
735 : ""); |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
736 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
737 octave::sys::env::putenv (var, val); |
1706 | 738 |
21078
49852ff04747
maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
739 return ovl (); |
1706 | 740 } |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
741 |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
742 DEFALIAS (putenv, setenv); |
1706 | 743 |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
744 /* |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
745 %!test |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
746 %! 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
|
747 %! 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
|
748 %! unsetenv ("dummy_variable_that_cannot_matter"); |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
749 %! assert (getenv ("dummy_variable_that_cannot_matter"), ""); |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
750 */ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
751 |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
752 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
|
753 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
|
754 @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
|
755 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
|
756 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
757 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
|
758 occurred. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
759 @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
|
760 @end deftypefn */) |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
761 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
762 if (args.length () != 1) |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
763 print_usage (); |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
764 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
765 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
|
766 |
25916
3f2282954600
Support non-ASCII characters in environment variables on Windows (bug #53922).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25714
diff
changeset
|
767 return ovl (octave::sys::unsetenv_wrapper (tmp)); |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
768 } |
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 /* |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
771 ## 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
|
772 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
773 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
774 #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
|
775 |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
776 static void |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
777 reg_close_key_wrapper (HKEY key) |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
778 { |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
779 RegCloseKey (key); |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
780 } |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
781 |
25655
be7ba25bb5bf
Fix Windows cross-build after 85c3e315bd43.
Markus Mützel <markus.muetzel@gmx.de>
parents:
25649
diff
changeset
|
782 LONG |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
783 get_regkey_value (HKEY h_rootkey, const std::string subkey, |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
784 const std::string name, octave_value& value) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
785 { |
24702
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
786 LONG result; |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
787 HKEY h_subkey; |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
788 |
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
|
789 result = RegOpenKeyExW (h_rootkey, |
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
790 octave::sys::u8_to_wstring (subkey).c_str (), 0, |
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
791 KEY_READ, &h_subkey); |
24702
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
792 if (result != ERROR_SUCCESS) |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
793 return result; |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
794 |
24710
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
795 octave::unwind_protect frame; |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
796 |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
797 frame.add_fcn (reg_close_key_wrapper, h_subkey); |
24709
6a6108db3a6b
winqueryreg: Close registry key after use (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24702
diff
changeset
|
798 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
799 DWORD length = 0; |
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
|
800 result = RegQueryValueExW (h_subkey, |
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
801 octave::sys::u8_to_wstring (name).c_str (), |
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
802 nullptr, nullptr, nullptr, &length); |
24702
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
803 if (result != ERROR_SUCCESS) |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
804 return result; |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
805 |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
806 DWORD type = 0; |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
807 OCTAVE_LOCAL_BUFFER (BYTE, data, length); |
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
|
808 result = RegQueryValueExW (h_subkey, |
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
809 octave::sys::u8_to_wstring (name).c_str (), |
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
810 nullptr, &type, data, &length); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
811 if (result != ERROR_SUCCESS) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
812 return result; |
24691
b658e0fa0cb3
maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents:
24682
diff
changeset
|
813 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
814 if (type == REG_DWORD) |
24702
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
815 value = octave_int32 (*data); |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
816 else if (type == REG_SZ || type == REG_EXPAND_SZ) |
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
|
817 value = string_vector (octave::sys::u8_from_wstring ( |
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
818 reinterpret_cast<wchar_t *> (data))); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
819 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
820 return result; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
821 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
822 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
823 static LONG |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
824 get_regkey_names (HKEY h_rootkey, const std::string subkey, |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
825 std::list<std::string> &fields) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
826 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
827 LONG retval; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
828 HKEY h_subkey; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
829 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
830 fields.clear (); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
831 |
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
|
832 retval = RegOpenKeyExW (h_rootkey, |
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
833 octave::sys::u8_to_wstring (subkey).c_str (), 0, |
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
834 KEY_READ, &h_subkey); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
835 if (retval != ERROR_SUCCESS) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
836 return retval; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
837 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
838 DWORD idx = 0; |
24720
48f22c5b22aa
winqueryreg: Fix error on Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24714
diff
changeset
|
839 const int MAX_VALUE_NAME_SIZE = 32766; |
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
|
840 wchar_t value_name[MAX_VALUE_NAME_SIZE+1]; |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
841 DWORD value_name_size = MAX_VALUE_NAME_SIZE; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
842 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
843 while (true) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
844 { |
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
|
845 retval = RegEnumValueW (h_subkey, idx, value_name, &value_name_size, |
197126863d95
sysdep.cc: Use wide character versions of Windows API functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25311
diff
changeset
|
846 nullptr, nullptr, nullptr, nullptr); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
847 if (retval != ERROR_SUCCESS) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
848 break; |
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
|
849 fields.push_back (octave::sys::u8_from_wstring (value_name)); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
850 value_name_size = MAX_VALUE_NAME_SIZE; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
851 idx++; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
852 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
853 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
854 if (retval == ERROR_NO_MORE_ITEMS) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
855 retval = ERROR_SUCCESS; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
856 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
857 RegCloseKey (h_subkey); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
858 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
859 return retval; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
860 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
861 #endif |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
862 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
863 DEFUN (winqueryreg, args, , |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
864 doc: /* -*- texinfo -*- |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
865 @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
|
866 @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
|
867 @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
|
868 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
869 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
|
870 |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
871 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
|
872 @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
|
873 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
|
874 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
|
875 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
|
876 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
|
877 @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
|
878 returned. |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
879 |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
880 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
|
881 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
|
882 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
883 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
|
884 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
885 @table @asis |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
886 @item @nospell{HKCR} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
887 @itemx @nospell{HKEY_CLASSES_ROOT} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
888 |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
889 @item @nospell{HKEY_CURRENT_CONFIG} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
890 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
891 @item @nospell{HKCU} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
892 @itemx @nospell{HKEY_CURRENT_USER} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
893 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
894 @item @nospell{HKLM} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
895 @itemx @nospell{HKEY_LOCAL_MACHINE} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
896 |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
897 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
898 @item @nospell{HKU} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
899 @itemx @nospell{HKEY_USERS} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
900 |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
901 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
902 @item @nospell{HKEY_PERFORMANCE_DATA} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
903 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
904 @end table |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
905 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
906 Examples: |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
907 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
908 Get a list of value names at the key @nospell{@qcode{'HKCU\Environment'}}: |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
909 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
910 @example |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
911 @group |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
912 @var{valuenames} = winqueryreg ("name", "HKEY_CURRENT_USER", ... |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
913 "Environment"); |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
914 @end group |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
915 @end example |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
916 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
917 For each @var{valuenames}, display the value: |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
918 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
919 @example |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
920 @group |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
921 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
|
922 @var{val} = winqueryreg ("HKEY_CURRENT_USER", "Environment", ... |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
923 @var{valuenames}@{@var{k}@}); |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
924 @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
|
925 disp (@var{str}); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
926 endfor |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
927 @end group |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
928 @end example |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
929 |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
930 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
|
931 @end deftypefn */) |
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 #if defined (OCTAVE_USE_WINDOWS_API) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
934 if ((args.length () < 2) || (args.length () > 3)) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
935 print_usage (); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
936 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
937 // Input check |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
938 std::string rootkey_name = |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
939 args(0).xstring_value ("winqueryreg: the first argument must be 'name' " |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
940 "or a valid ROOTKEY identifier"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
941 std::string subkey_name = ""; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
942 std::string value_name = ""; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
943 bool get_names = false; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
944 if (rootkey_name.compare ("name") == 0) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
945 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
946 if (args.length () < 3) |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
947 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
|
948 "ROOTKEY and SUBKEY must be given"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
949 get_names = true; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
950 rootkey_name = |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
951 args(1).xstring_value ("winqueryreg: ROOTKEY must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
952 subkey_name = |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
953 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
|
954 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
955 else |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
956 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
957 subkey_name = |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
958 args(1).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
|
959 if (args.length () == 3) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
960 value_name = |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
961 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
|
962 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
963 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
964 // Get rootkey handle |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
965 HKEY h_rootkey; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
966 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
|
967 h_rootkey = HKEY_CLASSES_ROOT; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
968 else if (rootkey_name == "HKEY_CURRENT_CONFIG") |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
969 h_rootkey = HKEY_CURRENT_CONFIG; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
970 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
|
971 h_rootkey = HKEY_CURRENT_USER; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
972 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
|
973 h_rootkey = HKEY_LOCAL_MACHINE; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
974 else if (rootkey_name == "HKEY_PERFORMANCE_DATA") |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
975 h_rootkey = HKEY_PERFORMANCE_DATA; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
976 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
|
977 h_rootkey = HKEY_USERS; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
978 else |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
979 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
|
980 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
981 if (get_names) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
982 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
983 std::list<std::string> fields; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
984 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
985 LONG retval = get_regkey_names (h_rootkey, subkey_name, fields); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
986 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
|
987 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
|
988 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
989 Cell fieldnames (dim_vector (1, fields.size ())); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
990 size_t i; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
991 std::list<std::string>::const_iterator it; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
992 for (i = 0, it = fields.begin (); it != fields.end (); ++it, ++i) |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
993 fieldnames(i) = *it; |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
994 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
995 return ovl (fieldnames); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
996 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
997 else |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
998 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
999 octave_value key_val; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1000 LONG retval = get_regkey_value (h_rootkey, subkey_name, value_name, |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1001 key_val); |
24720
48f22c5b22aa
winqueryreg: Fix error on Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24714
diff
changeset
|
1002 if (retval == ERROR_FILE_NOT_FOUND) |
48f22c5b22aa
winqueryreg: Fix error on Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24714
diff
changeset
|
1003 error ("winqueryreg: no value found for '%s' at %s\\%s.", |
48f22c5b22aa
winqueryreg: Fix error on Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24714
diff
changeset
|
1004 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
|
1005 subkey_name.c_str ()); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1006 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
|
1007 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
|
1008 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1009 return ovl (key_val); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1010 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1011 #else |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1012 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1013 octave_unused_parameter (args); |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1014 |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1015 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
|
1016 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1017 #endif |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1018 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1019 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1020 /* |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1021 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1022 %! assert (ischar (winqueryreg ("HKEY_LOCAL_MACHINE", |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1023 %! 'SOFTWARE\Microsoft\Windows\CurrentVersion', |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1024 %! "ProgramFilesDir"))); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1025 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1026 %! assert (isa (winqueryreg ("HKEY_LOCAL_MACHINE", |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1027 %! 'SYSTEM\CurrentControlSet\Control\FileSystem', |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1028 %! "Win31FileSystem"), "int32")); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1029 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1030 %! assert (iscellstr (winqueryreg ("name", "HKEY_LOCAL_MACHINE", |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1031 %! 'SOFTWARE\Microsoft\Windows\CurrentVersion'))); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1032 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1033 %! fail ('winqueryreg (1, ''SOFTWARE\Microsoft\Windows\CurrentVersion'')', |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1034 %! "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
|
1035 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1036 %! 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
|
1037 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1038 %! fail (['winqueryreg ("HKEY_LOCAL_MACHINE", ', ... |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1039 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'', 1)'], |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1040 %! "VALUENAME must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1041 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1042 %! fail (['winqueryreg ("FOO", ', ... |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1043 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'')'], |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1044 %! "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
|
1045 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1046 %! 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
|
1047 %! "no value found for"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1048 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1049 %! fail (['winqueryreg ("HKEY_LOCAL_MACHINE", ', ... |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1050 %! '''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
|
1051 %! "no value found for"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1052 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1053 %! fail ('winqueryreg ("name", "HKEY_LOCAL_MACHINE")', |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1054 %! "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
|
1055 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1056 %! fail (['winqueryreg ("name", 1, ', ... |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1057 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'')'], |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1058 %! "ROOTKEY must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1059 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1060 %! fail ('winqueryreg ("name", "HKEY_LOCAL_MACHINE", 1)', |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
1061 %! "SUBKEY must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1062 */ |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
1063 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1064 // FIXME: perhaps kbhit should also be able to print a prompt? |
3372 | 1065 |
3657 | 1066 DEFUN (kbhit, 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
|
1067 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
|
1068 @deftypefn {} {} kbhit () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1069 @deftypefnx {} {} kbhit (1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1070 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
|
1071 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1072 If called with an argument, don't wait for a keypress. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1073 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1074 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
|
1075 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1076 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1077 x = kbhit (); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1078 @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
|
1079 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1080 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1081 will set @var{x} to the next character typed at the keyboard as soon as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1082 it is typed. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1083 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1084 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1085 x = kbhit (1); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1086 @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
|
1087 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1088 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1089 is identical to the above example, but doesn't wait for a keypress, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1090 returning the empty string if no key is available. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1091 @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
|
1092 @end deftypefn */) |
529 | 1093 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1094 // FIXME: add timeout and default value args? |
529 | 1095 |
25311
10ec5795bd06
allow kbhit to work in command-line scripts (bug #53412)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1096 Fdrawnow (); |
6423 | 1097 |
25649
85c3e315bd43
move libinterp/corefcn/sysdep functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25646
diff
changeset
|
1098 int c = octave::kbhit (args.length () == 0); |
3657 | 1099 |
25311
10ec5795bd06
allow kbhit to work in command-line scripts (bug #53412)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1100 if (c == -1) |
10ec5795bd06
allow kbhit to work in command-line scripts (bug #53412)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1101 c = 0; |
16015 | 1102 |
25311
10ec5795bd06
allow kbhit to work in command-line scripts (bug #53412)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1103 char s[2] = { static_cast<char> (c), '\0' }; |
529 | 1104 |
25311
10ec5795bd06
allow kbhit to work in command-line scripts (bug #53412)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1105 return octave_value (s); |
529 | 1106 } |
1107 | |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1108 // State of the pause system |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1109 static bool Vpause_enabled = true; |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1110 |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1111 DEFUN (pause, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1112 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
|
1113 @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
|
1114 @deftypefnx {} {} pause (@var{n}) |
26046
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1115 @deftypefnx {} {@var{old_state} =} pause ("on") |
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1116 @deftypefnx {} {@var{old_state} =} pause ("off") |
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1117 @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
|
1118 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
|
1119 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1120 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
|
1121 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
|
1122 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
|
1123 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1124 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1125 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1126 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
|
1127 @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
|
1128 @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
|
1129 @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
|
1130 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1131 The following example prints a message and then waits 5 seconds before |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1132 clearing the screen. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1133 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1134 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1135 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1136 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
|
1137 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
|
1138 clc; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1139 @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
|
1140 @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
|
1141 |
26046
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1142 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
|
1143 @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
|
1144 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
|
1145 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
|
1146 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
|
1147 |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1148 @example |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1149 @group |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1150 old_state = pause ("off"); |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1151 tic; pause (0.05); toc |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1152 @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
|
1153 pause (old_state); |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1154 @end group |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1155 @end example |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1156 |
26046
ff0aa19333c9
doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents:
26026
diff
changeset
|
1157 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
|
1158 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
|
1159 |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1160 @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
|
1161 @end deftypefn */) |
529 | 1162 { |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1163 octave_value_list retval; |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1164 |
529 | 1165 int nargin = args.length (); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1166 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
1167 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
1168 print_usage (); |
529 | 1169 |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1170 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
|
1171 { |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1172 bool saved_state = Vpause_enabled; |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1173 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
|
1174 |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1175 if (state == "on") |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1176 Vpause_enabled = true; |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1177 else if (state == "off") |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1178 Vpause_enabled = false; |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1179 else if (state == "query") |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1180 ;// Do nothing |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1181 else |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1182 error ("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
|
1183 |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1184 if (nargout > 0 || state == "query") |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1185 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
|
1186 } |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1187 else if (Vpause_enabled) |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1188 { |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1189 double dval; |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1190 |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1191 if (nargin == 0) |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1192 dval = octave_Inf; |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1193 else |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1194 dval = args(0).xdouble_value ("pause: N must be a scalar real value"); |
6419 | 1195 |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1196 if (octave::math::isnan (dval)) |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1197 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
|
1198 else |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1199 { |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1200 Fdrawnow (); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1201 |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1202 octave::sleep (dval, true); |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1203 } |
3234 | 1204 } |
26026
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1205 |
511295347a27
Allow pause state to be changed (bug #53723)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25961
diff
changeset
|
1206 return retval; |
2630 | 1207 } |
1208 | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1209 /* |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1210 %!test |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1211 %! pause (1); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1212 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1213 %!error (pause (1, 2)) |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1214 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1215 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1216 // FIXME: maybe this should only return 1 if IEEE floating |
862 | 1217 // point functions really work. |
1218 | |
1957 | 1219 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
|
1220 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
|
1221 @deftypefn {} {} isieee () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1222 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
|
1223 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
|
1224 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1225 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
|
1226 @end deftypefn */) |
862 | 1227 { |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1228 octave::mach_info::float_format flt_fmt = |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1229 octave::mach_info::native_float_format (); |
2317 | 1230 |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21736
diff
changeset
|
1231 return ovl (flt_fmt == octave::mach_info::flt_fmt_ieee_little_endian |
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21736
diff
changeset
|
1232 || flt_fmt == octave::mach_info::flt_fmt_ieee_big_endian); |
862 | 1233 } |
1234 | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1235 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1236 %!assert (islogical (isieee ())) |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1237 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1238 |
4600 | 1239 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
|
1240 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
|
1241 @deftypefn {} {} native_float_format () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1242 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
|
1243 @end deftypefn */) |
4600 | 1244 { |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1245 octave::mach_info::float_format flt_fmt = |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1246 octave::mach_info::native_float_format (); |
4600 | 1247 |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21736
diff
changeset
|
1248 return ovl (octave::mach_info::float_format_as_string (flt_fmt)); |
4600 | 1249 } |
1250 | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1251 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1252 %!assert (ischar (native_float_format ())) |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1253 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1254 |
1957 | 1255 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
|
1256 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
|
1257 @deftypefn {} {} tilde_expand (@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
|
1258 @deftypefnx {} {} tilde_expand (@var{cellstr}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1259 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
|
1260 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1261 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
|
1262 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
|
1263 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
|
1264 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
|
1265 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
|
1266 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
|
1267 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1268 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
|
1269 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
|
1270 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1271 Examples: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1272 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1273 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1274 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1275 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
|
1276 @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
|
1277 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
|
1278 @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
|
1279 @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
|
1280 @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
|
1281 @end deftypefn */) |
1750 | 1282 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
1283 if (args.length () != 1) |
5823 | 1284 print_usage (); |
1750 | 1285 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
1286 octave_value arg = args(0); |
6116 | 1287 |
20990
fc9cca99b2de
Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents:
20961
diff
changeset
|
1288 string_vector sv = arg.xstring_vector_value ("tilde_expand: argument must be char or cellstr object"); |
6116 | 1289 |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
1290 sv = octave::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
|
1291 |
23575
e95738a119da
maint: Deprecate is_cellstr and replace with iscellstr.
Rik <rik@octave.org>
parents:
23459
diff
changeset
|
1292 if (arg.iscellstr ()) |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1293 return ovl (Cell (arg.dims (), sv)); |
1750 | 1294 else |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1295 return ovl (sv); |
1750 | 1296 } |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1297 |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1298 /* |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1299 %!test |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1300 %! 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
|
1301 %! 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
|
1302 %! 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
|
1303 %! 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
|
1304 */ |
17851
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
1305 |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1306 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
|
1307 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
|
1308 @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
|
1309 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
|
1310 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1311 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
|
1312 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
|
1313 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
|
1314 @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
|
1315 @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
|
1316 @end deftypefn */) |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1317 { |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
1318 return ovl (octave::sys::env::get_home_directory ()); |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1319 } |
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1320 |
20024
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1321 /* |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1322 %!test |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1323 %! if (! ispc ()) |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20172
diff
changeset
|
1324 %! 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
|
1325 %! endif |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1326 */ |
24714
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1327 |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1328 DEFUN (__blas_version__, , , |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1329 doc: /* -*- texinfo -*- |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1330 @deftypefn {} {} __blas_version__ () |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1331 Undocumented internal function. |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1332 @end deftypefn */) |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1333 { |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1334 return ovl (octave::sys::blas_version ()); |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1335 } |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1336 |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1337 DEFUN (__lapack_version__, , , |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1338 doc: /* -*- texinfo -*- |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1339 @deftypefn {} {} __lapack_version__ () |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1340 Undocumented internal function. |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1341 @end deftypefn */) |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1342 { |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1343 return ovl (octave::sys::lapack_version ()); |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1344 } |