annotate libinterp/corefcn/sysdep.cc @ 21910:4d723ba06b4a

provide wrappers for some unistd.h functions * liboctave/wrappers/unistd-wrappers.c, liboctave/wrappers/unistd-wrappers.h: New files. * liboctave/wrappers/module.mk: Update. * gl2ps-print.cc, oct-hist.cc, oct-procbuf.cc, oct-tex-lexer.in.ll, sysdep.cc, octave.cc, parse-tree/lex.ll, file-ops.cc, lo-sysdep.cc, oct-env.cc, oct-syscalls.cc, cmd-edit.cc, kpse.cc: Use wrappers instead of calling unistd.h functions directly.
author John W. Eaton <jwe@octave.org>
date Tue, 14 Jun 2016 18:10:04 -0400
parents 00f1249f2483
children baeffde5c87d
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"
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
75 #include "builtins.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
76 #include "defun.h"
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
77 #include "display.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
78 #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
79 #include "errwarn.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
80 #include "input.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
81 #include "ovl.h"
2370
a45c7d64b5e3 [project @ 1996-10-11 23:51:15 by jwe]
jwe
parents: 2317
diff changeset
82 #include "ov.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"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
87 #include "toplev.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
6956
cc712c417943 [project @ 2007-10-04 17:51:57 by jwe]
jwe
parents: 6954
diff changeset
109 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
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
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
112 #include <tlhelp32.h>
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
113 #include <windows.h>
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
114
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
115 static void
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
116 w32_set_octave_home (void)
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
117 {
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
118 std::string bin_dir;
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
119
13885
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
120 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
121 #if defined (TH32CS_SNAPMODULE32)
13885
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
122 | TH32CS_SNAPMODULE32
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
123 #endif
2f42a7b0cf94 Fix MinGW compilation problem with tlhelp32.h
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13771
diff changeset
124 , 0);
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
125
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
126 if (h != INVALID_HANDLE_VALUE)
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
127 {
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
128 MODULEENTRY32 mod_info;
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
129
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
130 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
131 mod_info.dwSize = sizeof (mod_info);
13751
be7ff59cbc7a Fix octinterp DLL searching on Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13282
diff changeset
132
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
133 if (Module32First (h, &mod_info))
14445
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
134 {
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
135 do
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
136 {
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
137 std::string mod_name (mod_info.szModule);
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
138
14445
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
139 if (mod_name.find ("octinterp") != std::string::npos)
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
140 {
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
141 bin_dir = mod_info.szExePath;
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
142 if (bin_dir[bin_dir.length () - 1] != '\\')
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
143 bin_dir.append (1, '\\');
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
144 break;
b50654a09ba7 maint: untabify sources
John W. Eaton <jwe@octave.org>
parents: 14429
diff changeset
145 }
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 while (Module32Next (h, &mod_info));
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
148 }
13771
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
149
80b30e186b73 [Win32] Use Toolhelp32 APi to find octinterp module path.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13751
diff changeset
150 CloseHandle (h);
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
151 }
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 if (! bin_dir.empty ())
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
154 {
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
155 size_t pos = bin_dir.rfind ("\\bin\\");
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
156
8021
85184151822e fix typo in NPOS change
John W. Eaton <jwe@octave.org>
parents: 8019
diff changeset
157 if (pos != std::string::npos)
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
158 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
159 }
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
6960
d5339f9f5f9c [project @ 2007-10-05 15:03:09 by jwe]
jwe
parents: 6956
diff changeset
162 void
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
163 w32_set_quiet_shutdown (void)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
164 {
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
165 // Let the user close the console window or shutdown without the
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
166 // pesky dialog.
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
167 //
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
168 // FIXME: should this be user configurable?
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
169 SetProcessShutdownParameters (0x280, SHUTDOWN_NORETRY);
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
170 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
171
6960
d5339f9f5f9c [project @ 2007-10-05 15:03:09 by jwe]
jwe
parents: 6956
diff changeset
172 void
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
173 MINGW_signal_cleanup (void)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
174 {
5455
ec44bd0917fe [project @ 2005-09-19 16:07:56 by jwe]
jwe
parents: 5451
diff changeset
175 w32_set_quiet_shutdown ();
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
176 }
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
177
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
178 static void
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
179 w32_init (void)
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
180 {
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
181 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
182
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
183 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
184 }
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
185
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
186 static bool
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
187 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
188 {
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
189 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
190 #endif
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
191
19856
5c1a38089f89 Change open_with_system_app to internal function.
Rik <rik@octave.org>
parents: 19849
diff changeset
192 DEFUN (__open_with_system_app__, args, ,
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19857
diff changeset
193 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
194 @deftypefn {} {} __open_with_system_app__ (@var{file})\n\
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
195 Undocumented internal function.\n\
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
196 @end deftypefn")
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
197 {
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
198 if (args.length () != 1)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
199 print_usage ();
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
200
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
201 std::string file = args(0).xstring_value ("__open_with_system_app__: argument must be a filename");
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
202
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
203 octave_value retval;
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
204
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
205 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
206 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
207 SW_SHOWNORMAL);
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
208
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
209 // 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
210 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
211 #elif defined (__APPLE__)
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
212 octave_value_list tmp
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
213 = 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
214 false, "async"),
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
215 1);
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
216
20961
f55251db0833 Add support for the Mac OS X "open" command.
Ben Abbott <bpabbott@mac.com>
parents: 20941
diff changeset
217 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
218 #else
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
219 octave_value_list tmp
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
220 = 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
221 false, "async"),
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
222 1);
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
223
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
224 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
225 #endif
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
226
19774
904912f18357 make open_with_system_app a built-in function
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
227 return retval;
19271
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
228 }
030d56f67363 implement the open function
John W. Eaton <jwe@octave.org>
parents: 19270
diff changeset
229
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
230 #if defined (__MINGW32__)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
231 static void
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
232 MINGW_init (void)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
233 {
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
234 w32_init ();
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
235 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
236 #endif
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
237
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
238 #if defined (_MSC_VER)
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
239 static void
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
240 MSVC_init (void)
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
241 {
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 18674
diff changeset
242 w32_init ();
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
243 }
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
244 #endif
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
245
4091
575507e27b8b [project @ 2002-10-06 20:50:15 by jwe]
jwe
parents: 4086
diff changeset
246
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
247 // 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
248
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
249 bool
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
250 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
251 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21662
diff changeset
252 #if defined (OCTAVE_USE_WINDOWS_API)
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
253
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
254 bool retval = false;
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
255
16564
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
256 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
257 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
258
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
259 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
260 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
261
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
262 // Windows native code
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
263 // 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
264
16564
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
265 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
266
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
267 HANDLE hfile1
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
268 = 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
269 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
270
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
271 if (hfile1 != INVALID_HANDLE_VALUE)
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
272 {
16564
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
273 HANDLE hfile2
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
274 = 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
275 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
276
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
277 if (hfile2 != INVALID_HANDLE_VALUE)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
278 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
279 BY_HANDLE_FILE_INFORMATION hfi1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
280 BY_HANDLE_FILE_INFORMATION hfi2;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
281
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
282 if (GetFileInformationByHandle (hfile1, &hfi1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
283 && 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
284 {
aa5299a1d770 * sysdep.cc (same_file_internal): Handle directories on Windows systems.
John W. Eaton <jwe@octave.org>
parents: 16537
diff changeset
285 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
286 && 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
287 && 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
288 }
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
289
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
290 CloseHandle (hfile2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
291 }
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
292
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
293 CloseHandle (hfile1);
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
294 }
6691
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
295
c6ee6c342699 [project @ 2007-06-05 05:50:10 by jwe]
jwe
parents: 6677
diff changeset
296 return retval;
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
297
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
298 #else
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
299
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
300 // POSIX Code
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
301
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
302 octave::sys::file_stat fs_file1 (file1);
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
303 octave::sys::file_stat fs_file2 (file2);
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
304
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
305 return (fs_file1 && fs_file2
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
306 && fs_file1.ino () == fs_file2.ino ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
307 && fs_file1.dev () == fs_file2.dev ());
6598
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
308
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
309 #endif
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
310 }
ce819776ee76 [project @ 2007-04-27 17:34:27 by jwe]
jwe
parents: 6423
diff changeset
311
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
312 void
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
313 sysdep_init (void)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
314 {
21557
f6663c49870c Add comment clarifying why omp_get_num_threads is called in sysdep.cc.
Rik <rik@octave.org>
parents: 21556
diff changeset
315 // 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
316 // 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
317 // 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
318 #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
319 omp_get_num_threads ();
9f0088f3f335 call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 20788
diff changeset
320 #endif
9f0088f3f335 call openmp function at initialization (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 20788
diff changeset
321
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14445
diff changeset
322 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__)
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 2493
diff changeset
323 BSD_init ();
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
324 #elif defined (__MINGW32__)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
325 MINGW_init ();
6080
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
326 #elif defined (_MSC_VER)
40ab35ab651c [project @ 2006-10-25 03:26:36 by jwe]
jwe
parents: 5823
diff changeset
327 MSVC_init ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
328 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
329 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
330
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
331 void
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
332 sysdep_cleanup (void)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
333 {
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
334 MINGW_SIGNAL_CLEANUP ();
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
335 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5395
diff changeset
336
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
337 // Set terminal in raw mode. From less-177.
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
338 //
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
339 // 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
340 // "Raw mode" means
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
341 // 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
342 // 2. Input is not echoed.
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
343 // 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
344 // 4. \t is NOT expanded into spaces.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
345 // 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
346 // etc. are NOT disabled.
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
347 // 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
348
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
349 void
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
350 raw_mode (bool on, bool wait)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
351 {
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
352 static bool curr_on = false;
529
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 int tty_fd = STDIN_FILENO;
21910
4d723ba06b4a provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents: 21888
diff changeset
355 if (! octave_isatty_wrapper (tty_fd))
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
356 {
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19774
diff changeset
357 if (interactive && ! forced_interactive)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
358 error ("stdin is not a tty!");
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
359 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
360
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
361 if (on == curr_on)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
362 return;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
363
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
364 #if defined (HAVE_TERMIOS_H)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
365 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
366 struct termios s;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
367 static struct termios save_term;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
368
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
369 if (on)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
370 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
371 // Get terminal modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
372
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
373 tcgetattr (tty_fd, &s);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
374
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
375 // 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
376
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
377 save_term = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
378 // ospeed = s.c_cflag & CBAUD;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
379 // erase_char = s.c_cc[VERASE];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
380 // kill_char = s.c_cc[VKILL];
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
381
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
382 // 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
383
21662
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21557
diff changeset
384 s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL);
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21557
diff changeset
385 s.c_oflag |= (OPOST | ONLCR);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
386 #if defined (OCRNL)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
387 s.c_oflag &= ~(OCRNL);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
388 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
389 #if defined (ONOCR)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
390 s.c_oflag &= ~(ONOCR);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
391 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
392 #if defined (ONLRET)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
393 s.c_oflag &= ~(ONLRET);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
394 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
395 s.c_cc[VMIN] = wait ? 1 : 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
396 s.c_cc[VTIME] = 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
397 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
398 else
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
399 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
400 // Restore saved modes.
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
401
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
402 s = save_term;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
403 }
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
404
9411
c9636d98e5cd fix kbhit(1) to not discard waiting keystrokes
Joe Rothweiler <octaveuser@sensicomm.com>
parents: 9242
diff changeset
405 tcsetattr (tty_fd, wait ? TCSAFLUSH : TCSADRAIN, &s);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
406 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
407 #elif defined (HAVE_TERMIO_H)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
408 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
409 struct termio s;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
410 static struct termio save_term;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
411
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
412 if (on)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
413 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
414 // Get terminal modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
415
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
416 ioctl (tty_fd, TCGETA, &s);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
417
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
418 // 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
419
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
420 save_term = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
421 // ospeed = s.c_cflag & CBAUD;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
422 // erase_char = s.c_cc[VERASE];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
423 // kill_char = s.c_cc[VKILL];
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
424
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
425 // 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
426
21662
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21557
diff changeset
427 s.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL);
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21557
diff changeset
428 s.c_oflag |= (OPOST | ONLCR);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
429 #if defined (OCRNL)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
430 s.c_oflag &= ~(OCRNL);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
431 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
432 #if defined (ONOCR)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
433 s.c_oflag &= ~(ONOCR);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
434 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
435 #if defined (ONLRET)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
436 s.c_oflag &= ~(ONLRET);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
437 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
438 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
439 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
440 else
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
441 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
442 // Restore saved modes.
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
443
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
444 s = save_term;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
445 }
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
446
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
447 ioctl (tty_fd, TCSETAW, &s);
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
448 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
449 #elif defined (HAVE_SGTTY_H)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
450 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
451 struct sgttyb s;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
452 static struct sgttyb save_term;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
453
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
454 if (on)
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
455 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
456 // Get terminal modes.
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
457
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
458 ioctl (tty_fd, TIOCGETP, &s);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
459
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
460 // 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
461
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
462 save_term = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
463 // ospeed = s.sg_ospeed;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
464 // erase_char = s.sg_erase;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
465 // kill_char = s.sg_kill;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
466
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
467 // 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
468
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
469 s.sg_flags |= CBREAK;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
470 s.sg_flags &= ~(ECHO);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
471 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
472 else
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
473 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
474 // Restore saved modes.
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
475
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
476 s = save_term;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
477 }
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
478
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
479 ioctl (tty_fd, TIOCSETN, &s);
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
480 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
481 #else
21109
bd1752782e56 Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents: 21078
diff changeset
482 warn_disabled_feature ("", "raw mode console I/O");
4064
b4fa31442a78 [project @ 2002-09-26 21:10:45 by jwe]
jwe
parents: 3676
diff changeset
483
b4fa31442a78 [project @ 2002-09-26 21:10:45 by jwe]
jwe
parents: 3676
diff changeset
484 // Make sure the current mode doesn't toggle.
b4fa31442a78 [project @ 2002-09-26 21:10:45 by jwe]
jwe
parents: 3676
diff changeset
485 on = curr_on;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
486 #endif
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
487
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
488 curr_on = on;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
489 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
490
6726
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
491 FILE *
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
492 octave_popen (const char *command, const char *mode)
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
493 {
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
494 #if defined (__MINGW32__) || defined (_MSC_VER)
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
495 if (mode && mode[0] && ! mode[1])
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
496 {
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
497 char tmode[3];
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
498 tmode[0] = mode[0];
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
499 tmode[1] = 'b';
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
500 tmode[2] = 0;
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 return _popen (command, tmode);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
503 }
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 _popen (command, mode);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
506 #else
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
507 return popen (command, mode);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
508 #endif
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
509 }
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
510
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
511 int
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
512 octave_pclose (FILE *f)
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
513 {
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
514 #if defined (__MINGW32__) || defined (_MSC_VER)
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
515 return _pclose (f);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
516 #else
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
517 return pclose (f);
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
518 #endif
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
519 }
6b7ba4a31876 [project @ 2007-06-14 20:16:44 by jwe]
jwe
parents: 6691
diff changeset
520
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
521 // Read one character from the terminal.
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 712
diff changeset
522
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
523 int
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
524 octave_kbhit (bool wait)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
525 {
20788
a2b96b523472 Rewrite a8ee668e7fd7 to use #if defined rather than #ifdef.
Rik <rik@octave.org>
parents: 20786
diff changeset
526 #if defined (HAVE__KBHIT) && defined (HAVE__GETCH)
20786
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
527 // 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
528 int c;
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
529
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
530 if (wait)
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
531 c = _getch ();
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
532 else
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
533 c = (! _kbhit ()) ? 0 : _getch ();
a8ee668e7fd7 Fix kbhit and pause on Windows systems.
Rik <rik@octave.org>
parents: 20181
diff changeset
534
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
535 #else
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
536 raw_mode (true, wait);
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
537
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
538 // Get current handler.
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
539 octave_interrupt_handler saved_interrupt_handler
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
540 = octave_ignore_interrupts ();
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
541
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
542 // 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
543 // read can be interrupted.
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
544
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
545 octave_set_interrupt_handler (saved_interrupt_handler, false);
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
546
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
547 int c = std::cin.get ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
548
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
549 if (std::cin.fail () || std::cin.eof ())
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
550 std::cin.clear ();
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
551
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
552 // Restore it, enabling system call restarts (if possible).
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
553 octave_set_interrupt_handler (saved_interrupt_handler, true);
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5455
diff changeset
554
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
555 raw_mode (false, true);
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
556 #endif
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
557
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
558 return c;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
559 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
560
12228
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
561 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
562 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
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 defined (__WIN32__) && ! defined (_POSIX_VERSION)
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
565
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
566 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
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 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
569 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
570 #endif
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
571
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
572 // 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
573 // 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
574 // 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
575
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
576 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
577 {
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
578 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
579
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
580 if (retval.empty ())
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
581 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
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 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
584 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
585 }
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 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
588
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
589 #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
590
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
591 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
592
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
593 #else
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
594
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
595 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
596
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
597 #endif
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
598 }
0f70c5db58c3 try to get better value than \ for P_tmpdir on Windows systems
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
599
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
600 DEFUN (clc, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
601 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
602 @deftypefn {} {} clc ()\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
603 @deftypefnx {} {} home ()\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3308
diff changeset
604 Clear the terminal screen and move the cursor to the upper left corner.\n\
3333
15cddaacbc2d [project @ 1999-11-03 19:53:59 by jwe]
jwe
parents: 3332
diff changeset
605 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
606 {
16537
106a38d7b396 optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents: 16404
diff changeset
607 bool skip_redisplay = true;
106a38d7b396 optionall disable redisplay in command editor clear screen function
John W. Eaton <jwe@octave.org>
parents: 16404
diff changeset
608
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
609 octave::command_editor::clear_screen (skip_redisplay);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
610
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
611 return ovl ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
612 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
613
549
75a371805554 [project @ 1994-07-22 19:44:41 by jwe]
jwe
parents: 545
diff changeset
614 DEFALIAS (home, clc);
75a371805554 [project @ 1994-07-22 19:44:41 by jwe]
jwe
parents: 545
diff changeset
615
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
616 DEFUN (getenv, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
617 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
618 @deftypefn {} {} getenv (@var{var})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
619 Return the value of the environment variable @var{var}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
620 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
621 For example,\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
622 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
623 @example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
624 getenv (\"PATH\")\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
625 @end example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
626 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
627 @noindent\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
628 returns a string containing the value of your path.\n\
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
629 @seealso{setenv, unsetenv}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
630 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
631 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
632 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
633 print_usage ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
634
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
635 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
636
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
637 return ovl (octave::sys::env::getenv (name));
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
638 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
639
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
640 /*
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
641 %!assert (ischar (getenv ("OCTAVE_HOME")))
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
642 */
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
643
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
644 DEFUN (setenv, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
645 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
646 @deftypefn {} {} setenv (@var{var}, @var{value})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
647 @deftypefnx {} {} setenv (@var{var})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
648 @deftypefnx {} {} putenv (@dots{})\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
649 Set the value of the environment variable @var{var} to @var{value}.\n\
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
650 \n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
651 If no @var{value} is specified then the variable will be assigned the null\n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
652 string.\n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
653 @seealso{unsetenv, getenv}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
654 @end deftypefn")
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
655 {
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
656 int nargin = args.length ();
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
657
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
658 if (nargin < 1 || nargin > 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
659 print_usage ();
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
660
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
661 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
662
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
663 std::string val = (nargin == 2
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
664 ? 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
665 : "");
20582
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
666
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
667 octave::sys::env::putenv (var, val);
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
668
21078
49852ff04747 maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents: 21017
diff changeset
669 return ovl ();
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
670 }
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
671
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
672 DEFALIAS (putenv, setenv);
1706
6bb0c67bbf24 [project @ 1996-01-07 05:40:05 by jwe]
jwe
parents: 1670
diff changeset
673
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
674 /*
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
675 %!test
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
676 %! 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
677 %! 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
678 %! unsetenv ("dummy_variable_that_cannot_matter");
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
679 %! assert (getenv ("dummy_variable_that_cannot_matter"), "");
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
680 */
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
681
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
682 DEFUN (unsetenv, args, ,
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
683 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
684 @deftypefn {} {@var{status} =} unsetenv (@var{var})\n\
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
685 Delete the environment variable @var{var}.\n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
686 \n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
687 Return 0 if the variable was deleted, or did not exist, and -1 if an error\n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
688 occurred.\n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
689 @seealso{setenv, getenv}\n\
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
690 @end deftypefn")
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
691 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
692 if (args.length () != 1)
19167
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
693 print_usage ();
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
694
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
695 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
696
21888
00f1249f2483 create wrappers for some gnulib functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
697 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
698 }
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
699
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
700 /*
6f0290863d50 Add new function unsetenv from gnulib to Octave.
Rik <rik@octave.org>
parents: 18674
diff changeset
701 ## 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
702 */
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
703
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
704 // 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
705
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
706 DEFUN (kbhit, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
707 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
708 @deftypefn {} {} kbhit ()\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
709 @deftypefnx {} {} kbhit (1)\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
710 Read a single keystroke from the keyboard.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
711 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
712 If called with an argument, don't wait for a keypress.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
713 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
714 For example,\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
715 \n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
716 @example\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
717 x = kbhit ();\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
718 @end example\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
719 \n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
720 @noindent\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
721 will set @var{x} to the next character typed at the keyboard as soon as\n\
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
722 it is typed.\n\
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
723 \n\
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
724 @example\n\
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
725 x = kbhit (1);\n\
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
726 @end example\n\
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
727 \n\
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
728 @noindent\n\
16053
119ce9f5e1a3 doc: Add seealso links between input, yes_or_no, kbhit.
Rik <rik@octave.org>
parents: 16015
diff changeset
729 is identical to the above example, but doesn't wait for a keypress,\n\
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
730 returning the empty string if no key is available.\n\
18674
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
731 @seealso{input, pause}\n\
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3333
diff changeset
732 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
733 {
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4208
diff changeset
734 octave_value retval;
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
735
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
736 // FIXME: add timeout and default value args?
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
737
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19774
diff changeset
738 if (interactive)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
739 {
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
740 Fdrawnow ();
6423
a90b54016b12 [project @ 2007-03-21 13:15:03 by jwe]
jwe
parents: 6419
diff changeset
741
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
742 int c = octave_kbhit (args.length () == 0);
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
743
3658
808f399398c9 [project @ 2000-04-11 19:45:44 by jwe]
jwe
parents: 3657
diff changeset
744 if (c == -1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
745 c = 0;
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3531
diff changeset
746
16092
def3b111cff8 avoid gcc warning about int to char conversion
John W. Eaton <jwe@octave.org>
parents: 16053
diff changeset
747 char s[2] = { static_cast<char> (c), '\0' };
16015
d910b9211cca Plug memory leak in kbhit().
Rik <rik@octave.org>
parents: 15423
diff changeset
748
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
749 retval = s;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
750 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
751
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
752 return retval;
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
753 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
754
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
755 DEFUN (pause, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
756 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
757 @deftypefn {} {} pause ()\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
758 @deftypefnx {} {} pause (@var{n})\n\
18674
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
759 Suspend the execution of the program for @var{n} seconds.\n\
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
760 \n\
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
761 If invoked without an input arguments then the program is suspended until a\n\
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
762 character is typed.\n\
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
763 \n\
20923
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
764 @var{n} is a positive real value and may be a fraction of a second,\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
765 for example:\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
766 \n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
767 @example\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
768 @group\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
769 tic; pause (0.05); toc\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
770 @print{} Elapsed time is 0.05039 seconds.\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
771 @end group\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
772 @end example\n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
773 \n\
18674
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
774 The following example prints a message and then waits 5 seconds before\n\
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
775 clearing the screen.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
776 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
777 @example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
778 @group\n\
20923
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
779 disp (\"wait please...\");\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
780 pause (5);\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
781 clc;\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
782 @end group\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
783 @end example\n\
20923
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
784 \n\
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20853
diff changeset
785 @seealso{kbhit}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
786 @end deftypefn")
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
787 {
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
788 int nargin = args.length ();
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
789
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
790 if (nargin > 1)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
791 print_usage ();
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
792
1579
972ce8b5a757 [project @ 1995-10-19 06:39:35 by jwe]
jwe
parents: 1488
diff changeset
793 if (nargin == 1)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
794 {
1579
972ce8b5a757 [project @ 1995-10-19 06:39:35 by jwe]
jwe
parents: 1488
diff changeset
795 double dval = args(0).double_value ();
636
fae2bd91c027 [project @ 1994-08-23 18:39:50 by jwe]
jwe
parents: 610
diff changeset
796
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21748
diff changeset
797 if (octave::math::isnan (dval))
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
798 warning ("pause: NaN is an invalid delay");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
799 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
800 {
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
801 Fdrawnow ();
6419
73fcbac81f33 [project @ 2007-03-20 17:18:24 by jwe]
jwe
parents: 6208
diff changeset
802
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21748
diff changeset
803 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
804 {
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
805 flush_octave_stdout ();
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
806 octave_kbhit ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
807 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
808 else
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20181
diff changeset
809 octave_sleep (dval);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10266
diff changeset
810 }
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 505
diff changeset
811 }
1579
972ce8b5a757 [project @ 1995-10-19 06:39:35 by jwe]
jwe
parents: 1488
diff changeset
812 else
3234
be8e0ba13644 [project @ 1999-01-29 03:52:30 by jwe]
jwe
parents: 3124
diff changeset
813 {
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
814 Fdrawnow ();
3234
be8e0ba13644 [project @ 1999-01-29 03:52:30 by jwe]
jwe
parents: 3124
diff changeset
815 flush_octave_stdout ();
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 4064
diff changeset
816 octave_kbhit ();
3234
be8e0ba13644 [project @ 1999-01-29 03:52:30 by jwe]
jwe
parents: 3124
diff changeset
817 }
2630
fdee6fe3e73b [project @ 1997-01-27 19:08:47 by jwe]
jwe
parents: 2610
diff changeset
818
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
819 return ovl ();
2630
fdee6fe3e73b [project @ 1997-01-27 19:08:47 by jwe]
jwe
parents: 2610
diff changeset
820 }
fdee6fe3e73b [project @ 1997-01-27 19:08:47 by jwe]
jwe
parents: 2610
diff changeset
821
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
822 /*
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
823 %!test
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
824 %! pause (1);
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
825
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
826 %!error (pause (1, 2))
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
827 */
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
828
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
829 // 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
830 // point functions really work.
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
831
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
832 DEFUN (isieee, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
833 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
834 @deftypefn {} {} isieee ()\n\
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 11234
diff changeset
835 Return true if your computer @emph{claims} to conform to the IEEE standard\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
836 for floating point calculations.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
837 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
838 No actual tests are performed.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
839 @end deftypefn")
862
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
840 {
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
841 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
842
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
843 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
844 || 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
845 }
61d83ce7368c [project @ 1994-10-31 20:39:30 by jwe]
jwe
parents: 844
diff changeset
846
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
847 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
848 %!assert (islogical (isieee ()))
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
849 */
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
850
4600
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
851 DEFUN (native_float_format, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
852 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
853 @deftypefn {} {} native_float_format ()\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
854 Return the native floating point format as a string.\n\
4600
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
855 @end deftypefn")
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
856 {
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
857 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
858
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
859 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
860 }
3680bb30de0b [project @ 2003-11-12 18:25:53 by jwe]
jwe
parents: 4574
diff changeset
861
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
862 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
863 %!assert (ischar (native_float_format ()))
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
864 */
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
865
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
866 DEFUN (tilde_expand, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
867 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
868 @deftypefn {} {} tilde_expand (@var{string})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
869 @deftypefnx {} {} tilde_expand (@var{cellstr})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
870 Perform tilde expansion on @var{string}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
871 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
872 If @var{string} begins with a tilde character, (@samp{~}), all of the\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
873 characters preceding the first slash (or all characters, if there is no\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
874 slash) are treated as a possible user name, and the tilde and the following\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
875 characters up to the slash are replaced by the home directory of the named\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
876 user. If the tilde is followed immediately by a slash, the tilde is\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
877 replaced by the home directory of the user running Octave.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20064
diff changeset
878 \n\
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20704
diff changeset
879 If the input is a cell array of strings @var{cellstr} then tilde expansion\n\
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20704
diff changeset
880 is performed on each string element.\n\
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20704
diff changeset
881 \n\
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20704
diff changeset
882 Examples:\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
883 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
884 @example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
885 @group\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
886 tilde_expand (\"~joeuser/bin\")\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
887 @result{} \"/home/joeuser/bin\"\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
888 tilde_expand (\"~/bin\")\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
889 @result{} \"/home/jwe/bin\"\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
890 @end group\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
891 @end example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3248
diff changeset
892 @end deftypefn")
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
893 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
894 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
895 print_usage ();
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
896
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
897 octave_value arg = args(0);
6116
b64fb24bf4a0 [project @ 2006-10-27 18:04:49 by jwe]
jwe
parents: 6086
diff changeset
898
20990
fc9cca99b2de Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents: 20961
diff changeset
899 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
900
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
901 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
902
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20789
diff changeset
903 if (arg.is_cellstr ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
904 return ovl (Cell (arg.dims (), sv));
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
905 else
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
906 return ovl (sv);
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
907 }
12825
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
908
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
909 /*
a1dcb854a4f9 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
910 %!test
20016
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
911 %! 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
912 %! 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
913 %! 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
914 %! 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
915 */
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
916
20016
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
917 DEFUN (get_home_directory, , ,
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
918 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
919 @deftypefn {} {@var{homedir} =} get_home_directory ()\n\
20024
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
920 Return the current home directory.\n\
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
921 \n\
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
922 On most systems, this is equivalent to @code{getenv (\"HOME\")}. On Windows\n\
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
923 systems, if the environment variable @env{HOME} is not set then it is\n\
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
924 equivalent to\n\
20016
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
925 @code{fullfile (getenv (\"HOMEDRIVE\"), getenv (\"HOMEPATH\"))}\n\
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
926 @seealso{getenv}\n\
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
927 @end deftypefn")
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
928 {
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
929 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
930 }
47d420d769ba * sysdep.cc (Fget_home_directory): New function.
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
931
20024
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
932 /*
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
933 %!test
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
934 %! if (! ispc ())
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20172
diff changeset
935 %! 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
936 %! endif
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
937 */
cf9b94a89620 Document get_home_directory in Octave manual and NEWS file.
Rik <rik@octave.org>
parents: 20016
diff changeset
938
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
939 // 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
940 // 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
941 // needed for X11 and Carbon functions.
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
942
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
943 DEFUN (have_window_system, , ,
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19857
diff changeset
944 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
945 @deftypefn {} {} have_window_system ()\n\
18674
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
946 Return true if a window system is available (X11, Windows, or Apple OS X)\n\
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 17851
diff changeset
947 and false otherwise.\n\
19857
bf511802add7 doc: Add have_window_system() to documentation.
Rik <rik@octave.org>
parents: 19856
diff changeset
948 @seealso{isguirunning}\n\
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
949 @end deftypefn")
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
950 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
951 return ovl (display_info::display_available ());
17851
af685269e06c avoid symbol conflicts in display.cc
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
952 }