annotate libinterp/corefcn/toplev.cc @ 22091:0f6fc2ec3b1a

move call_stack class to a separate file * call-stack.h, call-stack.cc: New files. Move call_stack class here from toplev.h and toplev.cc. Update include file lists in other files as needed. * libinterp/corefcn/module.mk: Update.
author John W. Eaton <jwe@octave.org>
date Mon, 11 Jul 2016 17:05:33 -0400
parents c2c668b3051b
children 9203833cab7d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1 /*
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
3 Copyright (C) 1995-2015 John W. Eaton
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
4
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
6
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
5282f171363d [project @ 1995-12-30 03:46:07 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: 7013
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: 7013
diff changeset
10 option) any later version.
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
11
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
15 for more details.
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
16
5282f171363d [project @ 1995-12-30 03:46:07 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: 7013
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: 7013
diff changeset
19 <http://www.gnu.org/licenses/>.
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
20
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
21 */
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21618
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21253
diff changeset
24 # include "config.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
25 #endif
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
26
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
27 #include <cassert>
4489
a90c3cbded0d [project @ 2003-08-28 16:08:26 by jwe]
jwe
parents: 4440
diff changeset
28 #include <cerrno>
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
29 #include <cstdlib>
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
30 #include <cstring>
4221
a7d8e5dd87ad [project @ 2002-12-06 22:34:47 by jwe]
jwe
parents: 4217
diff changeset
31 #include <new>
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
32
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3446
diff changeset
33 #include <fstream>
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3446
diff changeset
34 #include <iostream>
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5744
diff changeset
35 #include <sstream>
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1704
diff changeset
36 #include <string>
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1704
diff changeset
37
21979
d04da18a407a use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
38 #if defined (OCTAVE_USE_WINDOWS_API)
21949
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21942
diff changeset
39 # define WIN32_LEAN_AND_MEAN 1
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21942
diff changeset
40 # include <windows.h>
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21942
diff changeset
41 #endif
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21942
diff changeset
42
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2910
diff changeset
43 #include "cmd-edit.h"
12989
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12846
diff changeset
44 #include "cmd-hist.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2910
diff changeset
45 #include "file-ops.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
46 #include "lo-error.h"
2370
a45c7d64b5e3 [project @ 1996-10-11 23:51:15 by jwe]
jwe
parents: 2322
diff changeset
47 #include "lo-mappers.h"
3020
f491f232cb09 [project @ 1997-06-03 22:15:08 by jwe]
jwe
parents: 3014
diff changeset
48 #include "oct-env.h"
21600
184b85b31e03 more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents: 21598
diff changeset
49 #include "oct-fftw.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
50 #include "oct-locbuf.h"
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21907
diff changeset
51 #include "oct-syscalls.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4130
diff changeset
52 #include "quit.h"
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
53 #include "signal-wrappers.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
54 #include "singleton-cleanup.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1751
diff changeset
55 #include "str-vec.h"
21899
7c053ad1c7ba hide sys/select header
John W. Eaton <jwe@octave.org>
parents: 21855
diff changeset
56 #include "wait-for-input.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
57
21220
d78e45987d6a rename octave::build_env namespace from octave::config
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
58 #include "build-env.h"
21607
37f6ed8a6f1b store liboctave and liboctinterp hg ids separately
John W. Eaton <jwe@octave.org>
parents: 21605
diff changeset
59 #include "liboctinterp-build-info.h"
22091
0f6fc2ec3b1a move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
60 #include "call-stack.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
61 #include "defaults.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
62 #include "defun.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
63 #include "error.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
64 #include "file-io.h"
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
65 #include "graphics.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
66 #include "input.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
67 #include "lex.h"
17755
9c03b071fd7b avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
68 #include "load-save.h"
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
69 #include "octave.h"
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
70 #include "octave-link.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1728
diff changeset
71 #include "oct-hist.h"
2162
a940dcdfe9de [project @ 1996-05-13 10:31:51 by jwe]
jwe
parents: 2145
diff changeset
72 #include "oct-map.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
73 #include "ovl.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
74 #include "ov.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
75 #include "pager.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
76 #include "parse.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
77 #include "pathsearch.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
78 #include "procstream.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8581
diff changeset
79 #include "pt-eval.h"
2985
aa9d0c0e0458 [project @ 1997-05-16 06:54:18 by jwe]
jwe
parents: 2982
diff changeset
80 #include "pt-jump.h"
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents: 2973
diff changeset
81 #include "pt-stmt.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
82 #include "sighandlers.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
83 #include "sysdep.h"
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
84 #include "toplev.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
85 #include "unwind-prot.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
86 #include "utils.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
87 #include "variables.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
88 #include "version.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
89
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21618
diff changeset
90 #if ! defined (SHELL_PATH)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21182
diff changeset
91 # define SHELL_PATH "/bin/sh"
15756
ea1a1fb00744 Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents: 15596
diff changeset
92 #endif
ea1a1fb00744 Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents: 15596
diff changeset
93
9217
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9187
diff changeset
94 void (*octave_exit) (int) = ::exit;
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9187
diff changeset
95
9255
1c2d2c9f4a8d don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents: 9217
diff changeset
96 // TRUE means the quit() call is allowed.
1c2d2c9f4a8d don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents: 9217
diff changeset
97 bool quit_allowed = true;
1c2d2c9f4a8d don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents: 9217
diff changeset
98
3020
f491f232cb09 [project @ 1997-06-03 22:15:08 by jwe]
jwe
parents: 3014
diff changeset
99 // TRUE means we are exiting via the builtin exit or quit functions.
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
100 bool quitting_gracefully = false;
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
101 // This stores the exit status.
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
102 int exit_status = 0;
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
103
4217
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4214
diff changeset
104 // TRUE means we are ready to interpret commands, but not everything
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4214
diff changeset
105 // is ready for interactive use.
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4214
diff changeset
106 bool octave_interpreter_ready = false;
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4214
diff changeset
107
4172
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4171
diff changeset
108 // TRUE means we've processed all the init code and we are good to go.
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4171
diff changeset
109 bool octave_initialized = false;
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4171
diff changeset
110
8011
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
111 void
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
112 recover_from_exception (void)
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
113 {
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
114 octave::can_interrupt = true;
4182
4d1d7c51205c [project @ 2002-11-15 20:33:47 by jwe]
jwe
parents: 4181
diff changeset
115 octave_interrupt_immediately = 0;
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
116 octave_interrupt_state = 0;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5102
diff changeset
117 octave_signal_caught = 0;
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7409
diff changeset
118 octave_exception_state = octave_no_exception;
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
119 octave_restore_signal_mask ();
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
120 octave::catch_interrupts ();
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
121 }
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
122
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
123 int
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5169
diff changeset
124 main_loop (void)
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
125 {
2016
6f3428b0d2c7 [project @ 1996-03-22 09:48:38 by jwe]
jwe
parents: 1996
diff changeset
126 octave_save_signal_mask ();
6f3428b0d2c7 [project @ 1996-03-22 09:48:38 by jwe]
jwe
parents: 1996
diff changeset
127
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
128 octave::can_interrupt = true;
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
129
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
130 octave_signal_hook = octave::signal_handler;
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9990
diff changeset
131 octave_interrupt_hook = 0;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9990
diff changeset
132 octave_bad_alloc_hook = 0;
4429
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4399
diff changeset
133
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
134 octave::catch_interrupts ();
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
135
4172
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4171
diff changeset
136 octave_initialized = true;
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4171
diff changeset
137
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
138 // The big loop.
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
139
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
140 octave_lexer *lxr = (octave::application::interactive ()
16335
bef822a80ffb if not interactive, bypass readline and read stdin as a file (bug #38520)
John W. Eaton <jwe@octave.org>
parents: 16317
diff changeset
141 ? new octave_lexer ()
bef822a80ffb if not interactive, bypass readline and read stdin as a file (bug #38520)
John W. Eaton <jwe@octave.org>
parents: 16317
diff changeset
142 : new octave_lexer (stdin));
bef822a80ffb if not interactive, bypass readline and read stdin as a file (bug #38520)
John W. Eaton <jwe@octave.org>
parents: 16317
diff changeset
143
bef822a80ffb if not interactive, bypass readline and read stdin as a file (bug #38520)
John W. Eaton <jwe@octave.org>
parents: 16317
diff changeset
144 octave_parser parser (*lxr);
16151
e309eb7940be parser tweaks
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
145
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4130
diff changeset
146 int retval = 0;
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
147 do
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
148 {
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
149 try
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
150 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
151 reset_error_handler ();
4318
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4254
diff changeset
152
16288
fe3b9a51e625 rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents: 16287
diff changeset
153 parser.reset ();
2620
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2614
diff changeset
154
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
155 if (symbol_table::at_top_level ())
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
156 tree_evaluator::reset_debug_state ();
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
157
16288
fe3b9a51e625 rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents: 16287
diff changeset
158 retval = parser.run ();
2620
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2614
diff changeset
159
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
160 if (retval == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
161 {
16288
fe3b9a51e625 rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents: 16287
diff changeset
162 if (parser.stmt_list)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
163 {
16288
fe3b9a51e625 rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents: 16287
diff changeset
164 parser.stmt_list->accept (*current_evaluator);
3883
69b6bd271277 [project @ 2002-04-02 21:05:10 by jwe]
jwe
parents: 3881
diff changeset
165
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
166 octave_quit ();
4171
04694e5b4239 [project @ 2002-11-12 20:27:24 by jwe]
jwe
parents: 4155
diff changeset
167
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
168 if (! octave::application::interactive ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
169 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
170 bool quit = (tree_return_command::returning
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
171 || tree_break_command::breaking);
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4130
diff changeset
172
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
173 if (tree_return_command::returning)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
174 tree_return_command::returning = 0;
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4130
diff changeset
175
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
176 if (tree_break_command::breaking)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
177 tree_break_command::breaking--;
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4130
diff changeset
178
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
179 if (quit)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
180 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
181 }
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4130
diff changeset
182
20741
a5ab31b52ae8 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
183 if (octave_completion_matches_called)
a5ab31b52ae8 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
184 octave_completion_matches_called = false;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
185 else
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
186 octave::command_editor::increment_current_command_number ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
187 }
16288
fe3b9a51e625 rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents: 16287
diff changeset
188 else if (parser.lexer.end_of_input)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
189 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
190 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
191 }
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
192 catch (const octave_interrupt_exception&)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
193 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
194 recover_from_exception ();
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
195
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
196 if (quitting_gracefully)
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
197 return exit_status;
21359
8e94a86ca648 Do not print extra newlines to stdout on exit (bug #47258).
Carnë Draug <carandraug@octave.org>
parents: 21322
diff changeset
198
8e94a86ca648 Do not print extra newlines to stdout on exit (bug #47258).
Carnë Draug <carandraug@octave.org>
parents: 21322
diff changeset
199 // Required newline when the user does Ctrl+C at the prompt.
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
200 if (octave::application::interactive ())
21363
8cfd1b47d49f Eliminate more extra newlines to stdout when not interactive (bug #47258)
Mike Miller <mtmiller@octave.org>
parents: 21359
diff changeset
201 octave_stdout << "\n";
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
202 }
20651
c1d94e5cd5ea catch index_exception by const reference where possible
John W. Eaton <jwe@octave.org>
parents: 20582
diff changeset
203 catch (const index_exception& e)
20542
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20535
diff changeset
204 {
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20535
diff changeset
205 recover_from_exception ();
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
206
20542
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20535
diff changeset
207 std::cerr << "error: unhandled index exception: "
20652
7a8096f8df5d more cleanup of indexing exceptions
John W. Eaton <jwe@octave.org>
parents: 20651
diff changeset
208 << e.message () << " -- trying to return to prompt"
20542
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20535
diff changeset
209 << std::endl;
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20535
diff changeset
210 }
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20652
diff changeset
211 catch (const octave_execution_exception& e)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
212 {
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20652
diff changeset
213 std::string stack_trace = e.info ();
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20652
diff changeset
214
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20652
diff changeset
215 if (! stack_trace.empty ())
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20652
diff changeset
216 std::cerr << stack_trace;
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20652
diff changeset
217
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
218 if (octave::application::interactive ())
20741
a5ab31b52ae8 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
219 recover_from_exception ();
a5ab31b52ae8 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
220 else
a5ab31b52ae8 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
221 {
a5ab31b52ae8 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
222 // We should exit with a nonzero status.
a5ab31b52ae8 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
223 retval = 1;
a5ab31b52ae8 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
224 break;
a5ab31b52ae8 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
225 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
226 }
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
227 catch (const std::bad_alloc&)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
228 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
229 recover_from_exception ();
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20741
diff changeset
230
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
231 std::cerr << "error: out of memory -- trying to return to prompt"
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
232 << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
233 }
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21140
diff changeset
234
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21618
diff changeset
235 #if defined (DBSTOP_NANINF)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21140
diff changeset
236 if (Vdebug_on_naninf)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21140
diff changeset
237 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21140
diff changeset
238 if (setjump (naninf_jump) != 0)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21140
diff changeset
239 debug_or_throw_exception (true); // true = stack trace
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21140
diff changeset
240 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21140
diff changeset
241 #endif
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
242 }
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
243 while (retval == 0);
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
244
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
245 if (octave::application::interactive ())
21363
8cfd1b47d49f Eliminate more extra newlines to stdout when not interactive (bug #47258)
Mike Miller <mtmiller@octave.org>
parents: 21359
diff changeset
246 octave_stdout << "\n";
18638
4ccd2b473f84 Print newline after closing interpreter with EOF (bug #41513).
Vaibhav Gupta <vaibhav.gupta@students.iiit.ac.in>
parents: 18515
diff changeset
247
16987
aabe12e5fdc1 Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents: 16892
diff changeset
248 if (retval == EOF)
aabe12e5fdc1 Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents: 16892
diff changeset
249 retval = 0;
aabe12e5fdc1 Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents: 16892
diff changeset
250
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
251 return retval;
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
252 }
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
253
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
254 // Fix up things before exiting.
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
255
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
256 static std::list<std::string> octave_atexit_functions;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
257
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
258 static void
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
259 do_octave_atexit (void)
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
260 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
261 static bool deja_vu = false;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
262
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
263 OCTAVE_SAFE_CALL (remove_input_event_hook_functions, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
264
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
265 while (! octave_atexit_functions.empty ())
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
266 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
267 std::string fcn = octave_atexit_functions.front ();
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
268
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
269 octave_atexit_functions.pop_front ();
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
270
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
271 OCTAVE_SAFE_CALL (reset_error_handler, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
272
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
273 OCTAVE_SAFE_CALL (feval, (fcn, octave_value_list (), 0));
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
274
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
275 OCTAVE_SAFE_CALL (flush_octave_stdout, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
276 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
277
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
278 if (! deja_vu)
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
279 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
280 deja_vu = true;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
281
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
282 // Process pending events and disasble octave_link event
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
283 // processing with this call.
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
284
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
285 octave_link::process_events (true);
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
286
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
287 // Do this explicitly so that destructors for mex file objects
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
288 // are called, so that functions registered with mexAtExit are
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
289 // called.
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
290 OCTAVE_SAFE_CALL (clear_mex_functions, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
291
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
292 OCTAVE_SAFE_CALL (octave::command_editor::restore_terminal_state, ());
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
293
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
294 // FIXME: is this needed? Can it cause any trouble?
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
295 OCTAVE_SAFE_CALL (raw_mode, (0));
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
296
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
297 OCTAVE_SAFE_CALL (octave_history_write_timestamp, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
298
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
299 if (! octave::command_history::ignoring_entries ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
300 OCTAVE_SAFE_CALL (octave::command_history::clean_up_and_save, ());
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
301
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
302 OCTAVE_SAFE_CALL (gh_manager::close_all_figures, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
303
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
304 OCTAVE_SAFE_CALL (gtk_manager::unload_all_toolkits, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
305
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
306 OCTAVE_SAFE_CALL (close_files, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
307
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
308 OCTAVE_SAFE_CALL (cleanup_tmp_files, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
309
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
310 OCTAVE_SAFE_CALL (symbol_table::cleanup, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
311
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
312 OCTAVE_SAFE_CALL (sysdep_cleanup, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
313
17755
9c03b071fd7b avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
314 OCTAVE_SAFE_CALL (octave_finalize_hdf5, ());
9c03b071fd7b avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
315
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
316 OCTAVE_SAFE_CALL (flush_octave_stdout, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
317
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
318 if (! quitting_gracefully && octave::application::interactive ())
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
319 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
320 octave_stdout << "\n";
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
321
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
322 // Yes, we want this to be separate from the call to
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
323 // flush_octave_stdout above.
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
324
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
325 OCTAVE_SAFE_CALL (flush_octave_stdout, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
326 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
327
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
328 // Don't call singleton_cleanup_list::cleanup until we have the
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
329 // problems with registering/unregistering types worked out. For
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
330 // example, uncomment the following line, then use the make_int
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
331 // function from the examples directory to create an integer
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
332 // object and then exit Octave. Octave should crash with a
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
333 // segfault when cleaning up the typinfo singleton. We need some
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
334 // way to force new octave_value_X types that are created in
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
335 // .oct files to be unregistered when the .oct file shared library
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
336 // is unloaded.
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
337 //
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
338 // OCTAVE_SAFE_CALL (singleton_cleanup_list::cleanup, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
339
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
340 OCTAVE_SAFE_CALL (octave_chunk_buffer::clear, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
341 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
342 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
343
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
344 void
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
345 clean_up_and_exit (int status, bool safe_to_return)
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3147
diff changeset
346 {
3216
60a89a69a70a [project @ 1998-11-11 20:47:03 by jwe]
jwe
parents: 3215
diff changeset
347 do_octave_atexit ();
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
348
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
349 if (octave_link::exit (status))
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
350 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
351 if (safe_to_return)
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
352 return;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
353 else
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
354 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
355 // What should we do here? We might be called from some
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
356 // location other than the end of octave_execute_interpreter,
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
357 // so it might not be safe to return.
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
358
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
359 // We have nothing else to do at this point, and the
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
360 // octave_link::exit function is supposed to take care of
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
361 // exiting for us. Assume that job won't take more than a
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
362 // day...
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
363
20923
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20878
diff changeset
364 octave_sleep (86400); // FIXME: really needed?
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
365 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
366 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
367 else
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
368 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
369 if (octave_exit)
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
370 (*octave_exit) (status);
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
371 }
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
372 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
373
11023
cb62c7401ea2 toplev.cc (Fquit): allow any number of output paramters
John W. Eaton <jwe@octave.org>
parents: 10890
diff changeset
374 DEFUN (quit, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
375 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
376 @deftypefn {} {} exit
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
377 @deftypefnx {} {} exit (@var{status})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
378 @deftypefnx {} {} quit
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
379 @deftypefnx {} {} quit (@var{status})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
380 Exit the current Octave session.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
381
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
382 If the optional integer value @var{status} is supplied, pass that value to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
383 the operating system as Octave's exit status. The default value is zero.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
384
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
385 When exiting, Octave will attempt to run the m-file @file{finish.m} if it
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
386 exists. User commands to save the workspace or clean up temporary files
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
387 may be placed in that file. Alternatively, another m-file may be scheduled
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
388 to run using @code{atexit}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
389 @seealso{atexit}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
390 @end deftypefn */)
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
391 {
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
392 // Confirm OK to shutdown. Note: A dynamic function installation similar
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
393 // to overriding polymorphism for which the GUI can install its own "quit"
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
394 // yet call this base "quit" could be nice. No link would be needed here.
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
395 if (! octave_link::confirm_shutdown ())
21078
49852ff04747 maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents: 21055
diff changeset
396 return ovl ();
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
397
9255
1c2d2c9f4a8d don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents: 9217
diff changeset
398 if (! quit_allowed)
11590
4ced6b90fffb style fixes for warning and error messages in source files
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
399 error ("quit: not supported in embedded mode");
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
400
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
401 if (args.length () > 0)
2068
18365b6332a8 [project @ 1996-04-17 23:37:35 by jwe]
jwe
parents: 2016
diff changeset
402 {
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
403 int tmp = args(0).nint_value ();
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
404
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
405 exit_status = tmp;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
406 }
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 3162
diff changeset
407
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
408 // Instead of simply calling exit, we simulate an interrupt
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
409 // with a request to exit cleanly so that no matter where the
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
410 // call to quit occurs, we will run the unwind_protect stack,
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
411 // clear the OCTAVE_LOCAL_BUFFER allocations, etc. before
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
412 // exiting.
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
413
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
414 quitting_gracefully = true;
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
415
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
416 octave_interrupt_state = -1;
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
417
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
418 octave_throw_interrupt_exception ();
2068
18365b6332a8 [project @ 1996-04-17 23:37:35 by jwe]
jwe
parents: 2016
diff changeset
419
21078
49852ff04747 maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents: 21055
diff changeset
420 return ovl ();
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
421 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
422
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
423 DEFALIAS (exit, quit);
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
424
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1907
diff changeset
425 DEFUN (warranty, , ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
426 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
427 @deftypefn {} {} warranty ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
428 Describe the conditions for copying and distributing Octave.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
429 @end deftypefn */)
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
430 {
17510
7542f4496974 eliminate some macros in version.h
John W. Eaton <jwe@octave.org>
parents: 17281
diff changeset
431 octave_stdout << "\n" << octave_name_version_and_copyright () << "\n\
3922
38c61cbf086c [project @ 2002-05-01 06:48:35 by jwe]
jwe
parents: 3892
diff changeset
432 \n\
19604
7005044f3080 Correct missing word in output of warranty().
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17821
diff changeset
433 GNU Octave is free software; you can redistribute it and/or modify\n\
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
434 it under the terms of the GNU General Public License as published by\n\
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7013
diff changeset
435 the Free Software Foundation; either version 3 of the License, or\n\
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
436 (at your option) any later version.\n\
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
437 \n\
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
438 GNU Octave is distributed in the hope that it will be useful,\n\
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
439 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
440 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
441 GNU General Public License for more details.\n\
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
442 \n\
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
443 You should have received a copy of the GNU General Public License\n\
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7013
diff changeset
444 along with this program. If not, see <http://www.gnu.org/licenses/>.\n\
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
445 \n";
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
446
21078
49852ff04747 maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents: 21055
diff changeset
447 return ovl ();
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
448 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
449
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
450 // Execute a shell command.
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
451
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 2084
diff changeset
452 static octave_value_list
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
453 run_command_and_return_output (const std::string& cmd_str)
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
454 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 2084
diff changeset
455 octave_value_list retval;
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
456 octave::unwind_protect frame;
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
457
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
458 iprocstream *cmd = new iprocstream (cmd_str.c_str ());
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
459
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
460 frame.add_delete (cmd);
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
461 frame.add_fcn (octave::child_list::remove, cmd->pid ());
3060
9c6cd52f3f5a [project @ 1997-06-25 18:30:40 by jwe]
jwe
parents: 3020
diff changeset
462
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
463 if (! *cmd)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
464 error ("system: unable to start subprocess for '%s'", cmd_str.c_str ());
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
465
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
466 int fid = cmd->file_number ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
467
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
468 std::ostringstream output_buf;
2095
36903d507b0e [project @ 1996-04-28 09:00:07 by jwe]
jwe
parents: 2086
diff changeset
469
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
470 char ch;
4494
93ad80b6eef6 [project @ 2003-09-03 20:27:00 by jwe]
jwe
parents: 4489
diff changeset
471
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
472 for (;;)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
473 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
474 if (cmd->get (ch))
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
475 output_buf.put (ch);
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
476 else
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
477 {
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
478 if (! cmd->eof () && errno == EAGAIN)
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
479 {
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
480 cmd->clear ();
3147
894d516b4a00 [project @ 1998-02-06 06:00:08 by jwe]
jwe
parents: 3141
diff changeset
481
21899
7c053ad1c7ba hide sys/select header
John W. Eaton <jwe@octave.org>
parents: 21855
diff changeset
482 if (octave_wait_for_input (fid) != 1)
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
483 break;
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
484 }
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
485 else
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
486 break;
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
487 }
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
488 }
3147
894d516b4a00 [project @ 1998-02-06 06:00:08 by jwe]
jwe
parents: 3141
diff changeset
489
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
490 int cmd_status = cmd->close ();
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
491
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21907
diff changeset
492 if (octave::sys::wifexited (cmd_status))
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21907
diff changeset
493 cmd_status = octave::sys::wexitstatus (cmd_status);
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
494 else
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
495 cmd_status = 127;
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
496
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20946
diff changeset
497 retval = ovl (cmd_status, output_buf.str ());
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
498
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
499 return retval;
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
500 }
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
501
5285
fe5ee25a5e6c [project @ 2005-04-19 15:02:49 by jwe]
jwe
parents: 5275
diff changeset
502 enum system_exec_type { et_sync, et_async };
fe5ee25a5e6c [project @ 2005-04-19 15:02:49 by jwe]
jwe
parents: 5275
diff changeset
503
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1907
diff changeset
504 DEFUN (system, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
505 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
506 @deftypefn {} {} system ("@var{string}")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
507 @deftypefnx {} {} system ("@var{string}", @var{return_output})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
508 @deftypefnx {} {} system ("@var{string}", @var{return_output}, @var{type})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
509 @deftypefnx {} {[@var{status}, @var{output}] =} system (@dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
510 Execute a shell command specified by @var{string}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
511
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
512 If the optional argument @var{type} is @qcode{"async"}, the process is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
513 started in the background and the process ID of the child process is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
514 returned immediately. Otherwise, the child process is started and Octave
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
515 waits until it exits. If the @var{type} argument is omitted, it defaults to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
516 the value @qcode{"sync"}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
517
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
518 If @var{system} is called with one or more output arguments, or if the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
519 optional argument @var{return_output} is true and the subprocess is started
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
520 synchronously, then the output from the command is returned as a variable.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
521 Otherwise, if the subprocess is executed synchronously, its output is sent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
522 to the standard output. To send the output of a command executed with
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
523 @code{system} through the pager, use a command like
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
524
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
525 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
526 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
527 [~, text] = system ("cmd");
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
528 disp (text);
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
529 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
530 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
531
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
532 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
533 or
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
534
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
535 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
536 printf ("%s\n", nthargout (2, "system", "cmd"));
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
537 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
538
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
539 The @code{system} function can return two values. The first is the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
540 exit status of the command and the second is any output from the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
541 command that was written to the standard output stream. For example,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
542
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
543 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
544 [status, output] = system ("echo foo; exit 2");
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
545 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
546
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
547 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
548 will set the variable @code{output} to the string @samp{foo}, and the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
549 variable @code{status} to the integer @samp{2}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
550
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
551 For commands run asynchronously, @var{status} is the process id of the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
552 command shell that is started to run the command.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
553 @seealso{unix, dos}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
554 @end deftypefn */)
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
555 {
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
556 int nargin = args.length ();
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
557
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
558 if (nargin == 0 || nargin > 3)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
559 print_usage ();
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
560
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
561 system_exec_type type = et_sync;
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
562 if (nargin == 3)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
563 {
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
564 std::string type_str = args(2).xstring_value ("system: TYPE must be a string");
11123
fbec4b3be59f toplev.cc (Fsystem): allow optional return_output and type arguments to be specified independently
John W. Eaton <jwe@octave.org>
parents: 11104
diff changeset
565
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
566 if (type_str == "sync")
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
567 type = et_sync;
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
568 else if (type_str == "async")
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
569 type = et_async;
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
570 else
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
571 error ("system: TYPE must be \"sync\" or \"async\"");
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
572 }
11123
fbec4b3be59f toplev.cc (Fsystem): allow optional return_output and type arguments to be specified independently
John W. Eaton <jwe@octave.org>
parents: 11104
diff changeset
573
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
574 octave_value_list retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
575
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
576 // FIXME: Is this unwind_protect frame needed anymore (12/16/15)?
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
577 octave::unwind_protect frame;
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
578
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
579 bool return_output = (nargin == 1 && nargout > 1);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
580
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
581 if (nargin > 1)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
582 {
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
583 try
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
584 {
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
585 return_output = args(1).is_true ();
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
586 }
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
587 catch (octave_execution_exception& e)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
588 {
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
589 error (e, "system: RETURN_OUTPUT must be boolean value true or false");
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
590 }
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
591 }
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
592
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
593 if (return_output && type == et_async)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
594 error ("system: can't return output from commands run asynchronously");
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
595
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
596 std::string cmd_str = args(0).xstring_value ("system: first argument must be a string");
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
597
21979
d04da18a407a use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
598 #if defined (OCTAVE_USE_WINDOWS_API)
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
599 // Work around weird double-quote handling on Windows systems.
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
600 if (type == et_sync)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
601 cmd_str = "\"" + cmd_str + "\"";
7104
b26d0cd10a42 [project @ 2007-11-06 17:18:41 by jwe]
jwe
parents: 7017
diff changeset
602 #endif
b26d0cd10a42 [project @ 2007-11-06 17:18:41 by jwe]
jwe
parents: 7017
diff changeset
603
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
604 if (type == et_async)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
605 {
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
606 // FIXME: maybe this should go in sysdep.cc?
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21618
diff changeset
607 #if defined (HAVE_FORK)
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
608 pid_t pid = fork ();
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
609
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
610 if (pid < 0)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
611 error ("system: fork failed -- can't create child process");
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
612 else if (pid == 0)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
613 {
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
614 // FIXME: should probably replace this call with something portable.
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
615 execl (SHELL_PATH, "sh", "-c", cmd_str.c_str (),
21534
be1c9f1e31ab Cast NULL pointer to char, rather than void, when using execl.
Rik <rik@octave.org>
parents: 21434
diff changeset
616 static_cast<char *> (0));
3273
eb27ea9b7ff8 [project @ 1999-10-12 02:22:25 by jwe]
jwe
parents: 3258
diff changeset
617
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
618 panic_impossible ();
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
619 }
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
620 else
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
621 retval(0) = pid;
21979
d04da18a407a use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
622 #elif defined (OCTAVE_USE_WINDOWS_API)
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
623 STARTUPINFO si;
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
624 PROCESS_INFORMATION pi;
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
625 ZeroMemory (&si, sizeof (si));
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
626 ZeroMemory (&pi, sizeof (pi));
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
627 OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length ()+1);
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
628 strcpy (xcmd_str, cmd_str.c_str ());
6222
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
629
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
630 if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi))
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
631 error ("system: CreateProcess failed -- can't create child process");
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
632
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
633 retval(0) = pi.dwProcessId;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
634 CloseHandle (pi.hProcess);
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 21017
diff changeset
635 CloseHandle (pi.hThread);
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
636 #else
21109
bd1752782e56 Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents: 21078
diff changeset
637 err_disabled_feature ("system", "asynchronous system calls");
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
638 #endif
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
639 }
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
640 else if (return_output)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
641 retval = run_command_and_return_output (cmd_str);
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
642 else
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
643 {
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
644 int status = system (cmd_str.c_str ());
2321
dac9933079e6 [project @ 1996-07-15 21:08:05 by jwe]
jwe
parents: 2299
diff changeset
645
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
646 // The value in status is as returned by waitpid. If
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
647 // the process exited normally, extract the actual exit
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
648 // status of the command. Otherwise, return 127 as a
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
649 // failure code.
20582
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
650
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21907
diff changeset
651 if (octave::sys::wifexited (status))
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21907
diff changeset
652 status = octave::sys::wexitstatus (status);
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
653
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
654 retval(0) = status;
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
655 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
656
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
657 return retval;
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
658 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
659
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
660 /*
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
661 %!test
14018
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
662 %! cmd = ls_command ();
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
663 %! [status, output] = system (cmd);
14018
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
664 %! assert (status, 0);
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
665 %! assert (ischar (output));
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
666 %! assert (! isempty (output));
14018
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
667
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
668 %!error system ()
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
669 %!error system (1, 2, 3)
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
670 */
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
671
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
672 void
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
673 octave_add_atexit_function (const std::string& fname)
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
674 {
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
675 octave_atexit_functions.push_front (fname);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
676 }
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
677
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
678 bool
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
679 octave_remove_atexit_function (const std::string& fname)
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
680 {
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
681 bool found = false;
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
682
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
683 for (std::list<std::string>::iterator p = octave_atexit_functions.begin ();
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
684 p != octave_atexit_functions.end (); p++)
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
685 {
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
686 if (*p == fname)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
687 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
688 octave_atexit_functions.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
689 found = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
690 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
691 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
692 }
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
693
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
694 return found;
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
695 }
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
696
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
697 DEFUN (atexit, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
698 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
699 @deftypefn {} {} atexit (@var{fcn})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
700 @deftypefnx {} {} atexit (@var{fcn}, @var{flag})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
701 Register a function to be called when Octave exits.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
702
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
703 For example,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
704
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
705 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
706 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
707 function last_words ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
708 disp ("Bye bye");
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
709 endfunction
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
710 atexit ("last_words");
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
711 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
712 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
713
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
714 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
715 will print the message @qcode{"Bye bye"} when Octave exits.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
716
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
717 The additional argument @var{flag} will register or unregister @var{fcn}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
718 from the list of functions to be called when Octave exits. If @var{flag} is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
719 true, the function is registered, and if @var{flag} is false, it is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
720 unregistered. For example, after registering the function @code{last_words}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
721 above,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
722
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
723 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
724 atexit ("last_words", false);
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
725 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
726
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
727 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
728 will remove the function from the list and Octave will not call
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
729 @code{last_words} when it exits.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
730
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
731 Note that @code{atexit} only removes the first occurrence of a function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
732 from the list, so if a function was placed in the list multiple times with
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
733 @code{atexit}, it must also be removed from the list multiple times.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
734 @seealso{quit}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
735 @end deftypefn */)
2077
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
736 {
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
737 int nargin = args.length ();
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
738
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
739 if (nargin < 1 || nargin > 2)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
740 print_usage ();
20582
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
741
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
742 std::string arg = args(0).xstring_value ("atexit: FCN argument must be a string");
2077
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
743
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
744 bool add_mode = (nargin == 2)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
745 ? args(1).xbool_value ("atexit: FLAG argument must be a logical value")
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
746 : true;
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
747
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
748 octave_value_list retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
749
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
750 if (add_mode)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
751 octave_add_atexit_function (arg);
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
752 else
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
753 {
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
754 bool found = octave_remove_atexit_function (arg);
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
755
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
756 if (nargout > 0)
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
757 retval = ovl (found);
2077
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
758 }
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
759
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
760 return retval;
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
761 }
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
762
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
763 static octave_value
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
764 find_config_info (const octave_scalar_map& m, const std::string& key)
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
765 {
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
766 if (m.isfield (key))
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
767 {
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
768 Cell c = m.contents (key);
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
769
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
770 if (! c.is_empty ())
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
771 return c(0);
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
772 }
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
773
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
774 return octave_value ();
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
775 }
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
776
21434
1da428cbf401 deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents: 21421
diff changeset
777 DEFUN (__octave_config_info__, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
778 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
779 @deftypefn {} {} __octave_config_info__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
780 @deftypefnx {} {} __octave_config_info__ (@var{option})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
781 Return a structure containing configuration and installation information for
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
782 Octave.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
783
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
784 If @var{option} is a string, return the configuration information for the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
785 specified option.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
786
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
787 @seealso{computer}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
788 @end deftypefn */)
2162
a940dcdfe9de [project @ 1996-05-13 10:31:51 by jwe]
jwe
parents: 2145
diff changeset
789 {
4128
919b2f6573ee [project @ 2002-10-25 20:36:14 by jwe]
jwe
parents: 4111
diff changeset
790 #if defined (ENABLE_DYNAMIC_LINKING)
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
791 bool octave_supports_dynamic_linking = true;
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
792 #else
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
793 bool octave_supports_dynamic_linking = false;
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
794 #endif
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
795
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
796 static bool initialized = false;
2162
a940dcdfe9de [project @ 1996-05-13 10:31:51 by jwe]
jwe
parents: 2145
diff changeset
797
6274
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
798 struct conf_info_struct
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
799 {
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
800 const char *key;
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
801 octave_value val;
6274
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
802 };
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
803
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
804 static const conf_info_struct conf_info[] =
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
805 {
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
806 { "DEFAULT_PAGER", OCTAVE_DEFAULT_PAGER },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
807
21229
a83e7a384ee0 create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents: 21226
diff changeset
808 #if defined (OCTAVE_ENABLE_64)
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
809 { "ENABLE_64", true },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
810 #else
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
811 { "ENABLE_64", false },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
812 #endif
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
813
21229
a83e7a384ee0 create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents: 21226
diff changeset
814 #if defined (OCTAVE_ENABLE_ATOMIC_REFCOUNT)
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
815 { "ENABLE_ATOMIC_REFCOUNT", true },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
816 #else
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
817 { "ENABLE_ATOMIC_REFCOUNT", false },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
818 #endif
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
819
21229
a83e7a384ee0 create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents: 21226
diff changeset
820 #if defined (OCTAVE_ENABLE_BOUNDS_CHECK)
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
821 { "ENABLE_BOUNDS_CHECK", true },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
822 #else
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
823 { "ENABLE_BOUNDS_CHECK", false },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
824 #endif
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
825
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
826 #if defined (ENABLE_DOCS)
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
827 { "ENABLE_DOCS", true },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
828 #else
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
829 { "ENABLE_DOCS", false },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
830 #endif
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
831
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
832 #if defined (ENABLE_DYNAMIC_LINKING)
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
833 { "ENABLE_DYNAMIC_LINKING", true },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
834 #else
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
835 { "ENABLE_DYNAMIC_LINKING", false },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
836 #endif
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
837
21229
a83e7a384ee0 create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents: 21226
diff changeset
838 #if defined (OCTAVE_ENABLE_FLOAT_TRUNCATE)
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
839 { "ENABLE_FLOAT_TRUNCATE", true },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
840 #else
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
841 { "ENABLE_FLOAT_TRUNCATE", false },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
842 #endif
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
843
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
844 #if defined (ENABLE_JIT)
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
845 { "ENABLE_JIT", true },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
846 #else
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
847 { "ENABLE_JIT", false },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
848 #endif
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
849
21229
a83e7a384ee0 create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents: 21226
diff changeset
850 #if defined (OCTAVE_ENABLE_OPENMP)
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
851 { "ENABLE_OPENMP", true },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
852 #else
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
853 { "ENABLE_OPENMP", false },
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
854 #endif
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
855
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
856 { "api_version", OCTAVE_API_VERSION },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
857 { "archlibdir", subst_octave_home (OCTAVE_ARCHLIBDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
858 { "bindir", subst_octave_home (OCTAVE_BINDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
859 { "canonical_host_type", OCTAVE_CANONICAL_HOST_TYPE },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
860 { "datadir", subst_octave_home (OCTAVE_DATADIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
861 { "datarootdir", subst_octave_home (OCTAVE_DATAROOTDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
862 { "exec_prefix", subst_octave_home (OCTAVE_EXEC_PREFIX) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
863 { "fcnfiledir", subst_octave_home (OCTAVE_FCNFILEDIR) },
21600
184b85b31e03 more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents: 21598
diff changeset
864 { "fftw_version", octave_fftw_version () },
21603
37cbdf7bffa9 Add fftwf_version (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents: 21600
diff changeset
865 { "fftwf_version", octave_fftwf_version () },
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
866 { "imagedir", subst_octave_home (OCTAVE_IMAGEDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
867 { "includedir", subst_octave_home (OCTAVE_INCLUDEDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
868 { "infodir", subst_octave_home (OCTAVE_INFODIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
869 { "infofile", subst_octave_home (OCTAVE_INFOFILE) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
870 { "libdir", subst_octave_home (OCTAVE_LIBDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
871 { "libexecdir", subst_octave_home (OCTAVE_LIBEXECDIR) },
21608
80258bb3a14b store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents: 21607
diff changeset
872 // Each library and executable has its own definition of the hg
80258bb3a14b store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents: 21607
diff changeset
873 // id. We check for consistency when Octave starts so we just
80258bb3a14b store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents: 21607
diff changeset
874 // store and report one of them here.
80258bb3a14b store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents: 21607
diff changeset
875 { "hg_id", liboctinterp_hg_id () },
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
876 { "localapiarchlibdir", subst_octave_home (OCTAVE_LOCALAPIARCHLIBDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
877 { "localapifcnfiledir", subst_octave_home (OCTAVE_LOCALAPIFCNFILEDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
878 { "localapioctfiledir", subst_octave_home (OCTAVE_LOCALAPIOCTFILEDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
879 { "localarchlibdir", subst_octave_home (OCTAVE_LOCALARCHLIBDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
880 { "localfcnfiledir", subst_octave_home (OCTAVE_LOCALFCNFILEDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
881 { "localoctfiledir", subst_octave_home (OCTAVE_LOCALOCTFILEDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
882 { "localstartupfiledir", subst_octave_home (OCTAVE_LOCALSTARTUPFILEDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
883 { "localverarchlibdir", subst_octave_home (OCTAVE_LOCALVERARCHLIBDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
884 { "localverfcnfiledir", subst_octave_home (OCTAVE_LOCALVERFCNFILEDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
885 { "localveroctfiledir", subst_octave_home (OCTAVE_LOCALVEROCTFILEDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
886 { "man1dir", subst_octave_home (OCTAVE_MAN1DIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
887 { "man1ext", OCTAVE_MAN1EXT },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
888 { "mandir", subst_octave_home (OCTAVE_MANDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
889 { "octdatadir", subst_octave_home (OCTAVE_OCTDATADIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
890 { "octfiledir", subst_octave_home (OCTAVE_OCTFILEDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
891 { "octetcdir", subst_octave_home (OCTAVE_OCTETCDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
892 { "octincludedir", subst_octave_home (OCTAVE_OCTINCLUDEDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
893 { "octlibdir", subst_octave_home (OCTAVE_OCTLIBDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
894 { "octtestsdir", subst_octave_home (OCTAVE_OCTTESTSDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
895 { "prefix", subst_octave_home (OCTAVE_PREFIX) },
21598
cf552443c104 revise method of handling hg id for build info
John W. Eaton <jwe@octave.org>
parents: 21597
diff changeset
896 { "release_date", OCTAVE_RELEASE_DATE },
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
897 { "startupfiledir", subst_octave_home (OCTAVE_STARTUPFILEDIR) },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
898 { "version", OCTAVE_VERSION },
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
899 { 0, octave_value () }
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
900 };
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
901
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
902 struct build_info_struct
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
903 {
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
904 const char *key;
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
905 const char *val;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
906 };
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
907
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
908 static const build_info_struct build_info[] =
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
909 {
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
910 { "AMD_CPPFLAGS", octave::build_env::AMD_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
911 { "AMD_LDFLAGS", octave::build_env::AMD_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
912 { "AMD_LIBS", octave::build_env::AMD_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
913 { "AR", octave::build_env::AR },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
914 { "ARFLAGS", octave::build_env::ARFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
915 { "ARPACK_CPPFLAGS", octave::build_env::ARPACK_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
916 { "ARPACK_LDFLAGS", octave::build_env::ARPACK_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
917 { "ARPACK_LIBS", octave::build_env::ARPACK_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
918 { "BLAS_LIBS", octave::build_env::BLAS_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
919 { "CAMD_CPPFLAGS", octave::build_env::CAMD_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
920 { "CAMD_LDFLAGS", octave::build_env::CAMD_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
921 { "CAMD_LIBS", octave::build_env::CAMD_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
922 { "CARBON_LIBS", octave::build_env::CARBON_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
923 { "CC", octave::build_env::CC },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
924 { "CCOLAMD_CPPFLAGS", octave::build_env::CCOLAMD_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
925 { "CCOLAMD_LDFLAGS", octave::build_env::CCOLAMD_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
926 { "CCOLAMD_LIBS", octave::build_env::CCOLAMD_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
927 { "CFLAGS", octave::build_env::CFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
928 { "CHOLMOD_CPPFLAGS", octave::build_env::CHOLMOD_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
929 { "CHOLMOD_LDFLAGS", octave::build_env::CHOLMOD_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
930 { "CHOLMOD_LIBS", octave::build_env::CHOLMOD_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
931 { "COLAMD_CPPFLAGS", octave::build_env::COLAMD_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
932 { "COLAMD_LDFLAGS", octave::build_env::COLAMD_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
933 { "COLAMD_LIBS", octave::build_env::COLAMD_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
934 { "CPICFLAG", octave::build_env::CPICFLAG },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
935 { "CPPFLAGS", octave::build_env::CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
936 { "CURL_CPPFLAGS", octave::build_env::CURL_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
937 { "CURL_LDFLAGS", octave::build_env::CURL_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
938 { "CURL_LIBS", octave::build_env::CURL_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
939 { "CXSPARSE_CPPFLAGS", octave::build_env::CXSPARSE_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
940 { "CXSPARSE_LDFLAGS", octave::build_env::CXSPARSE_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
941 { "CXSPARSE_LIBS", octave::build_env::CXSPARSE_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
942 { "CXX", octave::build_env::CXX },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
943 { "CXXCPP", octave::build_env::CXXCPP },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
944 { "CXXFLAGS", octave::build_env::CXXFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
945 { "CXXPICFLAG", octave::build_env::CXXPICFLAG },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
946 { "DEFS", octave::build_env::DEFS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
947 { "DL_LD", octave::build_env::DL_LD },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
948 { "DL_LDFLAGS", octave::build_env::DL_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
949 { "DL_LIBS", octave::build_env::DL_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
950 { "GCC_VERSION", octave::build_env::GCC_VERSION },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
951 { "GXX_VERSION", octave::build_env::GXX_VERSION },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
952 { "EXEEXT", octave::build_env::EXEEXT },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
953 { "F77", octave::build_env::F77 },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
954 { "F77_FLOAT_STORE_FLAG", octave::build_env::F77_FLOAT_STORE_FLAG },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
955 { "F77_INTEGER_8_FLAG", octave::build_env::F77_INTEGER_8_FLAG },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
956 { "FFLAGS", octave::build_env::FFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
957 { "FFTW3_CPPFLAGS", octave::build_env::FFTW3_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
958 { "FFTW3_LDFLAGS", octave::build_env::FFTW3_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
959 { "FFTW3_LIBS", octave::build_env::FFTW3_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
960 { "FFTW3F_CPPFLAGS", octave::build_env::FFTW3F_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
961 { "FFTW3F_LDFLAGS", octave::build_env::FFTW3F_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
962 { "FFTW3F_LIBS", octave::build_env::FFTW3F_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
963 { "FLIBS", octave::build_env::FLIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
964 { "FLTK_CPPFLAGS", octave::build_env::FLTK_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
965 { "FLTK_LDFLAGS", octave::build_env::FLTK_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
966 { "FLTK_LIBS", octave::build_env::FLTK_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
967 { "FONTCONFIG_CPPFLAGS", octave::build_env::FONTCONFIG_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
968 { "FONTCONFIG_LIBS", octave::build_env::FONTCONFIG_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
969 { "FPICFLAG", octave::build_env::FPICFLAG },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
970 { "FT2_CPPFLAGS", octave::build_env::FT2_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
971 { "FT2_LIBS", octave::build_env::FT2_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
972 { "GLPK_CPPFLAGS", octave::build_env::GLPK_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
973 { "GLPK_LDFLAGS", octave::build_env::GLPK_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
974 { "GLPK_LIBS", octave::build_env::GLPK_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
975 { "GNUPLOT", octave::build_env::GNUPLOT },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
976 { "HDF5_CPPFLAGS", octave::build_env::HDF5_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
977 { "HDF5_LDFLAGS", octave::build_env::HDF5_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
978 { "HDF5_LIBS", octave::build_env::HDF5_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
979 { "LAPACK_LIBS", octave::build_env::LAPACK_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
980 { "LDFLAGS", octave::build_env::LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
981 { "LD_CXX", octave::build_env::LD_CXX },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
982 { "LD_STATIC_FLAG", octave::build_env::LD_STATIC_FLAG },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
983 { "LEX", octave::build_env::LEX },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
984 { "LEXLIB", octave::build_env::LEXLIB },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
985 { "LFLAGS", octave::build_env::LFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
986 { "LIBOCTAVE", octave::build_env::LIBOCTAVE },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
987 { "LIBOCTINTERP", octave::build_env::LIBOCTINTERP },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
988 { "LIBS", octave::build_env::LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
989 { "LLVM_CPPFLAGS", octave::build_env::LLVM_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
990 { "LLVM_LDFLAGS", octave::build_env::LLVM_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
991 { "LLVM_LIBS", octave::build_env::LLVM_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
992 { "LN_S", octave::build_env::LN_S },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
993 { "MAGICK_CPPFLAGS", octave::build_env::MAGICK_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
994 { "MAGICK_LDFLAGS", octave::build_env::MAGICK_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
995 { "MAGICK_LIBS", octave::build_env::MAGICK_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
996 { "MKOCTFILE_DL_LDFLAGS", octave::build_env::MKOCTFILE_DL_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
997 { "OCTAVE_LINK_DEPS", octave::build_env::OCTAVE_LINK_DEPS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
998 { "OCTAVE_LINK_OPTS", octave::build_env::OCTAVE_LINK_OPTS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
999 { "OCT_LINK_DEPS", octave::build_env::OCT_LINK_DEPS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1000 { "OCT_LINK_OPTS", octave::build_env::OCT_LINK_OPTS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1001 { "OPENGL_LIBS", octave::build_env::OPENGL_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1002 { "OSMESA_CPPFLAGS", octave::build_env::OSMESA_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1003 { "OSMESA_LDFLAGS", octave::build_env::OSMESA_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1004 { "OSMESA_LIBS", octave::build_env::OSMESA_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1005 { "PCRE_CPPFLAGS", octave::build_env::PCRE_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1006 { "PCRE_LIBS", octave::build_env::PCRE_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1007 { "PTHREAD_CFLAGS", octave::build_env::PTHREAD_CFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1008 { "PTHREAD_LIBS", octave::build_env::PTHREAD_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1009 { "QHULL_CPPFLAGS", octave::build_env::QHULL_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1010 { "QHULL_LDFLAGS", octave::build_env::QHULL_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1011 { "QHULL_LIBS", octave::build_env::QHULL_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1012 { "QRUPDATE_CPPFLAGS", octave::build_env::QRUPDATE_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1013 { "QRUPDATE_LDFLAGS", octave::build_env::QRUPDATE_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1014 { "QRUPDATE_LIBS", octave::build_env::QRUPDATE_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1015 { "QT_CPPFLAGS", octave::build_env::QT_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1016 { "QT_LDFLAGS", octave::build_env::QT_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1017 { "QT_LIBS", octave::build_env::QT_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1018 { "RANLIB", octave::build_env::RANLIB },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1019 { "RDYNAMIC_FLAG", octave::build_env::RDYNAMIC_FLAG },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1020 { "READLINE_LIBS", octave::build_env::READLINE_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1021 { "SED", octave::build_env::SED },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1022 { "SHARED_LIBS", octave::build_env::SHARED_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1023 { "SH_LD", octave::build_env::SH_LD },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1024 { "SH_LDFLAGS", octave::build_env::SH_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1025 { "STATIC_LIBS", octave::build_env::STATIC_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1026 { "TERM_LIBS", octave::build_env::TERM_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1027 { "UMFPACK_CPPFLAGS", octave::build_env::UMFPACK_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1028 { "UMFPACK_LDFLAGS", octave::build_env::UMFPACK_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1029 { "UMFPACK_LIBS", octave::build_env::UMFPACK_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1030 { "WARN_CFLAGS", octave::build_env::WARN_CFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1031 { "WARN_CXXFLAGS", octave::build_env::WARN_CXXFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1032 { "X11_INCFLAGS", octave::build_env::X11_INCFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1033 { "X11_LIBS", octave::build_env::X11_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1034 { "XTRA_CFLAGS", octave::build_env::XTRA_CFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1035 { "XTRA_CXXFLAGS", octave::build_env::XTRA_CXXFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1036 { "YACC", octave::build_env::YACC },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1037 { "YFLAGS", octave::build_env::YFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1038 { "Z_CPPFLAGS", octave::build_env::Z_CPPFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1039 { "Z_LDFLAGS", octave::build_env::Z_LDFLAGS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1040 { "Z_LIBS", octave::build_env::Z_LIBS },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1041 { "config_opts", octave::build_env::config_opts },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1042 { 0, 0 },
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1043 };
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1044
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1045 static octave_scalar_map config;
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1046 static octave_scalar_map build_env;
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1047 static octave_scalar_map build_features = octave::build_env::features ();
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1048
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1049 if (! initialized)
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1050 {
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1051 int i;
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1052
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1053 i = 0;
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1054 while (true)
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1055 {
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1056 const build_info_struct& elt = build_info[i++];
4697
c26904f532f1 [project @ 2004-01-16 17:49:20 by jwe]
jwe
parents: 4691
diff changeset
1057
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1058 const char *key = elt.key;
4697
c26904f532f1 [project @ 2004-01-16 17:49:20 by jwe]
jwe
parents: 4691
diff changeset
1059
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1060 if (key)
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1061 build_env.assign (key, elt.val);
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1062 else
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1063 break;
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1064 }
4697
c26904f532f1 [project @ 2004-01-16 17:49:20 by jwe]
jwe
parents: 4691
diff changeset
1065
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1066 i = 0;
4440
0bca8443db39 [project @ 2003-07-02 22:45:29 by jwe]
jwe
parents: 4429
diff changeset
1067 while (true)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1068 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1069 const conf_info_struct& elt = conf_info[i++];
6274
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
1070
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1071 const char *key = elt.key;
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1072
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1073 if (key)
21253
a66a737913b5 allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
1074 config.assign (key, elt.val);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1075 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1076 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1077 }
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1078
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1079 bool unix_system = true;
7013
f943e9635115 [project @ 2007-10-11 19:39:02 by jwe]
jwe
parents: 7010
diff changeset
1080 bool mac_system = false;
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1081 bool windows_system = false;
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1082
21979
d04da18a407a use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
1083 #if defined (__WIN32__)
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1084 windows_system = true;
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20785
diff changeset
1085 #if ! defined (__CYGWIN__)
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1086 unix_system = false;
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1087 #endif
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1088 #endif
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1089
8574
83b8c739d626 toplev.cc: check OCTAVE_USE_OS_X_API instead of __APPLE__ && __MACH__
John W. Eaton <jwe@octave.org>
parents: 8377
diff changeset
1090 #if defined (OCTAVE_USE_OS_X_API)
7010
f7d2f54008f5 [project @ 2007-10-11 17:50:34 by jwe]
jwe
parents: 7001
diff changeset
1091 mac_system = true;
f7d2f54008f5 [project @ 2007-10-11 17:50:34 by jwe]
jwe
parents: 7001
diff changeset
1092 #endif
f7d2f54008f5 [project @ 2007-10-11 17:50:34 by jwe]
jwe
parents: 7001
diff changeset
1093
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1094 config.assign ("unix", octave_value (unix_system));
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1095 config.assign ("mac", octave_value (mac_system));
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1096 config.assign ("windows", octave_value (windows_system));
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1097
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1098 config.assign ("dld", octave_value (octave_supports_dynamic_linking));
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1099
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1100 octave::mach_info::float_format ff = octave::mach_info::native_float_format ();
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1101 config.assign ("float_format",
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1102 octave_value (octave::mach_info::float_format_as_string (ff)));
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1103
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1104 config.assign ("words_big_endian",
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1105 octave_value (octave::mach_info::words_big_endian ()));
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1106
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1107 config.assign ("words_little_endian",
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1108 octave_value (octave::mach_info::words_little_endian ()));
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1109
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1110 config.assign ("build_environment", octave_value (build_env));
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1111
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1112 config.assign ("build_features", octave_value (build_features));
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1113
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1114 initialized = true;
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1115 }
2162
a940dcdfe9de [project @ 1996-05-13 10:31:51 by jwe]
jwe
parents: 2145
diff changeset
1116
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1117 int nargin = args.length ();
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1118
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
1119 if (nargin > 1)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
1120 print_usage ();
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
1121
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
1122 octave_value_list retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
1123
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1124 if (nargin == 1)
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1125 {
21434
1da428cbf401 deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents: 21421
diff changeset
1126 std::string arg = args(0).xstring_value ("__octave_config_info__: OPTION argument must be a string");
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1127
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1128 octave_value info = find_config_info (config, arg);
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1129
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1130 if (info.is_undefined ())
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1131 info = find_config_info (build_env, arg);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
1132
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1133 if (info.is_undefined ())
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1134 info = find_config_info (build_features, arg);
5199
16a6247730d9 [project @ 2005-03-10 20:24:45 by jwe]
jwe
parents: 5189
diff changeset
1135
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1136 if (info.is_undefined ())
21434
1da428cbf401 deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents: 21421
diff changeset
1137 error ("__octave_config_info__: no info for '%s'", arg.c_str ());
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
1138
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1139 return info;
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1140 }
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
1141 else
21226
a55b8ece1ecd reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents: 21220
diff changeset
1142 retval = ovl (config);
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1143
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1144 return retval;
2162
a940dcdfe9de [project @ 1996-05-13 10:31:51 by jwe]
jwe
parents: 2145
diff changeset
1145 }
a940dcdfe9de [project @ 1996-05-13 10:31:51 by jwe]
jwe
parents: 2145
diff changeset
1146
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1147 /*
21434
1da428cbf401 deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents: 21421
diff changeset
1148 %!assert (ischar (__octave_config_info__ ("version")))
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1149 %!test
21434
1da428cbf401 deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents: 21421
diff changeset
1150 %! x = __octave_config_info__ ();
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1151 %! assert (isstruct (x));
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1152 %! assert (! isempty (x));
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14156
diff changeset
1153
21603
37cbdf7bffa9 Add fftwf_version (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents: 21600
diff changeset
1154 %!assert (__octave_config_info__ ("fftw_version"), __octave_config_info__ ("fftwf_version"))
37cbdf7bffa9 Add fftwf_version (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents: 21600
diff changeset
1155
21434
1da428cbf401 deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents: 21421
diff changeset
1156 %!error __octave_config_info__ (1, 2)
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1157 */
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1158
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1159 #if defined (__GNUG__) && defined (DEBUG_NEW_DELETE)
2806
187d5321cfa3 [project @ 1997-03-11 05:13:15 by jwe]
jwe
parents: 2802
diff changeset
1160
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1161 int debug_new_delete = 0;
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1162
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1163 typedef void (*vfp)(void);
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1164 extern vfp __new_handler;
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1165
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1166 void *
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1167 __builtin_new (size_t sz)
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1168 {
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1169 void *p;
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1170
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
1171 // malloc (0) is unpredictable; avoid it.
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1172 if (sz == 0)
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1173 sz = 1;
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1174 p = std::malloc (sz);
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1175 while (p == 0)
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1176 {
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1177 (*__new_handler) ();
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1178 p = std::malloc (sz);
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1179 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1180
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1181 if (debug_new_delete)
5629
489a475073d7 [project @ 2006-02-20 21:47:12 by jwe]
jwe
parents: 5510
diff changeset
1182 std::cerr << "__builtin_new: " << p << std::endl;
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1183
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1184 return p;
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1185 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1186
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1187 void
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1188 __builtin_delete (void *ptr)
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1189 {
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1190 if (debug_new_delete)
5629
489a475073d7 [project @ 2006-02-20 21:47:12 by jwe]
jwe
parents: 5510
diff changeset
1191 std::cerr << "__builtin_delete: " << ptr << std::endl;
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1192
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1193 if (ptr)
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1194 free (ptr);
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1195 }
2806
187d5321cfa3 [project @ 1997-03-11 05:13:15 by jwe]
jwe
parents: 2802
diff changeset
1196
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1197 #endif