Mercurial > octave
annotate libinterp/corefcn/sysdep.cc @ 25103:078b795c5219 stable
maint: style check C++ ahead of 4.4 release.
* ButtonGroup.cc, Canvas.cc, Figure.cc, GLCanvas.cc, GLCanvas.h,
ListBoxControl.cc, ObjectProxy.cc, QTerminal.h, dialog.cc, documentation.cc,
files-dock-widget.cc, history-dock-widget.cc, file-editor-tab.cc,
file-editor.h, find-dialog.cc, marker.h, octave-qscintilla.cc,
octave-qscintilla.h, main-window.cc, webinfo.cc, resource-manager.h,
settings-dialog.cc, shortcut-manager.cc, shortcut-manager.h,
variable-editor.cc, workspace-view.cc, build-env.in.cc, __ilu__.cc, cellfun.cc,
data.cc, dirfns.cc, dynamic-ld.h, environment.cc, error.cc, fcn-info.cc,
gl-render.cc, gl2ps-print.cc, graphics.cc, graphics.in.h, help.cc,
interpreter.cc, load-path.cc, load-save.cc, ls-mat5.cc, mex.cc, oct-stream.cc,
oct-stream.h, qz.cc, sighandlers.cc, sparse-xpow.cc, svd.cc, symscope.h,
symtab.cc, symtab.h, sysdep.cc, url-handle-manager.h, utils.cc, variables.cc,
__init_fltk__.cc, __ode15__.cc, gzip.cc, ov-base.cc, ov-builtin.h, ov-cell.cc,
ov-class.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-java.cc, ov-re-diag.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc,
op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc,
op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc,
op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcs-fcm.cc, op-fcs-fcs.cc,
op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc, op-fm-fcs.cc,
op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc,
op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc,
op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc,
op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc,
op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc,
op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc,
op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc,
bp-table.cc, comment-list.h, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, lex.h,
parse.h, pt-binop.h, pt-decl.h, pt-eval.cc, pt-jit.cc, pt-jit.h, pt-misc.h,
token.h, CMatrix.cc, CMatrix.h, CSparse.cc, CSparse.h, dMatrix.h, fCMatrix.cc,
fCMatrix.h, fMatrix.h, Faddeeva.cc, gepbalance.cc, hess.cc, oct-fftw.cc,
oct-fftw.h, file-stat.cc, lo-sysinfo.cc, action-container.h, f77-fcn.h,
lo-regexp.cc, oct-mutex.h, oct-shlib.cc:
Use Octave coding conventions in C++ files.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 03 Apr 2018 13:52:07 -0700 |
parents | 6652d3823428 |
children | 10ec5795bd06 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
25054
6652d3823428
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25003
diff
changeset
|
3 Copyright (C) 1993-2018 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" |
21910
4d723ba06b4a
provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
67 #include "unistd-wrappers.h" |
21888
00f1249f2483
create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
68 #include "unsetenv-wrapper.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 { |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
125 MODULEENTRY32 mod_info; |
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 |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
130 if (Module32First (h, &mod_info)) |
14445 | 131 { |
132 do | |
133 { | |
134 std::string mod_name (mod_info.szModule); | |
6080 | 135 |
14445 | 136 if (mod_name.find ("octinterp") != std::string::npos) |
137 { | |
138 bin_dir = 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 } | |
144 while (Module32Next (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 | |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
169 // Set app id if we have the SetCurrentProcessExplicitAppUserModelID |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
170 // available (>= Win7). FIXME: Could we check for existence of this |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
171 // function in the configure script instead of dynamically loading |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
172 // shell32.dll? |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
173 |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
174 void |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
175 set_application_id (void) |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
176 { |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
177 #if defined (__MINGW32__) || defined (_MSC_VER) |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
178 |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
179 typedef HRESULT (WINAPI *SETCURRENTAPPID)(PCWSTR AppID); |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
180 |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
181 HMODULE hShell = LoadLibrary ("shell32.dll"); |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
182 |
23459
ddcbf10c8c39
maint: Use C++11 nullptr rather than 0 or NULL for remaining instances in code.
Rik <rik@octave.org>
parents:
23455
diff
changeset
|
183 if (hShell) |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
184 { |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
185 SETCURRENTAPPID pfnSetCurrentProcessExplicitAppUserModelID = |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
186 reinterpret_cast<SETCURRENTAPPID> (GetProcAddress (hShell, |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
187 "SetCurrentProcessExplicitAppUserModelID")); |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
188 |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
189 if (pfnSetCurrentProcessExplicitAppUserModelID) |
23319 | 190 pfnSetCurrentProcessExplicitAppUserModelID (L"gnu.octave." VERSION); |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
191 |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
192 FreeLibrary (hShell); |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
193 } |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
194 |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
195 #endif |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
196 } |
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22141
diff
changeset
|
197 |
19856
5c1a38089f89
Change open_with_system_app to internal function.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
198 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
|
199 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
|
200 @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
|
201 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
|
202 @end deftypefn */) |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
203 { |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
204 if (args.length () != 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
205 print_usage (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
206 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
207 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
|
208 |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
209 octave_value retval; |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
210 |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
211 #if defined (OCTAVE_USE_WINDOWS_API) |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
212 HINSTANCE status = ShellExecute (0, 0, file.c_str (), 0, 0, |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
213 SW_SHOWNORMAL); |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
214 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
215 // 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
|
216 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
|
217 #elif defined (__APPLE__) |
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
218 octave_value_list tmp |
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
219 = 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
|
220 false, "async"), |
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
221 1); |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
222 |
20961
f55251db0833
Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents:
20941
diff
changeset
|
223 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
|
224 #else |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
225 octave_value_list tmp |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
226 = 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
|
227 false, "async"), |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
228 1); |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
229 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
230 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
|
231 #endif |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
232 |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
233 return retval; |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
234 } |
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
235 |
5451 | 236 #if defined (__MINGW32__) |
237 static void | |
238 MINGW_init (void) | |
239 { | |
19302
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
240 w32_init (); |
5451 | 241 } |
242 #endif | |
243 | |
6080 | 244 #if defined (_MSC_VER) |
245 static void | |
246 MSVC_init (void) | |
247 { | |
19302
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
248 w32_init (); |
6080 | 249 } |
250 #endif | |
251 | |
6598 | 252 // Return TRUE if FILE1 and FILE2 refer to the same (physical) file. |
253 | |
254 bool | |
255 same_file_internal (const std::string& file1, const std::string& file2) | |
256 { | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21662
diff
changeset
|
257 #if defined (OCTAVE_USE_WINDOWS_API) |
6598 | 258 |
6691 | 259 bool retval = false; |
260 | |
16564
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
261 const char *f1 = file1.c_str (); |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
262 const char *f2 = file2.c_str (); |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
263 |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
264 bool f1_is_dir = GetFileAttributes (f1) & FILE_ATTRIBUTE_DIRECTORY; |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
265 bool f2_is_dir = GetFileAttributes (f2) & FILE_ATTRIBUTE_DIRECTORY; |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
266 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
267 // Windows native code |
6598 | 268 // Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx |
269 | |
16564
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
270 DWORD share = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE; |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
271 |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
272 HANDLE hfile1 |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
273 = CreateFile (f1, 0, share, 0, OPEN_EXISTING, |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
274 f1_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0); |
6691 | 275 |
276 if (hfile1 != INVALID_HANDLE_VALUE) | |
277 { | |
16564
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
278 HANDLE hfile2 |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
279 = CreateFile (f2, 0, share, 0, OPEN_EXISTING, |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
280 f2_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0); |
6598 | 281 |
6691 | 282 if (hfile2 != INVALID_HANDLE_VALUE) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
283 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
284 BY_HANDLE_FILE_INFORMATION hfi1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
285 BY_HANDLE_FILE_INFORMATION hfi2; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
286 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
287 if (GetFileInformationByHandle (hfile1, &hfi1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
288 && GetFileInformationByHandle (hfile2, &hfi2)) |
16564
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
289 { |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
290 retval = (hfi1.dwVolumeSerialNumber == hfi2.dwVolumeSerialNumber |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
291 && hfi1.nFileIndexHigh == hfi2.nFileIndexHigh |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
292 && hfi1.nFileIndexLow == hfi2.nFileIndexLow); |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
293 } |
6598 | 294 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
295 CloseHandle (hfile2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
296 } |
6691 | 297 |
6598 | 298 CloseHandle (hfile1); |
299 } | |
6691 | 300 |
301 return retval; | |
6598 | 302 |
303 #else | |
304 | |
305 // POSIX Code | |
306 | |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
307 octave::sys::file_stat fs_file1 (file1); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
308 octave::sys::file_stat fs_file2 (file2); |
6598 | 309 |
310 return (fs_file1 && fs_file2 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
311 && fs_file1.ino () == fs_file2.ino () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
312 && fs_file1.dev () == fs_file2.dev ()); |
6598 | 313 |
314 #endif | |
315 } | |
316 | |
1 | 317 void |
318 sysdep_init (void) | |
319 { | |
21557
f6663c49870c
Add comment clarifying why omp_get_num_threads is called in sysdep.cc.
Rik <rik@octave.org>
parents:
21556
diff
changeset
|
320 // Use a function from libgomp to force loading of OpenMP library. |
f6663c49870c
Add comment clarifying why omp_get_num_threads is called in sysdep.cc.
Rik <rik@octave.org>
parents:
21556
diff
changeset
|
321 // Otherwise, a dynamically loaded library making use of OpenMP such |
f6663c49870c
Add comment clarifying why omp_get_num_threads is called in sysdep.cc.
Rik <rik@octave.org>
parents:
21556
diff
changeset
|
322 // 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
|
323 #if defined (HAVE_OMP_GET_NUM_THREADS) |
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
324 omp_get_num_threads (); |
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
325 #endif |
9f0088f3f335
call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20788
diff
changeset
|
326 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14445
diff
changeset
|
327 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__) |
2508 | 328 BSD_init (); |
5451 | 329 #elif defined (__MINGW32__) |
330 MINGW_init (); | |
6080 | 331 #elif defined (_MSC_VER) |
332 MSVC_init (); | |
1 | 333 #endif |
334 } | |
335 | |
5451 | 336 void |
337 sysdep_cleanup (void) | |
338 { | |
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
|
339 #if defined (OCTAVE_USE_WINDOWS_API) |
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
|
340 // Let us fail immediately without displaying any dialog. |
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
|
341 SetProcessShutdownParameters (0x280, SHUTDOWN_NORETRY); |
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
|
342 #endif |
5451 | 343 } |
344 | |
767 | 345 // Set terminal in raw mode. From less-177. |
346 // | |
347 // Change terminal to "raw mode", or restore to "normal" mode. | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
348 // "Raw mode" means |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
349 // 1. An outstanding read will complete on receipt of a single keystroke. |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
350 // 2. Input is not echoed. |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
351 // 3. On output, \n is mapped to \r\n. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
352 // 4. \t is NOT expanded into spaces. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
353 // 5. Signal-causing characters such as ctrl-C (interrupt), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
354 // etc. are NOT disabled. |
767 | 355 // It doesn't matter whether an input \n is mapped to \r, or vice versa. |
356 | |
529 | 357 void |
3657 | 358 raw_mode (bool on, bool wait) |
529 | 359 { |
3657 | 360 static bool curr_on = false; |
529 | 361 |
362 int tty_fd = STDIN_FILENO; | |
21910
4d723ba06b4a
provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents:
21888
diff
changeset
|
363 if (! octave_isatty_wrapper (tty_fd)) |
529 | 364 { |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
365 if (octave::application::interactive () |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
366 && ! octave::application::forced_interactive ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
367 error ("stdin is not a tty!"); |
529 | 368 } |
369 | |
370 if (on == curr_on) | |
371 return; | |
372 | |
373 #if defined (HAVE_TERMIOS_H) | |
374 { | |
375 struct termios s; | |
376 static struct termios save_term; | |
377 | |
378 if (on) | |
379 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
380 // Get terminal modes. |
529 | 381 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
382 tcgetattr (tty_fd, &s); |
529 | 383 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
384 // Save modes and set certain variables dependent on modes. |
529 | 385 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
386 save_term = s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
387 // ospeed = s.c_cflag & CBAUD; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
388 // erase_char = s.c_cc[VERASE]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
389 // kill_char = s.c_cc[VKILL]; |
529 | 390 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
391 // Set the modes to the way we want them. |
529 | 392 |
21662
5b9868c2e212
maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents:
21557
diff
changeset
|
393 s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL); |
5b9868c2e212
maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents:
21557
diff
changeset
|
394 s.c_oflag |= (OPOST | ONLCR); |
529 | 395 #if defined (OCRNL) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
396 s.c_oflag &= ~(OCRNL); |
529 | 397 #endif |
398 #if defined (ONOCR) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
399 s.c_oflag &= ~(ONOCR); |
529 | 400 #endif |
401 #if defined (ONLRET) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
402 s.c_oflag &= ~(ONLRET); |
529 | 403 #endif |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23325
diff
changeset
|
404 s.c_cc[VMIN] = (wait ? 1 : 0); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
405 s.c_cc[VTIME] = 0; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
406 } |
529 | 407 else |
408 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
409 // Restore saved modes. |
1358 | 410 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
411 s = save_term; |
529 | 412 } |
3658 | 413 |
9411
c9636d98e5cd
fix kbhit(1) to not discard waiting keystrokes
Joe Rothweiler <octaveuser@sensicomm.com>
parents:
9242
diff
changeset
|
414 tcsetattr (tty_fd, wait ? TCSAFLUSH : TCSADRAIN, &s); |
529 | 415 } |
416 #elif defined (HAVE_TERMIO_H) | |
417 { | |
418 struct termio s; | |
419 static struct termio save_term; | |
420 | |
421 if (on) | |
422 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
423 // Get terminal modes. |
529 | 424 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
425 ioctl (tty_fd, TCGETA, &s); |
529 | 426 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
427 // Save modes and set certain variables dependent on modes. |
529 | 428 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
429 save_term = s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
430 // ospeed = s.c_cflag & CBAUD; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
431 // erase_char = s.c_cc[VERASE]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
432 // kill_char = s.c_cc[VKILL]; |
529 | 433 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
434 // Set the modes to the way we want them. |
529 | 435 |
21662
5b9868c2e212
maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents:
21557
diff
changeset
|
436 s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL); |
5b9868c2e212
maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents:
21557
diff
changeset
|
437 s.c_oflag |= (OPOST | ONLCR); |
529 | 438 #if defined (OCRNL) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
439 s.c_oflag &= ~(OCRNL); |
529 | 440 #endif |
441 #if defined (ONOCR) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
442 s.c_oflag &= ~(ONOCR); |
529 | 443 #endif |
444 #if defined (ONLRET) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
445 s.c_oflag &= ~(ONLRET); |
529 | 446 #endif |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23325
diff
changeset
|
447 s.c_cc[VMIN] = (wait ? 1 : 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
448 } |
529 | 449 else |
450 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
451 // Restore saved modes. |
1358 | 452 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
453 s = save_term; |
529 | 454 } |
3658 | 455 |
529 | 456 ioctl (tty_fd, TCSETAW, &s); |
457 } | |
458 #elif defined (HAVE_SGTTY_H) | |
459 { | |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23812
diff
changeset
|
460 octave_unused_parameter (wait); |
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23812
diff
changeset
|
461 |
529 | 462 struct sgttyb s; |
463 static struct sgttyb save_term; | |
464 | |
465 if (on) | |
466 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
467 // Get terminal modes. |
529 | 468 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
469 ioctl (tty_fd, TIOCGETP, &s); |
529 | 470 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
471 // Save modes and set certain variables dependent on modes. |
529 | 472 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
473 save_term = s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
474 // ospeed = s.sg_ospeed; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
475 // erase_char = s.sg_erase; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
476 // kill_char = s.sg_kill; |
529 | 477 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
478 // Set the modes to the way we want them. |
529 | 479 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
480 s.sg_flags |= CBREAK; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
481 s.sg_flags &= ~(ECHO); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
482 } |
529 | 483 else |
484 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
485 // Restore saved modes. |
1358 | 486 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
487 s = save_term; |
529 | 488 } |
3658 | 489 |
529 | 490 ioctl (tty_fd, TIOCSETN, &s); |
491 } | |
492 #else | |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23812
diff
changeset
|
493 |
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23812
diff
changeset
|
494 octave_unused_parameter (wait); |
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23812
diff
changeset
|
495 |
21109
bd1752782e56
Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents:
21078
diff
changeset
|
496 warn_disabled_feature ("", "raw mode console I/O"); |
4064 | 497 |
498 // Make sure the current mode doesn't toggle. | |
499 on = curr_on; | |
529 | 500 #endif |
501 | |
502 curr_on = on; | |
503 } | |
504 | |
6726 | 505 FILE * |
506 octave_popen (const char *command, const char *mode) | |
507 { | |
508 #if defined (__MINGW32__) || defined (_MSC_VER) | |
509 if (mode && mode[0] && ! mode[1]) | |
510 { | |
22855
f9fdd2f66514
maint: use initializer of char array for octave_popen tmode.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
511 // Use binary mode on Windows if unspecified |
f9fdd2f66514
maint: use initializer of char array for octave_popen tmode.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
512 char tmode[3] = {mode[0], 'b', '\0'}; |
6726 | 513 |
514 return _popen (command, tmode); | |
515 } | |
516 else | |
517 return _popen (command, mode); | |
518 #else | |
519 return popen (command, mode); | |
520 #endif | |
521 } | |
522 | |
523 int | |
524 octave_pclose (FILE *f) | |
525 { | |
526 #if defined (__MINGW32__) || defined (_MSC_VER) | |
527 return _pclose (f); | |
528 #else | |
529 return pclose (f); | |
530 #endif | |
531 } | |
532 | |
767 | 533 // Read one character from the terminal. |
534 | |
529 | 535 int |
4067 | 536 octave_kbhit (bool wait) |
529 | 537 { |
20788
a2b96b523472
Rewrite a8ee668e7fd7 to use #if defined rather than #ifdef.
Rik <rik@octave.org>
parents:
20786
diff
changeset
|
538 #if defined (HAVE__KBHIT) && defined (HAVE__GETCH) |
20786
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
539 // This essentially means we are on a Windows system. |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
540 int c; |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
541 |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
542 if (wait) |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
543 c = _getch (); |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
544 else |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
545 c = (! _kbhit ()) ? 0 : _getch (); |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
546 |
4067 | 547 #else |
3658 | 548 raw_mode (true, wait); |
549 | |
5770 | 550 // Get current handler. |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22019
diff
changeset
|
551 octave::interrupt_handler saved_interrupt_handler |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22019
diff
changeset
|
552 = octave::ignore_interrupts (); |
5770 | 553 |
554 // Restore it, disabling system call restarts (if possible) so the | |
555 // read can be interrupted. | |
556 | |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22019
diff
changeset
|
557 octave::set_interrupt_handler (saved_interrupt_handler, false); |
5770 | 558 |
3658 | 559 int c = std::cin.get (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
560 |
3658 | 561 if (std::cin.fail () || std::cin.eof ()) |
562 std::cin.clear (); | |
563 | |
5770 | 564 // Restore it, enabling system call restarts (if possible). |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22019
diff
changeset
|
565 octave::set_interrupt_handler (saved_interrupt_handler, true); |
5770 | 566 |
3658 | 567 raw_mode (false, true); |
4067 | 568 #endif |
3658 | 569 |
529 | 570 return c; |
571 } | |
572 | |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
573 std::string |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
574 get_P_tmpdir (void) |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
575 { |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
576 #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
|
577 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
578 std::string retval; |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
579 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
580 #if 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
|
581 retval = 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
|
582 #endif |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
583 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
584 // Apparently some versions of MinGW and MSVC either don't define |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
585 // P_tmpdir, or they define it to a single backslash, neither of which |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
586 // is particularly helpful. |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
587 |
23809
e56d84a16a2e
Fix "no match for 'operator=='" when comparing C++ string to char literal.
Markus Mützel <markus.muetzel@gmx.de>
parents:
23804
diff
changeset
|
588 if (retval.empty () || retval == R"(\)") |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
589 { |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
590 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
|
591 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
592 if (retval.empty ()) |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
593 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
|
594 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
595 if (retval.empty ()) |
23804
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23746
diff
changeset
|
596 retval = R"(c:\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
|
597 } |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
598 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
599 return retval; |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
600 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
601 #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
|
602 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
603 return 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
|
604 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
605 #else |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
606 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
607 return "/tmp"; |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
608 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
609 #endif |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
610 } |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
611 |
1957 | 612 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
|
613 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
|
614 @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
|
615 @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
|
616 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
|
617 @end deftypefn */) |
529 | 618 { |
16537
106a38d7b396
optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents:
16404
diff
changeset
|
619 bool skip_redisplay = true; |
106a38d7b396
optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents:
16404
diff
changeset
|
620 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
621 octave::command_editor::clear_screen (skip_redisplay); |
529 | 622 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
623 return ovl (); |
529 | 624 } |
625 | |
549 | 626 DEFALIAS (home, clc); |
627 | |
1957 | 628 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
|
629 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
|
630 @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
|
631 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
|
632 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
633 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
|
634 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
635 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
636 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
|
637 @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
|
638 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
639 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
640 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
|
641 @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
|
642 @end deftypefn */) |
529 | 643 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
644 if (args.length () != 1) |
5823 | 645 print_usage (); |
529 | 646 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
647 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
|
648 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
649 return ovl (octave::sys::env::getenv (name)); |
529 | 650 } |
651 | |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
652 /* |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
653 %!assert (ischar (getenv ("OCTAVE_HOME"))) |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
654 */ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
655 |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
656 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
|
657 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
|
658 @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
|
659 @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
|
660 @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
|
661 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
|
662 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
663 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
|
664 string. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
665 @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
|
666 @end deftypefn */) |
1706 | 667 { |
668 int nargin = args.length (); | |
669 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
670 if (nargin < 1 || nargin > 2) |
5823 | 671 print_usage (); |
1706 | 672 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
673 std::string var = args(0).xstring_value ("setenv: VAR must be a string"); |
1706 | 674 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
675 std::string val = (nargin == 2 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
676 ? 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
|
677 : ""); |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
678 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
679 octave::sys::env::putenv (var, val); |
1706 | 680 |
21078
49852ff04747
maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
681 return ovl (); |
1706 | 682 } |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
683 |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
684 DEFALIAS (putenv, setenv); |
1706 | 685 |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
686 /* |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
687 %!test |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
688 %! 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
|
689 %! 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
|
690 %! unsetenv ("dummy_variable_that_cannot_matter"); |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
691 %! assert (getenv ("dummy_variable_that_cannot_matter"), ""); |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
692 */ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
693 |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
694 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
|
695 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
|
696 @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
|
697 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
|
698 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
699 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
|
700 occurred. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
701 @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
|
702 @end deftypefn */) |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
703 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
704 if (args.length () != 1) |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
705 print_usage (); |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
706 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
707 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
|
708 |
21888
00f1249f2483
create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
709 return ovl (octave_unsetenv_wrapper (tmp.c_str ())); |
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 |
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 ## 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
|
714 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
715 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
716 #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
|
717 |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
718 static void |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
719 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
|
720 { |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
721 RegCloseKey (key); |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
722 } |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
723 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
724 LONG |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
725 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
|
726 const std::string name, octave_value& value) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
727 { |
24702
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
728 LONG result; |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
729 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
|
730 |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
731 result = RegOpenKeyExA (h_rootkey, subkey.c_str (), 0, KEY_READ, &h_subkey); |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
732 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
|
733 return result; |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
734 |
24710
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
735 octave::unwind_protect frame; |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
736 |
a979bb895b64
avoid reinterpret_cast on function pointer in previous change
John W. Eaton <jwe@octave.org>
parents:
24709
diff
changeset
|
737 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
|
738 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
739 DWORD length = 0; |
24702
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
740 result = RegQueryValueExA (h_subkey, name.c_str (), nullptr, nullptr, nullptr, |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
741 &length); |
24702
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
742 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
|
743 return result; |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
744 |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
745 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
|
746 OCTAVE_LOCAL_BUFFER (BYTE, data, length); |
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
747 result = RegQueryValueExA (h_subkey, name.c_str (), nullptr, &type, data, |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
748 &length); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
749 if (result != ERROR_SUCCESS) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
750 return result; |
24691
b658e0fa0cb3
maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents:
24682
diff
changeset
|
751 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
752 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
|
753 value = octave_int32 (*data); |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
754 else if (type == REG_SZ || type == REG_EXPAND_SZ) |
24702
15daa0b34826
winqueryreg: Use WinAPI functions available in Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24691
diff
changeset
|
755 value = string_vector (reinterpret_cast<char *> (data)); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
756 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
757 return result; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
758 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
759 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
760 LONG |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
761 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
|
762 std::list<std::string> &fields) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
763 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
764 LONG retval; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
765 HKEY h_subkey; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
766 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
767 fields.clear (); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
768 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
769 retval = RegOpenKeyEx (h_rootkey, subkey.c_str (), 0, KEY_READ, &h_subkey); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
770 if (retval != ERROR_SUCCESS) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
771 return retval; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
772 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
773 DWORD idx = 0; |
24720
48f22c5b22aa
winqueryreg: Fix error on Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24714
diff
changeset
|
774 const int MAX_VALUE_NAME_SIZE = 32766; |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
775 char value_name[MAX_VALUE_NAME_SIZE+1]; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
776 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
|
777 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
778 while (true) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
779 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
780 retval = RegEnumValue (h_subkey, idx, value_name, &value_name_size, |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
781 nullptr, nullptr, nullptr, nullptr); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
782 if (retval != ERROR_SUCCESS) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
783 break; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
784 fields.push_back (value_name); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
785 value_name_size = MAX_VALUE_NAME_SIZE; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
786 idx++; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
787 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
788 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
789 if (retval == ERROR_NO_MORE_ITEMS) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
790 retval = ERROR_SUCCESS; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
791 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
792 RegCloseKey (h_subkey); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
793 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
794 return retval; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
795 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
796 #endif |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
797 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
798 DEFUN (winqueryreg, args, , |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
799 doc: /* -*- texinfo -*- |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
800 @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
|
801 @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
|
802 @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
|
803 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
804 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
|
805 |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
806 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
|
807 @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
|
808 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
|
809 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
|
810 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
|
811 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
|
812 @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
|
813 returned. |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
814 |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
815 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
|
816 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
|
817 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
818 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
|
819 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
820 @table @asis |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
821 @item @nospell{HKCR} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
822 @itemx @nospell{HKEY_CLASSES_ROOT} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
823 |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
824 @item @nospell{HKEY_CURRENT_CONFIG} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
825 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
826 @item @nospell{HKCU} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
827 @itemx @nospell{HKEY_CURRENT_USER} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
828 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
829 @item @nospell{HKLM} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
830 @itemx @nospell{HKEY_LOCAL_MACHINE} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
831 |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
832 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
833 @item @nospell{HKU} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
834 @itemx @nospell{HKEY_USERS} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
835 |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
836 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
837 @item @nospell{HKEY_PERFORMANCE_DATA} |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
838 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
839 @end table |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
840 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
841 Examples: |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
842 |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24720
diff
changeset
|
843 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
|
844 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
845 @example |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
846 @group |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
847 @var{valuenames} = winqueryreg ("name", "HKEY_CURRENT_USER", ... |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
848 "Environment"); |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
849 @end group |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
850 @end example |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
851 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
852 For each @var{valuenames}, display the value: |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
853 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
854 @example |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
855 @group |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
856 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
|
857 @var{val} = winqueryreg ("HKEY_CURRENT_USER", "Environment", ... |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
858 @var{valuenames}@{@var{k}@}); |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
859 @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
|
860 disp (@var{str}); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
861 endfor |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
862 @end group |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
863 @end example |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
864 |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
865 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
|
866 @end deftypefn */) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
867 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
868 #if defined (OCTAVE_USE_WINDOWS_API) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
869 if ((args.length () < 2) || (args.length () > 3)) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
870 print_usage (); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
871 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
872 // Input check |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
873 std::string rootkey_name = |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
874 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
|
875 "or a valid ROOTKEY identifier"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
876 std::string subkey_name = ""; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
877 std::string value_name = ""; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
878 bool get_names = false; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
879 if (rootkey_name.compare ("name") == 0) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
880 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
881 if (args.length () < 3) |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
882 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
|
883 "ROOTKEY and SUBKEY must be given"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
884 get_names = true; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
885 rootkey_name = |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
886 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
|
887 subkey_name = |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
888 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
|
889 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
890 else |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
891 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
892 subkey_name = |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
893 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
|
894 if (args.length () == 3) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
895 value_name = |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
896 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
|
897 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
898 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
899 // Get rootkey handle |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
900 HKEY h_rootkey; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
901 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
|
902 h_rootkey = HKEY_CLASSES_ROOT; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
903 else if (rootkey_name == "HKEY_CURRENT_CONFIG") |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
904 h_rootkey = HKEY_CURRENT_CONFIG; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
905 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
|
906 h_rootkey = HKEY_CURRENT_USER; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
907 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
|
908 h_rootkey = HKEY_LOCAL_MACHINE; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
909 else if (rootkey_name == "HKEY_PERFORMANCE_DATA") |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
910 h_rootkey = HKEY_PERFORMANCE_DATA; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
911 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
|
912 h_rootkey = HKEY_USERS; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
913 else |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
914 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
|
915 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
916 if (get_names) |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
917 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
918 std::list<std::string> fields; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
919 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
920 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
|
921 if (retval != ERROR_SUCCESS) |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
922 error ("winqueryreg: error %d reading names from registry", retval); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
923 |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
924 Cell fieldnames (dim_vector (1, fields.size ())); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
925 size_t i; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
926 std::list<std::string>::const_iterator it; |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
927 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
|
928 fieldnames(i) = *it; |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
929 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
930 return ovl (fieldnames); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
931 } |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
932 else |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
933 { |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
934 octave_value key_val; |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
935 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
|
936 key_val); |
24720
48f22c5b22aa
winqueryreg: Fix error on Windows XP (bug #50463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24714
diff
changeset
|
937 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
|
938 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
|
939 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
|
940 subkey_name.c_str ()); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
941 if (retval != ERROR_SUCCESS) |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
942 error ("winqueryreg: error %d reading the specified key", retval); |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
943 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
944 return ovl (key_val); |
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 #else |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
947 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
948 octave_unused_parameter (args); |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
949 |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
950 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
|
951 |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
952 #endif |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
953 } |
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 /* |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
956 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
957 %! assert (ischar (winqueryreg ("HKEY_LOCAL_MACHINE", |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
958 %! 'SOFTWARE\Microsoft\Windows\CurrentVersion', |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
959 %! "ProgramFilesDir"))); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
960 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
961 %! assert (isa (winqueryreg ("HKEY_LOCAL_MACHINE", |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
962 %! 'SYSTEM\CurrentControlSet\Control\FileSystem', |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
963 %! "Win31FileSystem"), "int32")); |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
964 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
965 %! assert (iscellstr (winqueryreg ("name", "HKEY_LOCAL_MACHINE", |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
966 %! 'SOFTWARE\Microsoft\Windows\CurrentVersion'))); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
967 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
968 %! fail ('winqueryreg (1, ''SOFTWARE\Microsoft\Windows\CurrentVersion'')', |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
969 %! "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
|
970 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
971 %! 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
|
972 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
973 %! fail (['winqueryreg ("HKEY_LOCAL_MACHINE", ', ... |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
974 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'', 1)'], |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
975 %! "VALUENAME must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
976 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
977 %! fail (['winqueryreg ("FOO", ', ... |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
978 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'')'], |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
979 %! "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 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
981 %! 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
|
982 %! "no value found for"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
983 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
984 %! fail (['winqueryreg ("HKEY_LOCAL_MACHINE", ', ... |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
985 %! '''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
|
986 %! "no value found for"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
987 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
988 %! fail ('winqueryreg ("name", "HKEY_LOCAL_MACHINE")', |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
989 %! "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
|
990 %!testif ; ispc () |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
991 %! fail (['winqueryreg ("name", 1, ', ... |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
992 %! '''SOFTWARE\Microsoft\Windows\CurrentVersion'')'], |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
993 %! "ROOTKEY must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
994 %!testif ; ispc () |
24665
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
995 %! fail ('winqueryreg ("name", "HKEY_LOCAL_MACHINE", 1)', |
4a9793818fca
Use Octave coding conventions in cset a829062fdea4.
Rik <rik@octave.org>
parents:
24664
diff
changeset
|
996 %! "SUBKEY must be a string"); |
24664
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
997 */ |
a829062fdea4
Add function "winqueryreg" (bug #52935).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24534
diff
changeset
|
998 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
999 // FIXME: perhaps kbhit should also be able to print a prompt? |
3372 | 1000 |
3657 | 1001 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
|
1002 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
|
1003 @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
|
1004 @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
|
1005 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
|
1006 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1007 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
|
1008 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1009 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
|
1010 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1011 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1012 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
|
1013 @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
|
1014 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1015 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1016 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
|
1017 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
|
1018 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1019 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1020 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
|
1021 @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
|
1022 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1023 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1024 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
|
1025 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
|
1026 @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
|
1027 @end deftypefn */) |
529 | 1028 { |
22141
ed6104a78ebf
kbhit: return an empty string if not running interactively (bug #48541)
Mike Miller <mtmiller@octave.org>
parents:
22097
diff
changeset
|
1029 octave_value retval = ""; |
529 | 1030 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1031 // FIXME: add timeout and default value args? |
529 | 1032 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
1033 if (octave::application::interactive ()) |
529 | 1034 { |
15423
53d073233fa4
call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1035 Fdrawnow (); |
6423 | 1036 |
4067 | 1037 int c = octave_kbhit (args.length () == 0); |
3657 | 1038 |
3658 | 1039 if (c == -1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
1040 c = 0; |
3657 | 1041 |
16092
def3b111cff8
avoid gcc warning about int to char conversion
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
1042 char s[2] = { static_cast<char> (c), '\0' }; |
16015 | 1043 |
529 | 1044 retval = s; |
1045 } | |
1046 | |
1047 return retval; | |
1048 } | |
1049 | |
1957 | 1050 DEFUN (pause, 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
|
1051 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
|
1052 @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
|
1053 @deftypefnx {} {} pause (@var{n}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1054 Suspend the execution of the program for @var{n} seconds. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1055 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1056 If invoked without an input arguments then the program is suspended until a |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1057 character 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
|
1058 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1059 @var{n} is a positive real value and may be a fraction of a second, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1060 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
|
1061 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1062 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1063 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1064 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
|
1065 @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
|
1066 @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
|
1067 @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
|
1068 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1069 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
|
1070 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
|
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 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1073 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1074 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
|
1075 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
|
1076 clc; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1077 @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
|
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 @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
|
1081 @end deftypefn */) |
529 | 1082 { |
1083 int nargin = args.length (); | |
1084 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
1085 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
1086 print_usage (); |
529 | 1087 |
1579 | 1088 if (nargin == 1) |
529 | 1089 { |
1579 | 1090 double dval = args(0).double_value (); |
636 | 1091 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21748
diff
changeset
|
1092 if (octave::math::isnan (dval)) |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1093 warning ("pause: NaN is an invalid delay"); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1094 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
1095 { |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
1096 Fdrawnow (); |
6419 | 1097 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21748
diff
changeset
|
1098 if (octave::math::isinf (dval)) |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
1099 { |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22855
diff
changeset
|
1100 octave::flush_stdout (); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
1101 octave_kbhit (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
1102 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
1103 else |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
1104 octave_sleep (dval); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
1105 } |
529 | 1106 } |
1579 | 1107 else |
3234 | 1108 { |
15423
53d073233fa4
call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1109 Fdrawnow (); |
23060
baf03cdb28b5
move pager and diary classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22855
diff
changeset
|
1110 octave::flush_stdout (); |
4067 | 1111 octave_kbhit (); |
3234 | 1112 } |
2630 | 1113 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1114 return ovl (); |
2630 | 1115 } |
1116 | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1117 /* |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1118 %!test |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1119 %! pause (1); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1120 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1121 %!error (pause (1, 2)) |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1122 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1123 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1124 // FIXME: maybe this should only return 1 if IEEE floating |
862 | 1125 // point functions really work. |
1126 | |
1957 | 1127 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
|
1128 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
|
1129 @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
|
1130 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
|
1131 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
|
1132 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1133 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
|
1134 @end deftypefn */) |
862 | 1135 { |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1136 octave::mach_info::float_format flt_fmt = |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1137 octave::mach_info::native_float_format (); |
2317 | 1138 |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21736
diff
changeset
|
1139 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
|
1140 || flt_fmt == octave::mach_info::flt_fmt_ieee_big_endian); |
862 | 1141 } |
1142 | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1143 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1144 %!assert (islogical (isieee ())) |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1145 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1146 |
4600 | 1147 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
|
1148 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
|
1149 @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
|
1150 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
|
1151 @end deftypefn */) |
4600 | 1152 { |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1153 octave::mach_info::float_format flt_fmt = |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1154 octave::mach_info::native_float_format (); |
4600 | 1155 |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21736
diff
changeset
|
1156 return ovl (octave::mach_info::float_format_as_string (flt_fmt)); |
4600 | 1157 } |
1158 | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1159 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1160 %!assert (ischar (native_float_format ())) |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1161 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1162 |
1957 | 1163 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
|
1164 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
|
1165 @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
|
1166 @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
|
1167 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
|
1168 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1169 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
|
1170 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
|
1171 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
|
1172 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
|
1173 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
|
1174 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
|
1175 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1176 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
|
1177 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
|
1178 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1179 Examples: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1180 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1181 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1182 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1183 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
|
1184 @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
|
1185 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
|
1186 @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
|
1187 @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
|
1188 @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
|
1189 @end deftypefn */) |
1750 | 1190 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
1191 if (args.length () != 1) |
5823 | 1192 print_usage (); |
1750 | 1193 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
1194 octave_value arg = args(0); |
6116 | 1195 |
20990
fc9cca99b2de
Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents:
20961
diff
changeset
|
1196 string_vector sv = arg.xstring_vector_value ("tilde_expand: argument must be char or cellstr object"); |
6116 | 1197 |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
1198 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
|
1199 |
23575
e95738a119da
maint: Deprecate is_cellstr and replace with iscellstr.
Rik <rik@octave.org>
parents:
23459
diff
changeset
|
1200 if (arg.iscellstr ()) |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1201 return ovl (Cell (arg.dims (), sv)); |
1750 | 1202 else |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1203 return ovl (sv); |
1750 | 1204 } |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1205 |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1206 /* |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1207 %!test |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1208 %! 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
|
1209 %! 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
|
1210 %! 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
|
1211 %! 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
|
1212 */ |
17851
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
1213 |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1214 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
|
1215 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
|
1216 @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
|
1217 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
|
1218 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
1219 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
|
1220 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
|
1221 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
|
1222 @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
|
1223 @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
|
1224 @end deftypefn */) |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1225 { |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
1226 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
|
1227 } |
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1228 |
20024
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1229 /* |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1230 %!test |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1231 %! if (! ispc ()) |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20172
diff
changeset
|
1232 %! 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
|
1233 %! endif |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
1234 */ |
24714
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1235 |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1236 DEFUN (__blas_version__, , , |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1237 doc: /* -*- texinfo -*- |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1238 @deftypefn {} {} __blas_version__ () |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1239 Undocumented internal function. |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1240 @end deftypefn */) |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1241 { |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1242 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
|
1243 } |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1244 |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1245 DEFUN (__lapack_version__, , , |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1246 doc: /* -*- texinfo -*- |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1247 @deftypefn {} {} __lapack_version__ () |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1248 Undocumented internal function. |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1249 @end deftypefn */) |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1250 { |
d2c727a438ab
Add "-blas" and "-lapack" options to "version" (bug #45659).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24710
diff
changeset
|
1251 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
|
1252 } |