annotate libinterp/corefcn/sysdep.cc @ 22096:b8f92ea626e7

include builtins.h only where needed * graphics.cc, sysdep.cc, __init_gnuplot__.cc, ov-usr-fcn.cc: Don't include builtins.h.
author John W. Eaton <jwe@octave.org>
date Tue, 12 Jul 2016 09:40:09 -0400
parents 9203833cab7d
children 5ad67277b007
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6960
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6960
diff changeset
10 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6960
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6960
diff changeset
19 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
1346
9e41dbb74bca [project @ 1995-09-05 06:37:49 by jwe]
jwe
parents: 1343
diff changeset
27 #include <cfloat>
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1318
diff changeset
28 #include <cstddef>
1346
9e41dbb74bca [project @ 1995-09-05 06:37:49 by jwe]
jwe
parents: 1343
diff changeset
29 #include <cstdio>
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1318
diff changeset
30 #include <cstdlib>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1318
diff changeset
31 #include <cstring>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1318
diff changeset
32
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3372
diff changeset
33 #include <iostream>
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1711
diff changeset
34 #include <string>
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1711
diff changeset
35
1430
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1415
diff changeset
36 #if defined (HAVE_TERMIOS_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
37 # include <termios.h>
1430
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1415
diff changeset
38 #elif defined (HAVE_TERMIO_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
39 # include <termio.h>
1430
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1415
diff changeset
40 #elif defined (HAVE_SGTTY_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
41 # include <sgtty.h>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
42 #endif
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
43
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
44 #if defined (HAVE_CONIO_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
45 # include <conio.h>
1430
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1415
diff changeset
46 #endif
045e70a15a8f [project @ 1995-09-19 07:05:37 by jwe]
jwe
parents: 1415
diff changeset
47
3248
68259f410026 [project @ 1999-07-13 03:34:54 by jwe]
jwe
parents: 3234
diff changeset
48 #if defined (HAVE_SYS_IOCTL_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
49 # include <sys/ioctl.h>
3248
68259f410026 [project @ 1999-07-13 03:34:54 by jwe]
jwe
parents: 3234
diff changeset
50 #endif
68259f410026 [project @ 1999-07-13 03:34:54 by jwe]
jwe
parents: 3234
diff changeset
51
1463
592291d9dfbb [project @ 1995-09-22 07:18:44 by jwe]
jwe
parents: 1430
diff changeset
52 #if defined (HAVE_FLOATINGPOINT_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
53 # include <floatingpoint.h>
1463
592291d9dfbb [project @ 1995-09-22 07:18:44 by jwe]
jwe
parents: 1430
diff changeset
54 #endif
592291d9dfbb [project @ 1995-09-22 07:18:44 by jwe]
jwe
parents: 1430
diff changeset
55
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
56 #if defined (HAVE_IEEEFP_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
57 # include <ieeefp.h>
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
58 #endif
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
59
21554
9f0088f3f335 call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 20788
diff changeset
60 #if defined (HAVE_OMP_H)
21556
12f207a534aa maint: merge stable to default.
John W. Eaton <jwe@octave.org>
parents: 21301 21554
diff changeset
61 # include <omp.h>
21554
9f0088f3f335 call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 20788
diff changeset
62 #endif
9f0088f3f335 call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 20788
diff changeset
63
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2893
diff changeset
64 #include "cmd-edit.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2893
diff changeset
65 #include "file-ops.h"
2893
9fd1df4b464a [project @ 1997-04-28 02:07:38 by jwe]
jwe
parents: 2847
diff changeset
66 #include "lo-mappers.h"
7231
2eb392d058bb [project @ 2007-11-30 18:53:29 by jwe]
jwe
parents: 7017
diff changeset
67 #include "lo-math.h"
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 2086
diff changeset
68 #include "mach-info.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2893
diff changeset
69 #include "oct-env.h"
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
70 #include "quit.h"
21910
4d723ba06b4a provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
71 #include "unistd-wrappers.h"
21888
00f1249f2483 create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
72 #include "unsetenv-wrapper.h"
1769
bc7ae9be3378 [project @ 1996-01-23 06:49:08 by jwe]
jwe
parents: 1755
diff changeset
73
6208
323be5eeed1f [project @ 2006-12-06 20:23:18 by jwe]
jwe
parents: 6135
diff changeset
74 #include "Cell.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
75 #include "defun.h"
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
76 #include "display.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
77 #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
78 #include "errwarn.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
79 #include "input.h"
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
80 #include "octave.h"
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
81 #include "ov.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
82 #include "ovl.h"
3234
be8e0ba13644 [project @ 1999-01-29 03:52:30 by jwe]
jwe
parents: 3124
diff changeset
83 #include "pager.h"
6419
73fcbac81f33 [project @ 2007-03-20 17:18:24 by jwe]
jwe
parents: 6208
diff changeset
84 #include "parse.h"
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
85 #include "sighandlers.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
86 #include "sysdep.h"
22094
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
87 #include "interpreter.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
88 #include "utils.h"
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
89 #include "file-stat.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
90
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21662
diff changeset
91 #if ! defined (STDIN_FILENO)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
92 # define STDIN_FILENO 1
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
93 #endif
444
ba637cc5c5f3 [project @ 1994-06-02 17:15:07 by jwe]
jwe
parents: 401
diff changeset
94
9441
160c564d5d25 initialize floating point values properly for NetBSD systems
Aleksej Saushev <asau@inbox.ru>
parents: 9411
diff changeset
95 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__)
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
96 static void
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
97 BSD_init (void)
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
98 {
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
99 # if defined (HAVE_FLOATINGPOINT_H)
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
100 // 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
101 # if ! defined (FP_X_DNML)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
102 # define FP_X_DNML 0
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21115
diff changeset
103 # endif
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
104 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
105 # endif
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
106 }
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
107 #endif
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
108
22019
2d8e9bdf5683 Dont use OCTAVE_USE_WINDOWS_API for w32_XXXX function definitions (Bug #48352)
John Donoghue
parents: 21989
diff changeset
109 #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
110
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
111 #define WIN32_LEAN_AND_MEAN
21949
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21910
diff changeset
112 #include <windows.h>
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
113 #include <tlhelp32.h>
21949
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21910
diff changeset
114 #include <shellapi.h>
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
115
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
116 static void
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
117 w32_set_octave_home (void)
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
118 {
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
119 std::string bin_dir;
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
120
13885
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
121 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
122 #if defined (TH32CS_SNAPMODULE32)
13885
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
123 | TH32CS_SNAPMODULE32
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
124 #endif
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
125 , 0);
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
126
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
127 if (h != INVALID_HANDLE_VALUE)
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
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 MODULEENTRY32 mod_info;
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
130
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
131 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
132 mod_info.dwSize = sizeof (mod_info);
13751
be7ff59cbc7a Fix octinterp DLL searching on Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13282
diff changeset
133
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
134 if (Module32First (h, &mod_info))
14445
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
135 {
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
136 do
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
137 {
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
138 std::string mod_name (mod_info.szModule);
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
139
14445
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
140 if (mod_name.find ("octinterp") != std::string::npos)
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
141 {
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
142 bin_dir = mod_info.szExePath;
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
143 if (bin_dir[bin_dir.length () - 1] != '\\')
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
144 bin_dir.append (1, '\\');
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
145 break;
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
146 }
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
147 }
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
148 while (Module32Next (h, &mod_info));
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
149 }
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
150
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
151 CloseHandle (h);
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
152 }
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
153
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
154 if (! bin_dir.empty ())
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
155 {
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
156 size_t pos = bin_dir.rfind ("\\bin\\");
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
157
8021
85184151822e fix typo in NPOS change
John W. Eaton <jwe@octave.org>
parents: 8019
diff changeset
158 if (pos != std::string::npos)
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
159 octave::sys::env::putenv ("OCTAVE_HOME", bin_dir.substr (0, pos));
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
160 }
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
161 }
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
162
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
163 static void
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
164 w32_init (void)
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
165 {
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
166 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
167
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
168 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
169 }
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
170
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
171 static bool
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
172 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
173 {
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
174 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
175 #endif
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
176
19856
5c1a38089f89 Change open_with_system_app to internal function.
Rik <rik@octave.org>
parents: 19849
diff changeset
177 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
178 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
179 @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
180 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
181 @end deftypefn */)
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
182 {
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
183 if (args.length () != 1)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
184 print_usage ();
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
185
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
186 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
187
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
188 octave_value retval;
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
189
21979
d04da18a407a use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
190 #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
191 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
192 SW_SHOWNORMAL);
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
193
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
194 // 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
195 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
196 #elif defined (__APPLE__)
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
197 octave_value_list tmp
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
198 = 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
199 false, "async"),
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
200 1);
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
201
20961
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
202 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
203 #else
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
204 octave_value_list tmp
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
205 = 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
206 false, "async"),
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
207 1);
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
208
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
209 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
210 #endif
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
211
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
212 return retval;
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
213 }
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
214
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
215 #if defined (__MINGW32__)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
216 static void
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
217 MINGW_init (void)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
218 {
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
219 w32_init ();
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
220 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
221 #endif
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
222
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
223 #if defined (_MSC_VER)
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
224 static void
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
225 MSVC_init (void)
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
226 {
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
227 w32_init ();
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
228 }
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
229 #endif
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
230
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
231 // Return TRUE if FILE1 and FILE2 refer to the same (physical) file.
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
232
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
233 bool
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
234 same_file_internal (const std::string& file1, const std::string& file2)
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
235 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21662
diff changeset
236 #if defined (OCTAVE_USE_WINDOWS_API)
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
237
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
238 bool retval = false;
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
239
16564
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
240 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
241 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
242
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
243 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
244 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
245
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
246 // Windows native code
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
247 // Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
248
16564
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
249 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
250
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
251 HANDLE hfile1
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
252 = 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
253 f1_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0);
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
254
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
255 if (hfile1 != INVALID_HANDLE_VALUE)
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
256 {
16564
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
257 HANDLE hfile2
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
258 = 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
259 f2_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0);
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
260
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
261 if (hfile2 != INVALID_HANDLE_VALUE)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
262 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
263 BY_HANDLE_FILE_INFORMATION hfi1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
264 BY_HANDLE_FILE_INFORMATION hfi2;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
265
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
266 if (GetFileInformationByHandle (hfile1, &hfi1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
267 && 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
268 {
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
269 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
270 && 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
271 && 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
272 }
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
273
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
274 CloseHandle (hfile2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
275 }
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
276
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
277 CloseHandle (hfile1);
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
278 }
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
279
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
280 return retval;
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
281
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
282 #else
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
283
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
284 // POSIX Code
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
285
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
286 octave::sys::file_stat fs_file1 (file1);
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
287 octave::sys::file_stat fs_file2 (file2);
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
288
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
289 return (fs_file1 && fs_file2
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
290 && fs_file1.ino () == fs_file2.ino ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
291 && fs_file1.dev () == fs_file2.dev ());
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
292
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
293 #endif
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
294 }
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
295
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
296 void
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
297 sysdep_init (void)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
298 {
21557
f6663c49870c Add comment clarifying why omp_get_num_threads is called in sysdep.cc.
Rik <rik@octave.org>
parents: 21556
diff changeset
299 // 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
300 // 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
301 // 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
302 #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
303 omp_get_num_threads ();
9f0088f3f335 call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 20788
diff changeset
304 #endif
9f0088f3f335 call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 20788
diff changeset
305
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14445
diff changeset
306 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__)
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
307 BSD_init ();
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
308 #elif defined (__MINGW32__)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
309 MINGW_init ();
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
310 #elif defined (_MSC_VER)
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
311 MSVC_init ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
312 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
313 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
314
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
315 void
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
316 sysdep_cleanup (void)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
317 {
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
318 #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
319 // 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
320 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
321 #endif
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
322 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
323
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
324 // Set terminal in raw mode. From less-177.
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
325 //
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
326 // 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
327 // "Raw mode" means
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
328 // 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
329 // 2. Input is not echoed.
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
330 // 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
331 // 4. \t is NOT expanded into spaces.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
332 // 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
333 // etc. are NOT disabled.
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
334 // It doesn't matter whether an input \n is mapped to \r, or vice versa.
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
335
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
336 void
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
337 raw_mode (bool on, bool wait)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
338 {
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
339 static bool curr_on = false;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
340
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
341 int tty_fd = STDIN_FILENO;
21910
4d723ba06b4a provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
342 if (! octave_isatty_wrapper (tty_fd))
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
343 {
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
344 if (octave::application::interactive ()
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
345 && ! octave::application::forced_interactive ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
346 error ("stdin is not a tty!");
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
347 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
348
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
349 if (on == curr_on)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
350 return;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
351
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
352 #if defined (HAVE_TERMIOS_H)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
353 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
354 struct termios s;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
355 static struct termios save_term;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
356
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
357 if (on)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
358 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
359 // Get terminal modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
360
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
361 tcgetattr (tty_fd, &s);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
362
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
363 // Save modes and set certain variables dependent on modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
364
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
365 save_term = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
366 // ospeed = s.c_cflag & CBAUD;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
367 // erase_char = s.c_cc[VERASE];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
368 // kill_char = s.c_cc[VKILL];
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
369
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
370 // Set the modes to the way we want them.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
371
21662
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21557
diff changeset
372 s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL);
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21557
diff changeset
373 s.c_oflag |= (OPOST | ONLCR);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
374 #if defined (OCRNL)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
375 s.c_oflag &= ~(OCRNL);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
376 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
377 #if defined (ONOCR)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
378 s.c_oflag &= ~(ONOCR);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
379 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
380 #if defined (ONLRET)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
381 s.c_oflag &= ~(ONLRET);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
382 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
383 s.c_cc[VMIN] = wait ? 1 : 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
384 s.c_cc[VTIME] = 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
385 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
386 else
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
387 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
388 // Restore saved modes.
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
389
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
390 s = save_term;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
391 }
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
392
9411
c9636d98e5cd fix kbhit(1) to not discard waiting keystrokes
Joe Rothweiler <octaveuser@sensicomm.com>
parents: 9242
diff changeset
393 tcsetattr (tty_fd, wait ? TCSAFLUSH : TCSADRAIN, &s);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
394 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
395 #elif defined (HAVE_TERMIO_H)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
396 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
397 struct termio s;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
398 static struct termio save_term;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
399
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
400 if (on)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
401 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
402 // Get terminal modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
403
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
404 ioctl (tty_fd, TCGETA, &s);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
405
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
406 // Save modes and set certain variables dependent on modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
407
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
408 save_term = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
409 // ospeed = s.c_cflag & CBAUD;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
410 // erase_char = s.c_cc[VERASE];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
411 // kill_char = s.c_cc[VKILL];
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
412
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
413 // Set the modes to the way we want them.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
414
21662
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21557
diff changeset
415 s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL);
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21557
diff changeset
416 s.c_oflag |= (OPOST | ONLCR);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
417 #if defined (OCRNL)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
418 s.c_oflag &= ~(OCRNL);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
419 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
420 #if defined (ONOCR)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
421 s.c_oflag &= ~(ONOCR);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
422 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
423 #if defined (ONLRET)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
424 s.c_oflag &= ~(ONLRET);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
425 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
426 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
427 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
428 else
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
429 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
430 // Restore saved modes.
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
431
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
432 s = save_term;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
433 }
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
434
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
435 ioctl (tty_fd, TCSETAW, &s);
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
436 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
437 #elif defined (HAVE_SGTTY_H)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
438 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
439 struct sgttyb s;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
440 static struct sgttyb save_term;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
441
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
442 if (on)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
443 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
444 // Get terminal modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
445
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
446 ioctl (tty_fd, TIOCGETP, &s);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
447
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
448 // Save modes and set certain variables dependent on modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
449
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
450 save_term = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
451 // ospeed = s.sg_ospeed;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
452 // erase_char = s.sg_erase;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
453 // kill_char = s.sg_kill;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
454
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
455 // Set the modes to the way we want them.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
456
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
457 s.sg_flags |= CBREAK;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
458 s.sg_flags &= ~(ECHO);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
459 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
460 else
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
461 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
462 // Restore saved modes.
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
463
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
464 s = save_term;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
465 }
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
466
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
467 ioctl (tty_fd, TIOCSETN, &s);
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
468 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
469 #else
21109
bd1752782e56 Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents: 21078
diff changeset
470 warn_disabled_feature ("", "raw mode console I/O");
4064
b4fa31442a78 [project @ 2002-09-26 21:10:45 by jwe]
jwe
parents: 3676
diff changeset
471
b4fa31442a78 [project @ 2002-09-26 21:10:45 by jwe]
jwe
parents: 3676
diff changeset
472 // Make sure the current mode doesn't toggle.
b4fa31442a78 [project @ 2002-09-26 21:10:45 by jwe]
jwe
parents: 3676
diff changeset
473 on = curr_on;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
474 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
475
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
476 curr_on = on;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
477 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
478
6726
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
479 FILE *
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
480 octave_popen (const char *command, const char *mode)
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
481 {
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
482 #if defined (__MINGW32__) || defined (_MSC_VER)
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
483 if (mode && mode[0] && ! mode[1])
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
484 {
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
485 char tmode[3];
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
486 tmode[0] = mode[0];
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
487 tmode[1] = 'b';
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
488 tmode[2] = 0;
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
489
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
490 return _popen (command, tmode);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
491 }
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
492 else
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
493 return _popen (command, mode);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
494 #else
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
495 return popen (command, mode);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
496 #endif
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
497 }
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
498
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
499 int
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
500 octave_pclose (FILE *f)
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
501 {
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
502 #if defined (__MINGW32__) || defined (_MSC_VER)
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
503 return _pclose (f);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
504 #else
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
505 return pclose (f);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
506 #endif
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
507 }
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
508
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
509 // Read one character from the terminal.
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
510
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
511 int
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
512 octave_kbhit (bool wait)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
513 {
20788
a2b96b523472 Rewrite a8ee668e7fd7 to use #if defined rather than #ifdef.
Rik <rik@octave.org>
parents: 20786
diff changeset
514 #if defined (HAVE__KBHIT) && defined (HAVE__GETCH)
20786
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
515 // 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
516 int c;
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
517
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
518 if (wait)
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
519 c = _getch ();
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
520 else
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
521 c = (! _kbhit ()) ? 0 : _getch ();
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
522
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
523 #else
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
524 raw_mode (true, wait);
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
525
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
526 // Get current handler.
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22019
diff changeset
527 octave::interrupt_handler saved_interrupt_handler
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22019
diff changeset
528 = octave::ignore_interrupts ();
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
529
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
530 // Restore it, disabling system call restarts (if possible) so the
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
531 // read can be interrupted.
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
532
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22019
diff changeset
533 octave::set_interrupt_handler (saved_interrupt_handler, false);
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
534
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
535 int c = std::cin.get ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
536
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
537 if (std::cin.fail () || std::cin.eof ())
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
538 std::cin.clear ();
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
539
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
540 // 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
541 octave::set_interrupt_handler (saved_interrupt_handler, true);
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
542
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
543 raw_mode (false, true);
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
544 #endif
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
545
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
546 return c;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
547 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
548
12228
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
549 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
550 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
551 {
21979
d04da18a407a use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
552 #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
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 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
555
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
556 #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
557 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
558 #endif
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 // 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
561 // 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
562 // 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
563
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
564 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
565 {
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
566 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
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 if (retval.empty ())
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
569 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
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 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
572 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
573 }
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 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
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 #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
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 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
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 #else
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
582
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
583 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
584
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
585 #endif
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
586 }
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
587
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
588 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
589 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
590 @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
591 @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
592 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
593 @end deftypefn */)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
594 {
16537
106a38d7b396 optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents: 16404
diff changeset
595 bool skip_redisplay = true;
106a38d7b396 optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents: 16404
diff changeset
596
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
597 octave::command_editor::clear_screen (skip_redisplay);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
598
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
599 return ovl ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
600 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
601
549
75a371805554 [project @ 1994-07-22 19:44:41 by jwe]
jwe
parents: 545
diff changeset
602 DEFALIAS (home, clc);
75a371805554 [project @ 1994-07-22 19:44:41 by jwe]
jwe
parents: 545
diff changeset
603
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
604 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
605 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
606 @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
607 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
608
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
609 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
610
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
611 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
612 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
613 @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
614
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
615 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
616 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
617 @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
618 @end deftypefn */)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
619 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
620 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
621 print_usage ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
622
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
623 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
624
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
625 return ovl (octave::sys::env::getenv (name));
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
626 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
627
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
628 /*
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
629 %!assert (ischar (getenv ("OCTAVE_HOME")))
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
630 */
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
631
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
632 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
633 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
634 @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
635 @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
636 @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
637 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
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 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
640 string.
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{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
642 @end deftypefn */)
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
643 {
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
644 int nargin = args.length ();
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
645
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
646 if (nargin < 1 || nargin > 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
647 print_usage ();
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
648
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
649 std::string var = args(0).xstring_value ("setenv: VAR must be a string");
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
650
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
651 std::string val = (nargin == 2
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
652 ? 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
653 : "");
20582
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
654
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
655 octave::sys::env::putenv (var, val);
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
656
21078
49852ff04747 maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents: 21017
diff changeset
657 return ovl ();
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
658 }
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
659
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
660 DEFALIAS (putenv, setenv);
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
661
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
662 /*
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
663 %!test
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
664 %! 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
665 %! 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
666 %! unsetenv ("dummy_variable_that_cannot_matter");
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
667 %! assert (getenv ("dummy_variable_that_cannot_matter"), "");
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
668 */
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
669
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
670 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
671 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
672 @deftypefn {} {@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
673 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
674
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
675 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
676 occurred.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
677 @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
678 @end deftypefn */)
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
679 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
680 if (args.length () != 1)
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
681 print_usage ();
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
682
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
683 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
684
21888
00f1249f2483 create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
685 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
686 }
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
687
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
688 /*
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
689 ## 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
690 */
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
691
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
692 // FIXME: perhaps kbhit should also be able to print a prompt?
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
693
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
694 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
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 {} {} kbhit ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
697 @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
698 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
699
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
700 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
701
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
702 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
703
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
704 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
705 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
706 @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
707
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
708 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
709 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
710 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
711
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
712 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
713 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
714 @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
715
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
716 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
717 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
718 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
719 @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
720 @end deftypefn */)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
721 {
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4208
diff changeset
722 octave_value retval;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
723
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
724 // FIXME: add timeout and default value args?
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
725
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
726 if (octave::application::interactive ())
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
727 {
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
728 Fdrawnow ();
6423
a90b54016b12 [project @ 2007-03-21 13:15:03 by jwe]
jwe
parents: 6419
diff changeset
729
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
730 int c = octave_kbhit (args.length () == 0);
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
731
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
732 if (c == -1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
733 c = 0;
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
734
16092
def3b111cff8 avoid gcc warning about int to char conversion
John W. Eaton <jwe@octave.org>
parents: 16053
diff changeset
735 char s[2] = { static_cast<char> (c), '\0' };
16015
d910b9211cca Plug memory leak in kbhit().
Rik <rik@octave.org>
parents: 15423
diff changeset
736
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
737 retval = s;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
738 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
739
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
740 return retval;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
741 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
742
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
743 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
744 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
745 @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
746 @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
747 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
748
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
749 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
750 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
751
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
752 @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
753 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
754
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
755 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
756 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
757 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
758 @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
759 @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
760 @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
761
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
762 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
763 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
764
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
765 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
766 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
767 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
768 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
769 clc;
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
770 @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
771 @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
772
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
773 @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
774 @end deftypefn */)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
775 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
776 int nargin = args.length ();
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
777
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
778 if (nargin > 1)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
779 print_usage ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
780
1579
972ce8b5a757 [project @ 1995-10-19 06:39:35 by jwe]
jwe
parents: 1488
diff changeset
781 if (nargin == 1)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
782 {
1579
972ce8b5a757 [project @ 1995-10-19 06:39:35 by jwe]
jwe
parents: 1488
diff changeset
783 double dval = args(0).double_value ();
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 610
diff changeset
784
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21748
diff changeset
785 if (octave::math::isnan (dval))
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
786 warning ("pause: NaN is an invalid delay");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
787 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
788 {
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
789 Fdrawnow ();
6419
73fcbac81f33 [project @ 2007-03-20 17:18:24 by jwe]
jwe
parents: 6208
diff changeset
790
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21748
diff changeset
791 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
792 {
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
793 flush_octave_stdout ();
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
794 octave_kbhit ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
795 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
796 else
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
797 octave_sleep (dval);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
798 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
799 }
1579
972ce8b5a757 [project @ 1995-10-19 06:39:35 by jwe]
jwe
parents: 1488
diff changeset
800 else
3234
be8e0ba13644 [project @ 1999-01-29 03:52:30 by jwe]
jwe
parents: 3124
diff changeset
801 {
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
802 Fdrawnow ();
3234
be8e0ba13644 [project @ 1999-01-29 03:52:30 by jwe]
jwe
parents: 3124
diff changeset
803 flush_octave_stdout ();
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
804 octave_kbhit ();
3234
be8e0ba13644 [project @ 1999-01-29 03:52:30 by jwe]
jwe
parents: 3124
diff changeset
805 }
2630
fdee6fe3e73b [project @ 1997-01-27 19:08:47 by jwe]
jwe
parents: 2610
diff changeset
806
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
807 return ovl ();
2630
fdee6fe3e73b [project @ 1997-01-27 19:08:47 by jwe]
jwe
parents: 2610
diff changeset
808 }
fdee6fe3e73b [project @ 1997-01-27 19:08:47 by jwe]
jwe
parents: 2610
diff changeset
809
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
810 /*
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
811 %!test
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
812 %! pause (1);
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
813
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
814 %!error (pause (1, 2))
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
815 */
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
816
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
817 // FIXME: maybe this should only return 1 if IEEE floating
862
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
818 // point functions really work.
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
819
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
820 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
821 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
822 @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
823 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
824 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
825
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
826 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
827 @end deftypefn */)
862
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
828 {
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
829 octave::mach_info::float_format flt_fmt = octave::mach_info::native_float_format ();
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 2086
diff changeset
830
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
831 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
832 || flt_fmt == octave::mach_info::flt_fmt_ieee_big_endian);
862
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
833 }
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
834
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
835 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
836 %!assert (islogical (isieee ()))
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
837 */
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
838
4600
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
839 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
840 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
841 @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
842 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
843 @end deftypefn */)
4600
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
844 {
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
845 octave::mach_info::float_format flt_fmt = octave::mach_info::native_float_format ();
4600
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
846
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
847 return ovl (octave::mach_info::float_format_as_string (flt_fmt));
4600
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
848 }
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
849
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
850 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
851 %!assert (ischar (native_float_format ()))
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
852 */
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
853
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
854 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
855 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
856 @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
857 @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
858 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
859
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
860 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
861 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
862 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
863 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
864 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
865 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
866
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
867 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
868 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
869
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
870 Examples:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
871
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
872 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
873 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
874 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
875 @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
876 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
877 @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
878 @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
879 @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
880 @end deftypefn */)
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
881 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
882 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
883 print_usage ();
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
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
b64fb24bf4a0 [project @ 2006-10-27 18:04:49 by jwe]
jwe
parents: 6086
diff changeset
886
20990
fc9cca99b2de Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents: 20961
diff changeset
887 string_vector sv = arg.xstring_vector_value ("tilde_expand: argument must be char or cellstr object");
6116
b64fb24bf4a0 [project @ 2006-10-27 18:04:49 by jwe]
jwe
parents: 6086
diff changeset
888
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
889 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
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 ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
892 return ovl (Cell (arg.dims (), sv));
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
893 else
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
894 return ovl (sv);
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
895 }
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
896
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
897 /*
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
898 %!test
20016
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
899 %! 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
900 %! 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
901 %! 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
902 %! 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
903 */
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
904
20016
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
905 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
906 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
907 @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
908 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
909
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
910 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
911 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
912 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
913 @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
914 @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
915 @end deftypefn */)
20016
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
916 {
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
917 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
918 }
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
919
20024
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
920 /*
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
921 %!test
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
922 %! if (! ispc ())
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20172
diff changeset
923 %! 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
924 %! endif
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
925 */
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
926
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
927 // 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
928 // 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
929 // needed for X11 and Carbon functions.
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
930
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
931 DEFUN (have_window_system, , ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
932 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
933 @deftypefn {} {} have_window_system ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
934 Return true if a window system is available (X11, Windows, or Apple OS X)
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
935 and false otherwise.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
936 @seealso{isguirunning}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
937 @end deftypefn */)
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
938 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
939 return ovl (display_info::display_available ());
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
940 }