Mercurial > octave
annotate libinterp/corefcn/sysdep.cc @ 20923:58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
* doc/interpreter/system.txi: removed sleep and usleep from doc.
* libinterp/corefcn/sysdep.cc (pause): updated docstring.
* libinterp/corefcn/sysdep.cc (sleep): moved to deprecate sleep.m.
* libinterp/corefcn/sysdep.cc (usleep): moved to deprecate usleep.m.
* scripts/deprecated/sleep.m: moved here from sysdep.cc.
* scripts/deprecated/usleep.m: moved here from sysdep.cc.
* scripts/deprecated/module.mk: add sleep.m and usleep.m to build system.
* NEWS: deprecation news for sleep and usleep.
* libinterp/corefcn/data.cc: examples updated.
* libinterp/corefcn/syscalls.cc: examples updated.
* scripts/audio/@audioplayer/audioplayer.m: examples updated.
* scripts/audio/@audiorecorder/audiorecorder.m: examples updated.
* scripts/plot/util/ginput.m: examples updated.
* scripts/plot/util/private/__gnuplot_get_var__.m: use pause.
* scripts/plot/util/private/__gnuplot_ginput__.m: use pause.
* libinterp/corefcn/utils.cc (octave_sleep): Unified "sleep" functions here.
* libinterp/corefcn/utils.h: removed header cutils.h.
* libinterp/corefcn/graphics.cc (drawnow): use octave_sleep.
* libinterp/corefcn/graphics.cc (waitfor): use octave_sleep.
* libinterp/corefcn/toplev.cc (clean_up_and_exit): use octave_sleep.
* libinterp/corefcn/cutils.c: removed no longer needed code.
* libinterp/corefcn/cutils.h: removed no longer needed header.
* libinterp/corefcn/matherr.c: removed orphaned code.
* libinterp/corefcn/module.mk: removed cutils.h, cutils.c, and matherr.c from
build system.
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Thu, 17 Dec 2015 16:04:13 +0100 |
parents | 1142cf6abc0d |
children | b17fda023ca6 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19540
diff
changeset
|
3 Copyright (C) 1993-2015 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
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 |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
240 | 23 #ifdef HAVE_CONFIG_H |
1192 | 24 #include <config.h> |
1 | 25 #endif |
26 | |
1346 | 27 #include <cfloat> |
1343 | 28 #include <cstddef> |
1346 | 29 #include <cstdio> |
1343 | 30 #include <cstdlib> |
31 #include <cstring> | |
32 | |
3503 | 33 #include <iostream> |
1728 | 34 #include <string> |
35 | |
529 | 36 #include <sys/types.h> |
37 #include <unistd.h> | |
1 | 38 |
1430 | 39 #if defined (HAVE_TERMIOS_H) |
40 #include <termios.h> | |
41 #elif defined (HAVE_TERMIO_H) | |
42 #include <termio.h> | |
43 #elif defined (HAVE_SGTTY_H) | |
44 #include <sgtty.h> | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
45 #endif |
4067 | 46 |
47 #if defined (HAVE_CONIO_H) | |
48 #include <conio.h> | |
1430 | 49 #endif |
50 | |
3248 | 51 #if defined (HAVE_SYS_IOCTL_H) |
52 #include <sys/ioctl.h> | |
53 #endif | |
54 | |
1463 | 55 #if defined (HAVE_FLOATINGPOINT_H) |
56 #include <floatingpoint.h> | |
57 #endif | |
58 | |
2508 | 59 #if defined (HAVE_IEEEFP_H) |
60 #include <ieeefp.h> | |
61 #endif | |
62 | |
2926 | 63 #include "cmd-edit.h" |
64 #include "file-ops.h" | |
2893 | 65 #include "lo-mappers.h" |
7231 | 66 #include "lo-math.h" |
2317 | 67 #include "mach-info.h" |
2926 | 68 #include "oct-env.h" |
5451 | 69 #include "quit.h" |
1769 | 70 |
6208 | 71 #include "Cell.h" |
15423
53d073233fa4
call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
72 #include "builtins.h" |
1352 | 73 #include "defun.h" |
17851
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
74 #include "display.h" |
1352 | 75 #include "error.h" |
529 | 76 #include "input.h" |
1755 | 77 #include "oct-obj.h" |
2370 | 78 #include "ov.h" |
3234 | 79 #include "pager.h" |
6419 | 80 #include "parse.h" |
5770 | 81 #include "sighandlers.h" |
1352 | 82 #include "sysdep.h" |
1755 | 83 #include "toplev.h" |
529 | 84 #include "utils.h" |
6598 | 85 #include "file-stat.h" |
529 | 86 |
87 #ifndef STDIN_FILENO | |
88 #define STDIN_FILENO 1 | |
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 { | |
95 #if defined (HAVE_FLOATINGPOINT_H) | |
96 // Disable trapping on common exceptions. | |
4164 | 97 #ifndef FP_X_DNML |
98 #define FP_X_DNML 0 | |
99 #endif | |
2508 | 100 fpsetmask (~(FP_X_OFL|FP_X_INV|FP_X_DZ|FP_X_DNML|FP_X_UFL|FP_X_IMP)); |
101 #endif | |
102 } | |
103 #endif | |
104 | |
6956 | 105 #if defined (__WIN32__) && ! defined (_POSIX_VERSION) |
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 |
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
108 #include <tlhelp32.h> |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
109 #include <windows.h> |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
110 |
6080 | 111 static void |
112 w32_set_octave_home (void) | |
113 { | |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
114 std::string bin_dir; |
6080 | 115 |
13885
2f42a7b0cf94
Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13771
diff
changeset
|
116 HANDLE h = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE |
2f42a7b0cf94
Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13771
diff
changeset
|
117 #ifdef TH32CS_SNAPMODULE32 |
2f42a7b0cf94
Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13771
diff
changeset
|
118 | TH32CS_SNAPMODULE32 |
2f42a7b0cf94
Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13771
diff
changeset
|
119 #endif |
2f42a7b0cf94
Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13771
diff
changeset
|
120 , 0); |
6080 | 121 |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
122 if (h != INVALID_HANDLE_VALUE) |
6080 | 123 { |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
124 MODULEENTRY32 mod_info; |
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
125 |
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
126 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
|
127 mod_info.dwSize = sizeof (mod_info); |
13751
be7ff59cbc7a
Fix octinterp DLL searching on Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13282
diff
changeset
|
128 |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
129 if (Module32First (h, &mod_info)) |
14445 | 130 { |
131 do | |
132 { | |
133 std::string mod_name (mod_info.szModule); | |
6080 | 134 |
14445 | 135 if (mod_name.find ("octinterp") != std::string::npos) |
136 { | |
137 bin_dir = mod_info.szExePath; | |
138 if (bin_dir[bin_dir.length () - 1] != '\\') | |
139 bin_dir.append (1, '\\'); | |
140 break; | |
141 } | |
142 } | |
143 while (Module32Next (h, &mod_info)); | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
144 } |
13771
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
145 |
80b30e186b73
[Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13751
diff
changeset
|
146 CloseHandle (h); |
6080 | 147 } |
148 | |
149 if (! bin_dir.empty ()) | |
150 { | |
151 size_t pos = bin_dir.rfind ("\\bin\\"); | |
152 | |
8021 | 153 if (pos != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
154 octave_env::putenv ("OCTAVE_HOME", bin_dir.substr (0, pos)); |
6080 | 155 } |
156 } | |
157 | |
6960 | 158 void |
5451 | 159 w32_set_quiet_shutdown (void) |
160 { | |
161 // Let the user close the console window or shutdown without the | |
162 // pesky dialog. | |
163 // | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
164 // FIXME: should this be user configurable? |
5451 | 165 SetProcessShutdownParameters (0x280, SHUTDOWN_NORETRY); |
166 } | |
167 | |
6960 | 168 void |
5451 | 169 MINGW_signal_cleanup (void) |
170 { | |
5455 | 171 w32_set_quiet_shutdown (); |
5451 | 172 } |
19302
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
173 |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
174 static void |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
175 w32_init (void) |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
176 { |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
177 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
|
178 |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
179 command_editor::prefer_env_winsize (true); |
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
180 } |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
181 |
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
182 static bool |
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
183 w32_shell_execute (const std::string& file) |
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
184 { |
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
185 } |
5451 | 186 #endif |
187 | |
19856
5c1a38089f89
Change open_with_system_app to internal function.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
188 DEFUN (__open_with_system_app__, args, , |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19857
diff
changeset
|
189 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
190 @deftypefn {} {} __open_with_system_app__ (@var{file})\n\ |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
191 Undocumented internal function.\n\ |
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
192 @end deftypefn") |
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
193 { |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
194 octave_value retval; |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
195 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
196 if (args.length () != 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
197 print_usage (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
198 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
199 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
|
200 |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
201 #if defined (__WIN32__) && ! defined (_POSIX_VERSION) |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
202 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
|
203 SW_SHOWNORMAL); |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
204 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
205 // 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
|
206 retval = (reinterpret_cast<ptrdiff_t> (status) > 32); |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
207 #else |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
208 octave_value_list tmp |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
209 = 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
|
210 false, "async"), |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
211 1); |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
212 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
213 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
|
214 #endif |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
215 |
19774
904912f18357
make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
216 return retval; |
19271
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
217 } |
030d56f67363
implement the open function
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
218 |
5451 | 219 #if defined (__MINGW32__) |
220 static void | |
221 MINGW_init (void) | |
222 { | |
19302
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
223 w32_init (); |
5451 | 224 } |
225 #endif | |
226 | |
6080 | 227 #if defined (_MSC_VER) |
228 static void | |
229 MSVC_init (void) | |
230 { | |
19302
37159a873c96
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18674
diff
changeset
|
231 w32_init (); |
6080 | 232 } |
233 #endif | |
234 | |
4091 | 235 |
6598 | 236 // Return TRUE if FILE1 and FILE2 refer to the same (physical) file. |
237 | |
238 bool | |
239 same_file_internal (const std::string& file1, const std::string& file2) | |
240 { | |
241 #ifdef OCTAVE_USE_WINDOWS_API | |
242 | |
6691 | 243 bool retval = false; |
244 | |
16564
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
245 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
|
246 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
|
247 |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
248 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
|
249 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
|
250 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
251 // Windows native code |
6598 | 252 // Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx |
253 | |
16564
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
254 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
|
255 |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
256 HANDLE hfile1 |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
257 = 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
|
258 f1_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0); |
6691 | 259 |
260 if (hfile1 != INVALID_HANDLE_VALUE) | |
261 { | |
16564
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
262 HANDLE hfile2 |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
263 = 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
|
264 f2_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0); |
6598 | 265 |
6691 | 266 if (hfile2 != INVALID_HANDLE_VALUE) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
267 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
268 BY_HANDLE_FILE_INFORMATION hfi1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
269 BY_HANDLE_FILE_INFORMATION hfi2; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
270 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
271 if (GetFileInformationByHandle (hfile1, &hfi1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
272 && 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
|
273 { |
aa5299a1d770
* sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents:
16537
diff
changeset
|
274 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
|
275 && 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
|
276 && 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
|
277 } |
6598 | 278 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
279 CloseHandle (hfile2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
280 } |
6691 | 281 |
6598 | 282 CloseHandle (hfile1); |
283 } | |
6691 | 284 |
285 return retval; | |
6598 | 286 |
287 #else | |
288 | |
289 // POSIX Code | |
290 | |
291 file_stat fs_file1 (file1); | |
292 file_stat fs_file2 (file2); | |
293 | |
294 return (fs_file1 && fs_file2 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
295 && fs_file1.ino () == fs_file2.ino () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
296 && fs_file1.dev () == fs_file2.dev ()); |
6598 | 297 |
298 #endif | |
299 } | |
300 | |
1 | 301 void |
302 sysdep_init (void) | |
303 { | |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14445
diff
changeset
|
304 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__) |
2508 | 305 BSD_init (); |
5451 | 306 #elif defined (__MINGW32__) |
307 MINGW_init (); | |
6080 | 308 #elif defined (_MSC_VER) |
309 MSVC_init (); | |
1 | 310 #endif |
311 } | |
312 | |
5451 | 313 void |
314 sysdep_cleanup (void) | |
315 { | |
316 MINGW_SIGNAL_CLEANUP (); | |
317 } | |
318 | |
767 | 319 // Set terminal in raw mode. From less-177. |
320 // | |
321 // 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
|
322 // "Raw mode" means |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
323 // 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
|
324 // 2. Input is not echoed. |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
325 // 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
|
326 // 4. \t is NOT expanded into spaces. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
327 // 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
|
328 // etc. are NOT disabled. |
767 | 329 // It doesn't matter whether an input \n is mapped to \r, or vice versa. |
330 | |
529 | 331 void |
3657 | 332 raw_mode (bool on, bool wait) |
529 | 333 { |
3657 | 334 static bool curr_on = false; |
529 | 335 |
336 int tty_fd = STDIN_FILENO; | |
14160 | 337 if (! gnulib::isatty (tty_fd)) |
529 | 338 { |
19849
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19774
diff
changeset
|
339 if (interactive && ! forced_interactive) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
340 error ("stdin is not a tty!"); |
529 | 341 } |
342 | |
343 if (on == curr_on) | |
344 return; | |
345 | |
346 #if defined (HAVE_TERMIOS_H) | |
347 { | |
348 struct termios s; | |
349 static struct termios save_term; | |
350 | |
351 if (on) | |
352 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
353 // Get terminal modes. |
529 | 354 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
355 tcgetattr (tty_fd, &s); |
529 | 356 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
357 // Save modes and set certain variables dependent on modes. |
529 | 358 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
359 save_term = s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
360 // ospeed = s.c_cflag & CBAUD; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
361 // erase_char = s.c_cc[VERASE]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
362 // kill_char = s.c_cc[VKILL]; |
529 | 363 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
364 // Set the modes to the way we want them. |
529 | 365 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
366 s.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
367 s.c_oflag |= (OPOST|ONLCR); |
529 | 368 #if defined (OCRNL) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
369 s.c_oflag &= ~(OCRNL); |
529 | 370 #endif |
371 #if defined (ONOCR) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
372 s.c_oflag &= ~(ONOCR); |
529 | 373 #endif |
374 #if defined (ONLRET) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
375 s.c_oflag &= ~(ONLRET); |
529 | 376 #endif |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
377 s.c_cc[VMIN] = wait ? 1 : 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
378 s.c_cc[VTIME] = 0; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
379 } |
529 | 380 else |
381 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
382 // Restore saved modes. |
1358 | 383 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
384 s = save_term; |
529 | 385 } |
3658 | 386 |
9411
c9636d98e5cd
fix kbhit(1) to not discard waiting keystrokes
Joe Rothweiler <octaveuser@sensicomm.com>
parents:
9242
diff
changeset
|
387 tcsetattr (tty_fd, wait ? TCSAFLUSH : TCSADRAIN, &s); |
529 | 388 } |
389 #elif defined (HAVE_TERMIO_H) | |
390 { | |
391 struct termio s; | |
392 static struct termio save_term; | |
393 | |
394 if (on) | |
395 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
396 // Get terminal modes. |
529 | 397 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
398 ioctl (tty_fd, TCGETA, &s); |
529 | 399 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
400 // Save modes and set certain variables dependent on modes. |
529 | 401 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
402 save_term = s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
403 // ospeed = s.c_cflag & CBAUD; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
404 // erase_char = s.c_cc[VERASE]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
405 // kill_char = s.c_cc[VKILL]; |
529 | 406 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
407 // Set the modes to the way we want them. |
529 | 408 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
409 s.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
410 s.c_oflag |= (OPOST|ONLCR); |
529 | 411 #if defined (OCRNL) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
412 s.c_oflag &= ~(OCRNL); |
529 | 413 #endif |
414 #if defined (ONOCR) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
415 s.c_oflag &= ~(ONOCR); |
529 | 416 #endif |
417 #if defined (ONLRET) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
418 s.c_oflag &= ~(ONLRET); |
529 | 419 #endif |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
420 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
|
421 } |
529 | 422 else |
423 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
424 // Restore saved modes. |
1358 | 425 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
426 s = save_term; |
529 | 427 } |
3658 | 428 |
529 | 429 ioctl (tty_fd, TCSETAW, &s); |
430 } | |
431 #elif defined (HAVE_SGTTY_H) | |
432 { | |
433 struct sgttyb s; | |
434 static struct sgttyb save_term; | |
435 | |
436 if (on) | |
437 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
438 // Get terminal modes. |
529 | 439 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
440 ioctl (tty_fd, TIOCGETP, &s); |
529 | 441 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
442 // Save modes and set certain variables dependent on modes. |
529 | 443 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
444 save_term = s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
445 // ospeed = s.sg_ospeed; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
446 // erase_char = s.sg_erase; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
447 // kill_char = s.sg_kill; |
529 | 448 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
449 // Set the modes to the way we want them. |
529 | 450 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
451 s.sg_flags |= CBREAK; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
452 s.sg_flags &= ~(ECHO); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
453 } |
529 | 454 else |
455 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
456 // Restore saved modes. |
1358 | 457 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
458 s = save_term; |
529 | 459 } |
3658 | 460 |
529 | 461 ioctl (tty_fd, TIOCSETN, &s); |
462 } | |
463 #else | |
4064 | 464 warning ("no support for raw mode console I/O on this system"); |
465 | |
466 // Make sure the current mode doesn't toggle. | |
467 on = curr_on; | |
529 | 468 #endif |
469 | |
470 curr_on = on; | |
471 } | |
472 | |
6726 | 473 FILE * |
474 octave_popen (const char *command, const char *mode) | |
475 { | |
476 #if defined (__MINGW32__) || defined (_MSC_VER) | |
477 if (mode && mode[0] && ! mode[1]) | |
478 { | |
479 char tmode[3]; | |
480 tmode[0] = mode[0]; | |
481 tmode[1] = 'b'; | |
482 tmode[2] = 0; | |
483 | |
484 return _popen (command, tmode); | |
485 } | |
486 else | |
487 return _popen (command, mode); | |
488 #else | |
489 return popen (command, mode); | |
490 #endif | |
491 } | |
492 | |
493 int | |
494 octave_pclose (FILE *f) | |
495 { | |
496 #if defined (__MINGW32__) || defined (_MSC_VER) | |
497 return _pclose (f); | |
498 #else | |
499 return pclose (f); | |
500 #endif | |
501 } | |
502 | |
767 | 503 // Read one character from the terminal. |
504 | |
529 | 505 int |
4067 | 506 octave_kbhit (bool wait) |
529 | 507 { |
20788
a2b96b523472
Rewrite a8ee668e7fd7 to use #if defined rather than #ifdef.
Rik <rik@octave.org>
parents:
20786
diff
changeset
|
508 #if defined (HAVE__KBHIT) && defined (HAVE__GETCH) |
20786
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
509 // 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
|
510 int c; |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
511 |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
512 if (wait) |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
513 c = _getch (); |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
514 else |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
515 c = (! _kbhit ()) ? 0 : _getch (); |
a8ee668e7fd7
Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
516 |
4067 | 517 #else |
3658 | 518 raw_mode (true, wait); |
519 | |
5770 | 520 // Get current handler. |
521 octave_interrupt_handler saved_interrupt_handler | |
522 = octave_ignore_interrupts (); | |
523 | |
524 // Restore it, disabling system call restarts (if possible) so the | |
525 // read can be interrupted. | |
526 | |
527 octave_set_interrupt_handler (saved_interrupt_handler, false); | |
528 | |
3658 | 529 int c = std::cin.get (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
530 |
3658 | 531 if (std::cin.fail () || std::cin.eof ()) |
532 std::cin.clear (); | |
533 | |
5770 | 534 // Restore it, enabling system call restarts (if possible). |
535 octave_set_interrupt_handler (saved_interrupt_handler, true); | |
536 | |
3658 | 537 raw_mode (false, true); |
4067 | 538 #endif |
3658 | 539 |
529 | 540 return c; |
541 } | |
542 | |
12228
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
543 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
|
544 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
|
545 { |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
546 #if defined (__WIN32__) && ! defined (_POSIX_VERSION) |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
547 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
548 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
|
549 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
550 #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
|
551 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
|
552 #endif |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
553 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
554 // 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
|
555 // 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
|
556 // 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
|
557 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
558 if (retval.empty () || retval == "\\") |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
559 { |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
560 retval = octave_env::getenv ("TEMP"); |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
561 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
562 if (retval.empty ()) |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
563 retval = octave_env::getenv ("TMP"); |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
564 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
565 if (retval.empty ()) |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
566 retval = "c:\\temp"; |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
567 } |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
568 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
569 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
|
570 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
571 #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
|
572 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
573 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
|
574 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
575 #else |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
576 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
577 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
|
578 |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
579 #endif |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
580 } |
0f70c5db58c3
try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
581 |
1957 | 582 DEFUN (clc, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
583 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
584 @deftypefn {} {} clc ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
585 @deftypefnx {} {} home ()\n\ |
3332 | 586 Clear the terminal screen and move the cursor to the upper left corner.\n\ |
3333 | 587 @end deftypefn") |
529 | 588 { |
16537
106a38d7b396
optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents:
16404
diff
changeset
|
589 bool skip_redisplay = true; |
106a38d7b396
optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents:
16404
diff
changeset
|
590 |
106a38d7b396
optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents:
16404
diff
changeset
|
591 command_editor::clear_screen (skip_redisplay); |
529 | 592 |
2926 | 593 return octave_value_list (); |
529 | 594 } |
595 | |
549 | 596 DEFALIAS (home, clc); |
597 | |
1957 | 598 DEFUN (getenv, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
599 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
600 @deftypefn {} {} getenv (@var{var})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
601 Return the value of the environment variable @var{var}.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
602 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
603 For example,\n\ |
3301 | 604 \n\ |
605 @example\n\ | |
606 getenv (\"PATH\")\n\ | |
607 @end example\n\ | |
608 \n\ | |
609 @noindent\n\ | |
610 returns a string containing the value of your path.\n\ | |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
611 @seealso{setenv, unsetenv}\n\ |
3301 | 612 @end deftypefn") |
529 | 613 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
614 if (args.length () != 1) |
5823 | 615 print_usage (); |
529 | 616 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
617 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
|
618 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
619 return octave_value (octave_env::getenv (name)); |
529 | 620 } |
621 | |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
622 /* |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
623 %!assert (ischar (getenv ("OCTAVE_HOME"))) |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
624 */ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
625 |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
626 DEFUN (setenv, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
627 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
628 @deftypefn {} {} setenv (@var{var}, @var{value})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
629 @deftypefnx {} {} setenv (@var{var})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
630 @deftypefnx {} {} putenv (@dots{})\n\ |
3301 | 631 Set the value of the environment variable @var{var} to @var{value}.\n\ |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
632 \n\ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
633 If no @var{value} is specified then the variable will be assigned the null\n\ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
634 string.\n\ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
635 @seealso{unsetenv, getenv}\n\ |
3301 | 636 @end deftypefn") |
1706 | 637 { |
2086 | 638 octave_value_list retval; |
1706 | 639 |
640 int nargin = args.length (); | |
641 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
642 if (nargin < 1 || nargin > 2) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
643 print_usage (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
644 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
645 std::string var = args(0).xstring_value ("setenv: VAR must be a string"); |
1706 | 646 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
647 std::string val = (nargin == 2 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
648 ? args(1).xstring_value ("setenv: VALUE must be a string") |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
649 : std::string ()); |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
650 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
651 octave_env::putenv (var, val); |
1706 | 652 |
653 return retval; | |
654 } | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
655 |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
656 DEFALIAS (putenv, setenv); |
1706 | 657 |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
658 /* |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
659 %!test |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
660 %! 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
|
661 %! 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
|
662 %! unsetenv ("dummy_variable_that_cannot_matter"); |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
663 %! assert (getenv ("dummy_variable_that_cannot_matter"), ""); |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
664 */ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
665 |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
666 DEFUN (unsetenv, args, , |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
667 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
668 @deftypefn {} {@var{status} =} unsetenv (@var{var})\n\ |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
669 Delete the environment variable @var{var}.\n\ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
670 \n\ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
671 Return 0 if the variable was deleted, or did not exist, and -1 if an error\n\ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
672 occurred.\n\ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
673 @seealso{setenv, getenv}\n\ |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
674 @end deftypefn") |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
675 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
676 if (args.length () != 1) |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
677 print_usage (); |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
678 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
679 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
|
680 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
681 return octave_value (gnulib::unsetenv (tmp.c_str ())); |
19167
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
682 } |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
683 |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
684 /* |
6f0290863d50
Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents:
18674
diff
changeset
|
685 ## 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
|
686 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
687 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
688 // FIXME: perhaps kbhit should also be able to print a prompt? |
3372 | 689 |
3657 | 690 DEFUN (kbhit, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
691 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
692 @deftypefn {} {} kbhit ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
693 @deftypefnx {} {} kbhit (1)\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
694 Read a single keystroke from the keyboard.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
695 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
696 If called with an argument, don't wait for a keypress.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
697 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
698 For example,\n\ |
3372 | 699 \n\ |
700 @example\n\ | |
701 x = kbhit ();\n\ | |
702 @end example\n\ | |
703 \n\ | |
704 @noindent\n\ | |
705 will set @var{x} to the next character typed at the keyboard as soon as\n\ | |
706 it is typed.\n\ | |
3657 | 707 \n\ |
708 @example\n\ | |
709 x = kbhit (1);\n\ | |
710 @end example\n\ | |
711 \n\ | |
712 @noindent\n\ | |
16053
119ce9f5e1a3
doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents:
16015
diff
changeset
|
713 is identical to the above example, but doesn't wait for a keypress,\n\ |
3657 | 714 returning the empty string if no key is available.\n\ |
18674
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
17851
diff
changeset
|
715 @seealso{input, pause}\n\ |
3372 | 716 @end deftypefn") |
529 | 717 { |
4233 | 718 octave_value retval; |
529 | 719 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
720 // FIXME: add timeout and default value args? |
529 | 721 |
19849
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19774
diff
changeset
|
722 if (interactive) |
529 | 723 { |
15423
53d073233fa4
call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
724 Fdrawnow (); |
6423 | 725 |
4067 | 726 int c = octave_kbhit (args.length () == 0); |
3657 | 727 |
3658 | 728 if (c == -1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
729 c = 0; |
3657 | 730 |
16092
def3b111cff8
avoid gcc warning about int to char conversion
John W. Eaton <jwe@octave.org>
parents:
16053
diff
changeset
|
731 char s[2] = { static_cast<char> (c), '\0' }; |
16015 | 732 |
529 | 733 retval = s; |
734 } | |
735 | |
736 return retval; | |
737 } | |
738 | |
1957 | 739 DEFUN (pause, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
740 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
741 @deftypefn {} {} pause ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
742 @deftypefnx {} {} pause (@var{n})\n\ |
18674
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
17851
diff
changeset
|
743 Suspend the execution of the program for @var{n} seconds.\n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
17851
diff
changeset
|
744 \n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
17851
diff
changeset
|
745 If invoked without an input arguments then the program is suspended until a\n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
17851
diff
changeset
|
746 character is typed.\n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
17851
diff
changeset
|
747 \n\ |
20923
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
748 @var{n} is a positive real value and may be a fraction of a second,\n\ |
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
749 for example:\n\ |
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
750 \n\ |
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
751 @example\n\ |
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
752 @group\n\ |
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
753 tic; pause (0.05); toc\n\ |
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
754 @print{} Elapsed time is 0.05039 seconds.\n\ |
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
755 @end group\n\ |
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
756 @end example\n\ |
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
757 \n\ |
18674
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
17851
diff
changeset
|
758 The following example prints a message and then waits 5 seconds before\n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
17851
diff
changeset
|
759 clearing the screen.\n\ |
3301 | 760 \n\ |
761 @example\n\ | |
762 @group\n\ | |
20923
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
763 disp (\"wait please...\");\n\ |
3301 | 764 pause (5);\n\ |
765 clc;\n\ | |
766 @end group\n\ | |
767 @end example\n\ | |
20923
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
768 \n\ |
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20853
diff
changeset
|
769 @seealso{kbhit}\n\ |
3301 | 770 @end deftypefn") |
529 | 771 { |
2086 | 772 octave_value_list retval; |
529 | 773 |
774 int nargin = args.length (); | |
775 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
776 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
777 print_usage (); |
529 | 778 |
1579 | 779 if (nargin == 1) |
529 | 780 { |
1579 | 781 double dval = args(0).double_value (); |
636 | 782 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
783 if (! xisnan (dval)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
784 { |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
785 Fdrawnow (); |
6419 | 786 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
787 if (xisinf (dval)) |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
788 { |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
789 flush_octave_stdout (); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
790 octave_kbhit (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
791 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
792 else |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
793 octave_sleep (dval); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
794 } |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
795 else |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20181
diff
changeset
|
796 warning ("pause: NaN is an invalid delay"); |
529 | 797 } |
1579 | 798 else |
3234 | 799 { |
15423
53d073233fa4
call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
800 Fdrawnow (); |
3234 | 801 flush_octave_stdout (); |
4067 | 802 octave_kbhit (); |
3234 | 803 } |
2630 | 804 |
805 return retval; | |
806 } | |
807 | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
808 /* |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
809 %!test |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
810 %! pause (1); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
811 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
812 %!error (pause (1, 2)) |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
813 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
814 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
815 // FIXME: maybe this should only return 1 if IEEE floating |
862 | 816 // point functions really work. |
817 | |
1957 | 818 DEFUN (isieee, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
819 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
820 @deftypefn {} {} isieee ()\n\ |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11234
diff
changeset
|
821 Return true if your computer @emph{claims} to conform to the IEEE standard\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
822 for floating point calculations.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
823 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
824 No actual tests are performed.\n\ |
3301 | 825 @end deftypefn") |
862 | 826 { |
4600 | 827 oct_mach_info::float_format flt_fmt = oct_mach_info::native_float_format (); |
2317 | 828 |
4574 | 829 return octave_value (flt_fmt == oct_mach_info::flt_fmt_ieee_little_endian |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10266
diff
changeset
|
830 || flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian); |
862 | 831 } |
832 | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
833 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
834 %!assert (islogical (isieee ())) |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
835 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
836 |
4600 | 837 DEFUN (native_float_format, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
838 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
839 @deftypefn {} {} native_float_format ()\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
840 Return the native floating point format as a string.\n\ |
4600 | 841 @end deftypefn") |
842 { | |
843 oct_mach_info::float_format flt_fmt = oct_mach_info::native_float_format (); | |
844 | |
845 return octave_value (oct_mach_info::float_format_as_string (flt_fmt)); | |
846 } | |
847 | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
848 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
849 %!assert (ischar (native_float_format ())) |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
850 */ |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
851 |
1957 | 852 DEFUN (tilde_expand, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
853 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
854 @deftypefn {} {} tilde_expand (@var{string})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
855 @deftypefnx {} {} tilde_expand (@var{cellstr})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
856 Perform tilde expansion on @var{string}.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
857 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
858 If @var{string} begins with a tilde character, (@samp{~}), all of the\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
859 characters preceding the first slash (or all characters, if there is no\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
860 slash) are treated as a possible user name, and the tilde and the following\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
861 characters up to the slash are replaced by the home directory of the named\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
862 user. If the tilde is followed immediately by a slash, the tilde is\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
863 replaced by the home directory of the user running Octave.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20064
diff
changeset
|
864 \n\ |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20704
diff
changeset
|
865 If the input is a cell array of strings @var{cellstr} then tilde expansion\n\ |
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20704
diff
changeset
|
866 is performed on each string element.\n\ |
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20704
diff
changeset
|
867 \n\ |
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20704
diff
changeset
|
868 Examples:\n\ |
3301 | 869 \n\ |
870 @example\n\ | |
871 @group\n\ | |
872 tilde_expand (\"~joeuser/bin\")\n\ | |
873 @result{} \"/home/joeuser/bin\"\n\ | |
874 tilde_expand (\"~/bin\")\n\ | |
875 @result{} \"/home/jwe/bin\"\n\ | |
876 @end group\n\ | |
877 @end example\n\ | |
878 @end deftypefn") | |
1750 | 879 { |
4233 | 880 octave_value retval; |
1750 | 881 |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
882 if (args.length () != 1) |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
883 print_usage (); |
6116 | 884 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
885 octave_value arg = args(0); |
6116 | 886 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
887 string_vector sv = arg.xall_strings ("tilde_expand: argument must be char or cellstr object"); |
6116 | 888 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
889 sv = file_ops::tilde_expand (sv); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
890 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
891 if (arg.is_cellstr ()) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
892 retval = Cell (arg.dims (), sv); |
1750 | 893 else |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20789
diff
changeset
|
894 retval = sv; |
1750 | 895 |
896 return retval; | |
897 } | |
12825
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
898 |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
899 /* |
a1dcb854a4f9
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
900 %!test |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
901 %! 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
|
902 %! 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
|
903 %! 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
|
904 %! 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
|
905 */ |
17851
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
906 |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
907 DEFUN (get_home_directory, , , |
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
908 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
909 @deftypefn {} {@var{homedir} =} get_home_directory ()\n\ |
20024
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
910 Return the current home directory.\n\ |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
911 \n\ |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
912 On most systems, this is equivalent to @code{getenv (\"HOME\")}. On Windows\n\ |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
913 systems, if the environment variable @env{HOME} is not set then it is\n\ |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
914 equivalent to\n\ |
20016
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
915 @code{fullfile (getenv (\"HOMEDRIVE\"), getenv (\"HOMEPATH\"))}\n\ |
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
916 @seealso{getenv}\n\ |
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
917 @end deftypefn") |
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
918 { |
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
919 return octave_value (octave_env::get_home_directory ()); |
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
920 } |
47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
921 |
20024
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
922 /* |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
923 %!test |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
924 %! if (! ispc ()) |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20172
diff
changeset
|
925 %! 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
|
926 %! endif |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
927 */ |
cf9b94a89620
Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents:
20016
diff
changeset
|
928 |
17851
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
929 // This function really belongs in display.cc, but including defun.h in |
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
930 // that file results in conflicts with symbols from headers that are |
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
931 // needed for X11 and Carbon functions. |
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
932 |
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
933 DEFUN (have_window_system, , , |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19857
diff
changeset
|
934 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
935 @deftypefn {} {} have_window_system ()\n\ |
18674
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
17851
diff
changeset
|
936 Return true if a window system is available (X11, Windows, or Apple OS X)\n\ |
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
17851
diff
changeset
|
937 and false otherwise.\n\ |
19857
bf511802add7
doc: Add have_window_system() to documentation.
Rik <rik@octave.org>
parents:
19856
diff
changeset
|
938 @seealso{isguirunning}\n\ |
17851
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
939 @end deftypefn") |
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
940 { |
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
941 return octave_value (display_info::display_available ()); |
af685269e06c
avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
942 } |