annotate libinterp/corefcn/toplev.cc @ 18755:fc43c8017e9b

Fix infinite loop when using builtin ("keyboard") (bug #33296). * toplev.cc (octave_call_stack::do_goto_frame_relative): If call stack increment is 0 (not dbup, nor dbdown, but keyboard function), choose an increment of -1 to eventially break out of while (1) loop.
author Rik <rik@octave.org>
date Thu, 15 May 2014 08:16:53 -0700
parents 4ccd2b473f84
children 9ac2357f19bc
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
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17731
diff changeset
3 Copyright (C) 1995-2013 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
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
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
16317
ce5231908ea2 * toplev.cc: Include sys/select.h.
John W. Eaton <jwe@octave.org>
parents: 16292
diff changeset
38 #include <sys/select.h>
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
39 #include <sys/types.h>
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
40 #include <unistd.h>
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
41
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2910
diff changeset
42 #include "cmd-edit.h"
12989
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12846
diff changeset
43 #include "cmd-hist.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2910
diff changeset
44 #include "file-ops.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
45 #include "lo-error.h"
2370
a45c7d64b5e3 [project @ 1996-10-11 23:51:15 by jwe]
jwe
parents: 2322
diff changeset
46 #include "lo-mappers.h"
3020
f491f232cb09 [project @ 1997-06-03 22:15:08 by jwe]
jwe
parents: 3014
diff changeset
47 #include "oct-env.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
48 #include "oct-locbuf.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4130
diff changeset
49 #include "quit.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
50 #include "singleton-cleanup.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1751
diff changeset
51 #include "str-vec.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
52
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
53 #include "defaults.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
54 #include "defun.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
55 #include "error.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
56 #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
57 #include "graphics.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
58 #include "input.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
59 #include "lex.h"
17755
9c03b071fd7b avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
60 #include "load-save.h"
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
61 #include "octave-link.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
62 #include "oct-conf.h"
16170
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 16164
diff changeset
63 #include "oct-conf-features.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1728
diff changeset
64 #include "oct-hist.h"
2162
a940dcdfe9de [project @ 1996-05-13 10:31:51 by jwe]
jwe
parents: 2145
diff changeset
65 #include "oct-map.h"
2862
95e85daad148 [project @ 1997-04-15 22:00:57 by jwe]
jwe
parents: 2859
diff changeset
66 #include "oct-obj.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
67 #include "ov.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
68 #include "pager.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
69 #include "parse.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
70 #include "pathsearch.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
71 #include "procstream.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8581
diff changeset
72 #include "pt-eval.h"
2985
aa9d0c0e0458 [project @ 1997-05-16 06:54:18 by jwe]
jwe
parents: 2982
diff changeset
73 #include "pt-jump.h"
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents: 2973
diff changeset
74 #include "pt-stmt.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
75 #include "sighandlers.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
76 #include "sysdep.h"
2693
f4d0604cbcc4 [project @ 1997-02-18 15:25:21 by jwe]
jwe
parents: 2692
diff changeset
77 #include "syswait.h"
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
78 #include "toplev.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
79 #include "unwind-prot.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
80 #include "utils.h"
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
81 #include "variables.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
82 #include "version.h"
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
83
15756
ea1a1fb00744 Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents: 15596
diff changeset
84 #ifndef SHELL_PATH
ea1a1fb00744 Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents: 15596
diff changeset
85 #define SHELL_PATH "/bin/sh"
ea1a1fb00744 Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents: 15596
diff changeset
86 #endif
ea1a1fb00744 Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents: 15596
diff changeset
87
9217
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9187
diff changeset
88 void (*octave_exit) (int) = ::exit;
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9187
diff changeset
89
9255
1c2d2c9f4a8d don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents: 9217
diff changeset
90 // 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
91 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
92
3020
f491f232cb09 [project @ 1997-06-03 22:15:08 by jwe]
jwe
parents: 3014
diff changeset
93 // 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
94 bool quitting_gracefully = false;
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
95 // This stores the exit status.
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
96 int exit_status = 0;
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
97
4217
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4214
diff changeset
98 // 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
99 // is ready for interactive use.
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4214
diff changeset
100 bool octave_interpreter_ready = false;
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4214
diff changeset
101
4172
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4171
diff changeset
102 // 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
103 bool octave_initialized = false;
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4171
diff changeset
104
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5717
diff changeset
105 octave_call_stack *octave_call_stack::instance = 0;
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5717
diff changeset
106
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
107 void
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
108 octave_call_stack::create_instance (void)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
109 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
110 instance = new octave_call_stack ();
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
111
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
112 if (instance)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
113 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
114 instance->do_push (0, symbol_table::top_scope (), 0);
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
115
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
116 singleton_cleanup_list::add (cleanup_instance);
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
117 }
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
118 }
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13981
diff changeset
119
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
120 int
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
121 octave_call_stack::do_current_line (void) const
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
122 {
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
123 int retval = -1;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
124
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
125 if (! cs.empty ())
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
126 {
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
127 const call_stack_elt& elt = cs[curr_frame];
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
128 retval = elt.line;
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
129 }
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
130
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
131 return retval;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
132 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
133
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
134 int
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
135 octave_call_stack::do_current_column (void) const
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
136 {
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
137 int retval = -1;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
138
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
139 if (! cs.empty ())
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
140 {
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
141 const call_stack_elt& elt = cs[curr_frame];
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
142 retval = elt.column;
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
143 }
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
144
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
145 return retval;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
146 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
147
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
148 int
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7913
diff changeset
149 octave_call_stack::do_caller_user_code_line (void) const
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
150 {
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
151 int retval = -1;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
152
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
153 const_iterator p = cs.end ();
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
154
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
155 while (p != cs.begin ())
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
156 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
157 const call_stack_elt& elt = *(--p);
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
158
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
159 octave_function *f = elt.fcn;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
160
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
161 if (f && f->is_user_code ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
162 {
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
163 if (elt.line > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
164 {
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
165 retval = elt.line;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
166 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
167 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
168 }
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
169 }
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
170
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
171 return retval;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
172 }
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
173
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
174 int
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7913
diff changeset
175 octave_call_stack::do_caller_user_code_column (void) const
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
176 {
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
177 int retval = -1;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
178
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
179 const_iterator p = cs.end ();
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
180
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
181 while (p != cs.begin ())
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
182 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
183 const call_stack_elt& elt = *(--p);
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
184
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
185 octave_function *f = elt.fcn;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
186
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
187 if (f && f->is_user_code ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
188 {
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
189 if (elt.column)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
190 {
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
191 retval = elt.column;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
192 break;
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 }
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
195 }
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
196
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
197 return retval;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
198 }
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
199
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
200 size_t
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
201 octave_call_stack::do_num_user_code_frames
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
202 (octave_idx_type& curr_user_frame) const
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
203 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
204 size_t retval = 0;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
205
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
206 curr_user_frame = 0;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
207
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
208 // Look for the caller of dbstack.
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
209 size_t frame = cs[curr_frame].prev;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
210
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
211 bool found = false;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
212
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
213 size_t k = cs.size ();
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
214
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
215 for (const_reverse_iterator p = cs.rbegin (); p != cs.rend (); p++)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
216 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
217 octave_function *f = (*p).fcn;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
218
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
219 if (--k == frame)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
220 found = true;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
221
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
222 if (f && f->is_user_code ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
223 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
224 if (! found)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
225 curr_user_frame++;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
226
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
227 retval++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
228 }
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
229 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
230
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
231 // We counted how many user frames were not the one, in reverse.
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
232 // Now set curr_user_frame to be the index in the other direction.
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
233 curr_user_frame = retval - curr_user_frame - 1;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
234
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
235 return retval;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
236 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
237
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7552
diff changeset
238 octave_user_code *
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7913
diff changeset
239 octave_call_stack::do_caller_user_code (size_t nskip) const
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
240 {
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7552
diff changeset
241 octave_user_code *retval = 0;
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
242
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
243 const_iterator p = cs.end ();
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
244
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
245 while (p != cs.begin ())
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
246 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
247 const call_stack_elt& elt = *(--p);
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
248
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
249 octave_function *f = elt.fcn;
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
250
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7552
diff changeset
251 if (f && f->is_user_code ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
252 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
253 if (nskip > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
254 nskip--;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
255 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
256 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
257 retval = dynamic_cast<octave_user_code *> (f);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
258 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
259 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
260 }
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
261 }
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
262
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
263 return retval;
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
264 }
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
265
18267
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
266 bool
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
267 octave_call_stack::do_all_scripts (void) const
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
268 {
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
269 bool retval = true;
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
270
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
271 const_iterator p = cs.end ();
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
272
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
273 while (p != cs.begin ())
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
274 {
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
275 const call_stack_elt& elt = *(--p);
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
276
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
277 octave_function *f = elt.fcn;
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
278
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
279 if (f && ! f->is_user_script ())
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
280 {
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
281 retval = false;
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
282 break;
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
283 }
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
284 }
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
285
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
286 return retval;
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
287 }
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18104
diff changeset
288
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
289 // Use static fields for the best efficiency.
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
290 // NOTE: C++0x will allow these two to be merged into one.
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
291 static const char *bt_fieldnames[] = { "file", "name", "line",
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
292 "column", "scope", "context", 0
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
293 };
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
294 static const octave_fields bt_fields (bt_fieldnames);
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
295
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
296 octave_map
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
297 octave_call_stack::empty_backtrace (void)
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
298 {
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
299 return octave_map (dim_vector (0, 1), bt_fields);
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
300 }
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
301
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
302 octave_map
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
303 octave_call_stack::do_backtrace (size_t nskip,
18440
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18270
diff changeset
304 octave_idx_type& curr_user_frame,
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18270
diff changeset
305 bool print_subfn) const
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
306 {
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
307 size_t user_code_frames = do_num_user_code_frames (curr_user_frame);
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
308
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
309 size_t nframes = nskip <= user_code_frames ? user_code_frames - nskip : 0;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
310
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
311 // Our list is reversed.
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
312 curr_user_frame = nframes - curr_user_frame - 1;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
313
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
314 octave_map retval (dim_vector (nframes, 1), bt_fields);
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
315
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
316 Cell& file = retval.contents (0);
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
317 Cell& name = retval.contents (1);
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
318 Cell& line = retval.contents (2);
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
319 Cell& column = retval.contents (3);
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
320 Cell& scope = retval.contents (4);
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10411
diff changeset
321 Cell& context = retval.contents (5);
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
322
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
323 if (nframes > 0)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
324 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
325 int k = 0;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
326
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
327 for (const_reverse_iterator p = cs.rbegin (); p != cs.rend (); p++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
328 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
329 const call_stack_elt& elt = *p;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
330
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
331 octave_function *f = elt.fcn;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
332
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
333 if (f && f->is_user_code ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
334 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
335 if (nskip > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
336 nskip--;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
337 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
338 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
339 scope(k) = elt.scope;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
340 context(k) = elt.context;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
341
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
342 file(k) = f->fcn_file_name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
343 std::string parent_fcn_name = f->parent_fcn_name ();
18440
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18270
diff changeset
344 if (! print_subfn || parent_fcn_name == std::string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
345 name(k) = f->name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
346 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
347 name(k) = f->parent_fcn_name () + Vfilemarker + f->name ();
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
348
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
349 line(k) = elt.line;
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
350 column(k) = elt.column;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
351
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
352 k++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
353 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
354 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
355 }
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
356 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
357
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
358 return retval;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
359 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
360
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
361 bool
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
362 octave_call_stack::do_goto_frame (size_t n, bool verbose)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
363 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
364 bool retval = false;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
365
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
366 if (n < cs.size ())
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
367 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
368 retval = true;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
369
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
370 curr_frame = n;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
371
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
372 const call_stack_elt& elt = cs[n];
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
373
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
374 symbol_table::set_scope_and_context (elt.scope, elt.context);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
375
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
376 if (verbose)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
377 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
378 octave_function *f = elt.fcn;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
379 std::string nm = f ? f->name () : std::string ("<unknown>");
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
380
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
381 octave_stdout << "stopped in " << nm
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
382 << " at line " << elt.line
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
383 << " column " << elt.column
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
384 << " (" << elt.scope << "[" << elt.context << "])"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
385 << std::endl;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
386 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
387 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
388
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
389 return retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
390 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
391
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
392 bool
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
393 octave_call_stack::do_goto_frame_relative (int nskip, bool verbose)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
394 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
395 bool retval = false;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
396
9483
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
397 int incr = 0;
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
398
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
399 if (nskip < 0)
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
400 incr = -1;
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
401 else if (nskip > 0)
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
402 incr = 1;
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
403
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
404 // Start looking with the caller of dbup/dbdown/keyboard.
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
405 size_t frame = cs[curr_frame].prev;
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
406
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
407 while (true)
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
408 {
9483
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
409 if ((incr < 0 && frame == 0) || (incr > 0 && frame == cs.size () - 1))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
410 break;
9483
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
411
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
412 frame += incr;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
413
9483
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
414 const call_stack_elt& elt = cs[frame];
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
415
9483
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
416 octave_function *f = elt.fcn;
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
417
9990
2b008f1d3794 octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents: 9981
diff changeset
418 if (frame == 0 || (f && f->is_user_code ()))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
419 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
420 if (nskip > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
421 nskip--;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
422 else if (nskip < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
423 nskip++;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
424
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
425 if (nskip == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
426 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
427 curr_frame = frame;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
428 cs[cs.size () - 1].prev = curr_frame;
9483
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
429
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
430 symbol_table::set_scope_and_context (elt.scope, elt.context);
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
431
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
432 if (verbose)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
433 {
9990
2b008f1d3794 octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents: 9981
diff changeset
434 std::ostringstream buf;
2b008f1d3794 octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents: 9981
diff changeset
435
2b008f1d3794 octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents: 9981
diff changeset
436 if (f)
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
437 buf << "stopped in " << f->name ()
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
438 << " at line " << elt.line << std::endl;
9990
2b008f1d3794 octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents: 9981
diff changeset
439 else
2b008f1d3794 octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents: 9981
diff changeset
440 buf << "at top level" << std::endl;
9483
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
441
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
442 octave_stdout << buf.str ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
443 }
9483
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
444
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
445 retval = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
446 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
447 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
448 }
18755
fc43c8017e9b Fix infinite loop when using builtin ("keyboard") (bug #33296).
Rik <rik@octave.org>
parents: 18638
diff changeset
449 else if (incr == 0) // Break out of infinite loop by choosing an incr.
fc43c8017e9b Fix infinite loop when using builtin ("keyboard") (bug #33296).
Rik <rik@octave.org>
parents: 18638
diff changeset
450 incr = -1;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
451
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
452 // There is no need to set scope and context here. That will
9483
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
453 // happen when the dbup/dbdown/keyboard frame is popped and we
25c2e92ee03c correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents: 9452
diff changeset
454 // jump to the new "prev" frame set above.
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
455 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
456
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
457 return retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
458 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
459
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
460 void
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
461 octave_call_stack::do_goto_caller_frame (void)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
462 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
463 size_t frame = curr_frame;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
464
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
465 bool skipped = false;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
466
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
467 while (frame != 0)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
468 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
469 frame = cs[frame].prev;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
470
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
471 const call_stack_elt& elt = cs[frame];
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
472
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
473 octave_function *f = elt.fcn;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
474
18511
83f5f2d41486 correctly handle nested evalin ('caller', ...) calls at top scope (bug #41651)
Michael C. Grant <mcg@cvxr.com>
parents: 18267
diff changeset
475 if (elt.scope == cs[0].scope || (f && f->is_user_code ()))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
476 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
477 if (! skipped)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
478 // We found the current user code frame, so skip it.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
479 skipped = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
480 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
481 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
482 // We found the caller user code frame.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
483 call_stack_elt tmp (elt);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
484 tmp.prev = curr_frame;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
485
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
486 curr_frame = cs.size ();
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
487
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
488 cs.push_back (tmp);
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
489
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
490 symbol_table::set_scope_and_context (tmp.scope, tmp.context);
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
491
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
492 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
493 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
494 }
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
495 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
496 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
497
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
498 void
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
499 octave_call_stack::do_goto_base_frame (void)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
500 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
501 call_stack_elt tmp (cs[0]);
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
502 tmp.prev = curr_frame;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
503
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
504 curr_frame = cs.size ();
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
505
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
506 cs.push_back (tmp);
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
507
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
508 symbol_table::set_scope_and_context (tmp.scope, tmp.context);
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
509 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
510
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
511 void
8013
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
512 octave_call_stack::do_backtrace_error_message (void) const
8011
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
513 {
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
514 if (error_state > 0)
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
515 {
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
516 error_state = -1;
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
517
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
518 error ("called from:");
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
519 }
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
520
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
521 if (! cs.empty ())
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
522 {
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
523 const call_stack_elt& elt = cs.back ();
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
524
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
525 octave_function *fcn = elt.fcn;
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
526
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
527 std::string fcn_name = "?unknown?";
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
528
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
529 if (fcn)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
530 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
531 fcn_name = fcn->fcn_file_name ();
8011
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
532
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
533 if (fcn_name.empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
534 fcn_name = fcn->name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
535 }
8011
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
536
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
537 error (" %s at line %d, column %d",
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16347
diff changeset
538 fcn_name.c_str (), elt.line, elt.column);
8011
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
539 }
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
540 }
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
541
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
542 void
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
543 recover_from_exception (void)
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
544 {
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
545 can_interrupt = true;
4182
4d1d7c51205c [project @ 2002-11-15 20:33:47 by jwe]
jwe
parents: 4181
diff changeset
546 octave_interrupt_immediately = 0;
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
547 octave_interrupt_state = 0;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5102
diff changeset
548 octave_signal_caught = 0;
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7409
diff changeset
549 octave_exception_state = octave_no_exception;
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
550 octave_restore_signal_mask ();
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
551 octave_catch_interrupts ();
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
552 }
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
553
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
554 int
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5169
diff changeset
555 main_loop (void)
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
556 {
2016
6f3428b0d2c7 [project @ 1996-03-22 09:48:38 by jwe]
jwe
parents: 1996
diff changeset
557 octave_save_signal_mask ();
6f3428b0d2c7 [project @ 1996-03-22 09:48:38 by jwe]
jwe
parents: 1996
diff changeset
558
3020
f491f232cb09 [project @ 1997-06-03 22:15:08 by jwe]
jwe
parents: 3014
diff changeset
559 can_interrupt = true;
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
560
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5102
diff changeset
561 octave_signal_hook = octave_signal_handler;
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9990
diff changeset
562 octave_interrupt_hook = 0;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9990
diff changeset
563 octave_bad_alloc_hook = 0;
4429
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4399
diff changeset
564
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2552
diff changeset
565 octave_catch_interrupts ();
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
566
4172
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4171
diff changeset
567 octave_initialized = true;
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4171
diff changeset
568
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
569 // The big loop.
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
570
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
571 octave_lexer *lxr = ((interactive || forced_interactive)
bef822a80ffb if not interactive, bypass readline and read stdin as a file (bug #38520)
John W. Eaton <jwe@octave.org>
parents: 16317
diff changeset
572 ? 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
573 : 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
574
bef822a80ffb if not interactive, bypass readline and read stdin as a file (bug #38520)
John W. Eaton <jwe@octave.org>
parents: 16317
diff changeset
575 octave_parser parser (*lxr);
16151
e309eb7940be parser tweaks
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
576
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4130
diff changeset
577 int retval = 0;
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
578 do
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
579 {
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4173
diff changeset
580 try
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
581 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
582 reset_error_handler ();
4318
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4254
diff changeset
583
16288
fe3b9a51e625 rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents: 16287
diff changeset
584 parser.reset ();
2620
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2614
diff changeset
585
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
586 if (symbol_table::at_top_level ())
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
587 tree_evaluator::reset_debug_state ();
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
588
16288
fe3b9a51e625 rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents: 16287
diff changeset
589 retval = parser.run ();
2620
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2614
diff changeset
590
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
591 if (retval == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
592 {
16288
fe3b9a51e625 rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents: 16287
diff changeset
593 if (parser.stmt_list)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
594 {
16288
fe3b9a51e625 rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents: 16287
diff changeset
595 parser.stmt_list->accept (*current_evaluator);
3883
69b6bd271277 [project @ 2002-04-02 21:05:10 by jwe]
jwe
parents: 3881
diff changeset
596
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
597 octave_quit ();
4171
04694e5b4239 [project @ 2002-11-12 20:27:24 by jwe]
jwe
parents: 4155
diff changeset
598
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
599 if (! (interactive || forced_interactive))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
600 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
601 bool quit = (tree_return_command::returning
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
602 || tree_break_command::breaking);
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4130
diff changeset
603
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
604 if (tree_return_command::returning)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
605 tree_return_command::returning = 0;
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4130
diff changeset
606
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
607 if (tree_break_command::breaking)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
608 tree_break_command::breaking--;
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4130
diff changeset
609
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
610 if (quit)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
611 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
612 }
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4130
diff changeset
613
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
614 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
615 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
616 if (! (interactive || forced_interactive))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
617 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
618 // We should exit with a non-zero status.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
619 retval = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
620 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
621 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
622 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
623 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
624 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
625 if (octave_completion_matches_called)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
626 octave_completion_matches_called = false;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
627 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
628 command_editor::increment_current_command_number ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
629 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
630 }
16288
fe3b9a51e625 rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents: 16287
diff changeset
631 else if (parser.lexer.end_of_input)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
632 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
633 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
634 }
4182
4d1d7c51205c [project @ 2002-11-15 20:33:47 by jwe]
jwe
parents: 4181
diff changeset
635 catch (octave_interrupt_exception)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
636 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
637 recover_from_exception ();
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
638 octave_stdout << "\n";
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
639 if (quitting_gracefully)
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
640 return exit_status;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
641 }
8704
236ff50db90f load-path.cc: catch execution exception in getcwd
John W. Eaton <jwe@octave.org>
parents: 8669
diff changeset
642 catch (octave_execution_exception)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
643 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
644 recover_from_exception ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
645 std::cerr << "error: unhandled execution exception -- trying to return to prompt"
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
646 << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
647 }
4181
dd2abf428f5d [project @ 2002-11-15 18:33:41 by jwe]
jwe
parents: 4180
diff changeset
648 catch (std::bad_alloc)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
649 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
650 recover_from_exception ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
651 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
652 << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
653 }
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
654 }
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
655 while (retval == 0);
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
656
18638
4ccd2b473f84 Print newline after closing interpreter with EOF (bug #41513).
Vaibhav Gupta <vaibhav.gupta@students.iiit.ac.in>
parents: 18515
diff changeset
657 octave_stdout << "\n";
4ccd2b473f84 Print newline after closing interpreter with EOF (bug #41513).
Vaibhav Gupta <vaibhav.gupta@students.iiit.ac.in>
parents: 18515
diff changeset
658
16987
aabe12e5fdc1 Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents: 16892
diff changeset
659 if (retval == EOF)
aabe12e5fdc1 Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents: 16892
diff changeset
660 retval = 0;
aabe12e5fdc1 Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents: 16892
diff changeset
661
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
662 return retval;
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
663 }
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
664
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
665 // Fix up things before exiting.
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
666
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
667 static std::list<std::string> octave_atexit_functions;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
668
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
669 static void
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
670 do_octave_atexit (void)
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
671 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
672 static bool deja_vu = false;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
673
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
674 OCTAVE_SAFE_CALL (remove_input_event_hook_functions, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
675
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
676 while (! octave_atexit_functions.empty ())
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
677 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
678 std::string fcn = octave_atexit_functions.front ();
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
679
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
680 octave_atexit_functions.pop_front ();
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
681
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
682 OCTAVE_SAFE_CALL (reset_error_handler, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
683
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
684 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
685
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
686 OCTAVE_SAFE_CALL (flush_octave_stdout, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
687 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
688
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
689 if (! deja_vu)
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
690 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
691 deja_vu = true;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
692
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
693 // Process pending events and disasble octave_link event
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
694 // processing with this call.
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
695
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
696 octave_link::process_events (true);
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
697
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
698 // 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
699 // 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
700 // called.
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
701 OCTAVE_SAFE_CALL (clear_mex_functions, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
702
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
703 OCTAVE_SAFE_CALL (command_editor::restore_terminal_state, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
704
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
705 // 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
706 OCTAVE_SAFE_CALL (raw_mode, (0));
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
707
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
708 OCTAVE_SAFE_CALL (octave_history_write_timestamp, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
709
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
710 if (! command_history::ignoring_entries ())
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
711 OCTAVE_SAFE_CALL (command_history::clean_up_and_save, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
712
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
713 OCTAVE_SAFE_CALL (gh_manager::close_all_figures, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
714
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
715 OCTAVE_SAFE_CALL (gtk_manager::unload_all_toolkits, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
716
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
717 OCTAVE_SAFE_CALL (close_files, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
718
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
719 OCTAVE_SAFE_CALL (cleanup_tmp_files, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
720
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
721 OCTAVE_SAFE_CALL (symbol_table::cleanup, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
722
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
723 OCTAVE_SAFE_CALL (sysdep_cleanup, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
724
17755
9c03b071fd7b avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
725 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
726
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
727 OCTAVE_SAFE_CALL (flush_octave_stdout, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
728
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
729 if (! quitting_gracefully && (interactive || forced_interactive))
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
730 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
731 octave_stdout << "\n";
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
732
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
733 // 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
734 // flush_octave_stdout above.
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
735
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
736 OCTAVE_SAFE_CALL (flush_octave_stdout, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
737 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
738
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
739 // 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
740 // problems with registering/unregistering types worked out. For
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
741 // 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
742 // 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
743 // 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
744 // 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
745 // 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
746 // .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
747 // is unloaded.
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
748 //
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
749 // OCTAVE_SAFE_CALL (singleton_cleanup_list::cleanup, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
750
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
751 OCTAVE_SAFE_CALL (octave_chunk_buffer::clear, ());
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
752 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
753 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
754
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
755 void
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
756 clean_up_and_exit (int retval, bool safe_to_return)
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3147
diff changeset
757 {
3216
60a89a69a70a [project @ 1998-11-11 20:47:03 by jwe]
jwe
parents: 3215
diff changeset
758 do_octave_atexit ();
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
759
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
760 if (octave_link::exit (retval))
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
761 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
762 if (safe_to_return)
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
763 return;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
764 else
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
765 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
766 // 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
767 // 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
768 // so it might not be safe to return.
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
769
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
770 // 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
771 // 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
772 // 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
773 // day...
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
774
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
775 gnulib::sleep (86400);
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
776 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
777 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
778 else
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
779 {
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
780 if (octave_exit)
16987
aabe12e5fdc1 Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents: 16892
diff changeset
781 (*octave_exit) (retval);
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
782 }
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
783 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
784
11023
cb62c7401ea2 toplev.cc (Fquit): allow any number of output paramters
John W. Eaton <jwe@octave.org>
parents: 10890
diff changeset
785 DEFUN (quit, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
786 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10839
diff changeset
787 @deftypefn {Built-in Function} {} exit (@var{status})\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3325
diff changeset
788 @deftypefnx {Built-in Function} {} quit (@var{status})\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3325
diff changeset
789 Exit the current Octave session. If the optional integer value\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3325
diff changeset
790 @var{status} is supplied, pass that value to the operating system as the\n\
6615
687ae48b2253 [project @ 2007-05-13 06:24:57 by jwe]
jwe
parents: 6556
diff changeset
791 Octave's exit status. The default value is zero.\n\
3333
15cddaacbc2d [project @ 1999-11-03 19:53:59 by jwe]
jwe
parents: 3332
diff changeset
792 @end deftypefn")
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
793 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 2084
diff changeset
794 octave_value_list retval;
2068
18365b6332a8 [project @ 1996-04-17 23:37:35 by jwe]
jwe
parents: 2016
diff changeset
795
9255
1c2d2c9f4a8d don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents: 9217
diff changeset
796 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
797 error ("quit: not supported in embedded mode");
11023
cb62c7401ea2 toplev.cc (Fquit): allow any number of output paramters
John W. Eaton <jwe@octave.org>
parents: 10890
diff changeset
798 else
2068
18365b6332a8 [project @ 1996-04-17 23:37:35 by jwe]
jwe
parents: 2016
diff changeset
799 {
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 3162
diff changeset
800 if (args.length () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
801 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
802 int tmp = args(0).nint_value ();
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
803
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
804 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
805 exit_status = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
806 }
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 3162
diff changeset
807
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
808 if (! error_state)
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
809 {
13981
5f8bc2f145f5 clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents: 13973
diff changeset
810 // Instead of simply calling exit, we simulate an interrupt
5f8bc2f145f5 clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents: 13973
diff changeset
811 // with a request to exit cleanly so that no matter where the
5f8bc2f145f5 clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents: 13973
diff changeset
812 // call to quit occurs, we will run the unwind_protect stack,
5f8bc2f145f5 clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents: 13973
diff changeset
813 // clear the OCTAVE_LOCAL_BUFFER allocations, etc. before
5f8bc2f145f5 clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents: 13973
diff changeset
814 // exiting.
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
815
13981
5f8bc2f145f5 clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents: 13973
diff changeset
816 quitting_gracefully = true;
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
817
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
818 octave_interrupt_state = -1;
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
819
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
820 octave_throw_interrupt_exception ();
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
821 }
2068
18365b6332a8 [project @ 1996-04-17 23:37:35 by jwe]
jwe
parents: 2016
diff changeset
822 }
18365b6332a8 [project @ 1996-04-17 23:37:35 by jwe]
jwe
parents: 2016
diff changeset
823
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
824 return retval;
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
825 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
826
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
827 DEFALIAS (exit, quit);
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
828
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1907
diff changeset
829 DEFUN (warranty, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
830 "-*- texinfo -*-\n\
3446
5ee5afb3981a [project @ 2000-01-17 09:42:43 by jwe]
jwe
parents: 3402
diff changeset
831 @deftypefn {Built-in Function} {} warranty ()\n\
5ee5afb3981a [project @ 2000-01-17 09:42:43 by jwe]
jwe
parents: 3402
diff changeset
832 Describe the conditions for copying and distributing Octave.\n\
5ee5afb3981a [project @ 2000-01-17 09:42:43 by jwe]
jwe
parents: 3402
diff changeset
833 @end deftypefn")
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
834 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 2084
diff changeset
835 octave_value_list retval;
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
836
17510
7542f4496974 eliminate some macros in version.h
John W. Eaton <jwe@octave.org>
parents: 17281
diff changeset
837 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
838 \n\
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
839 GNU Octave 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
840 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
841 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
842 (at your option) any later version.\n\
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
843 \n\
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
844 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
845 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
846 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
847 GNU General Public License for more details.\n\
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
848 \n\
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
849 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
850 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
851 \n";
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
852
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
853 return retval;
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
854 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
855
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
856 // Execute a shell command.
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
857
6316
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
858 static int
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
859 wait_for_input (int fid)
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
860 {
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
861 int retval = -1;
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
862
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
863 #if defined (HAVE_SELECT)
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
864 if (fid >= 0)
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
865 {
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
866 fd_set set;
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
867
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
868 FD_ZERO (&set);
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
869 FD_SET (fid, &set);
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
870
10411
479cc8a0a846 use gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10331
diff changeset
871 retval = gnulib::select (FD_SETSIZE, &set, 0, 0, 0);
6316
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
872 }
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
873 #else
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
874 retval = 1;
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
875 #endif
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
876
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
877 return retval;
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
878 }
a3a2580435c2 [project @ 2007-02-16 07:23:49 by jwe]
jwe
parents: 6311
diff changeset
879
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 2084
diff changeset
880 static octave_value_list
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
881 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
882 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 2084
diff changeset
883 octave_value_list retval;
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
884 unwind_protect frame;
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
885
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
886 iprocstream *cmd = new iprocstream (cmd_str.c_str ());
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
887
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
888 frame.add_delete (cmd);
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
889 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
890
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
891 if (*cmd)
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
892 {
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
893 int fid = cmd->file_number ();
2095
36903d507b0e [project @ 1996-04-28 09:00:07 by jwe]
jwe
parents: 2086
diff changeset
894
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
895 std::ostringstream output_buf;
4494
93ad80b6eef6 [project @ 2003-09-03 20:27:00 by jwe]
jwe
parents: 4489
diff changeset
896
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
897 char ch;
3147
894d516b4a00 [project @ 1998-02-06 06:00:08 by jwe]
jwe
parents: 3141
diff changeset
898
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
899 for (;;)
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
900 {
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
901 if (cmd->get (ch))
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
902 output_buf.put (ch);
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
903 else
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
904 {
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
905 if (! cmd->eof () && errno == EAGAIN)
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
906 {
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
907 cmd->clear ();
3147
894d516b4a00 [project @ 1998-02-06 06:00:08 by jwe]
jwe
parents: 3141
diff changeset
908
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
909 if (wait_for_input (fid) != 1)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
910 break;
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
911 }
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
912 else
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
913 break;
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
914 }
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
915 }
3147
894d516b4a00 [project @ 1998-02-06 06:00:08 by jwe]
jwe
parents: 3141
diff changeset
916
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
917 int cmd_status = cmd->close ();
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
918
15221
a83b7b2f95ee avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
919 if (octave_wait::ifexited (cmd_status))
a83b7b2f95ee avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
920 cmd_status = octave_wait::exitstatus (cmd_status);
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
921 else
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
922 cmd_status = 127;
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
923
14018
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
924 retval(1) = output_buf.str ();
10212
56f7734f5448 fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents: 10186
diff changeset
925 retval(0) = cmd_status;
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
926 }
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
927 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14156
diff changeset
928 error ("unable to start subprocess for '%s'", cmd_str.c_str ());
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
929
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
930 return retval;
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
931 }
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
932
5285
fe5ee25a5e6c [project @ 2005-04-19 15:02:49 by jwe]
jwe
parents: 5275
diff changeset
933 enum system_exec_type { et_sync, et_async };
fe5ee25a5e6c [project @ 2005-04-19 15:02:49 by jwe]
jwe
parents: 5275
diff changeset
934
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1907
diff changeset
935 DEFUN (system, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
936 "-*- texinfo -*-\n\
14018
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
937 @deftypefn {Built-in Function} {} system (\"@var{string}\")\n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
938 @deftypefnx {Built-in Function} {} system (\"@var{string}\", @var{return_output})\n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
939 @deftypefnx {Built-in Function} {} system (\"@var{string}\", @var{return_output}, @var{type})\n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
940 @deftypefnx {Built-in Function} {[@var{status}, @var{output}] =} system (@dots{})\n\
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
941 Execute a shell command specified by @var{string}.\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16987
diff changeset
942 If the optional argument @var{type} is @qcode{\"async\"}, the process\n\
14018
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
943 is started in the background and the process ID of the child process\n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
944 is returned immediately. Otherwise, the child process is started and\n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
945 Octave waits until it exits. If the @var{type} argument is omitted, it\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16987
diff changeset
946 defaults to the value @qcode{\"sync\"}.\n\
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
947 \n\
14018
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
948 If @var{system} is called with one or more output arguments, or if the\n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
949 optional argument @var{return_output} is true and the subprocess is started\n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
950 synchronously, then the output from the command is returned as a variable. \n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
951 Otherwise, if the subprocess is executed synchronously, its output is sent\n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
952 to the standard output. To send the output of a command executed with\n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
953 @code{system} through the pager, use a command like\n\
2321
dac9933079e6 [project @ 1996-07-15 21:08:05 by jwe]
jwe
parents: 2299
diff changeset
954 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
955 @example\n\
14018
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
956 @group\n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
957 [output, text] = system (\"cmd\");\n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
958 disp (text);\n\
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
959 @end group\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
960 @end example\n\
2321
dac9933079e6 [project @ 1996-07-15 21:08:05 by jwe]
jwe
parents: 2299
diff changeset
961 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
962 @noindent\n\
2321
dac9933079e6 [project @ 1996-07-15 21:08:05 by jwe]
jwe
parents: 2299
diff changeset
963 or\n\
dac9933079e6 [project @ 1996-07-15 21:08:05 by jwe]
jwe
parents: 2299
diff changeset
964 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
965 @example\n\
14018
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
966 printf (\"%s\\n\", nthargout (2, \"system\", \"cmd\"));\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
967 @end example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
968 \n\
5659
960f4b9a26af [project @ 2006-03-10 15:35:20 by jwe]
jwe
parents: 5655
diff changeset
969 The @code{system} function can return two values. The first is the\n\
960f4b9a26af [project @ 2006-03-10 15:35:20 by jwe]
jwe
parents: 5655
diff changeset
970 exit status of the command and the second is any output from the\n\
960f4b9a26af [project @ 2006-03-10 15:35:20 by jwe]
jwe
parents: 5655
diff changeset
971 command that was written to the standard output stream. For example,\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
972 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
973 @example\n\
5717
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5672
diff changeset
974 [status, output] = system (\"echo foo; exit 2\");\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
975 @end example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
976 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
977 @noindent\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
978 will set the variable @code{output} to the string @samp{foo}, and the\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
979 variable @code{status} to the integer @samp{2}.\n\
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
980 \n\
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
981 For commands run asynchronously, @var{status} is the process id of the\n\
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
982 command shell that is started to run the command.\n\
14018
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
983 @seealso{unix, dos}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
984 @end deftypefn")
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
985 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 2084
diff changeset
986 octave_value_list retval;
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
987
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9990
diff changeset
988 unwind_protect frame;
3834
414e694c9e6a [project @ 2001-05-17 13:45:41 by jwe]
jwe
parents: 3822
diff changeset
989
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
990 int nargin = args.length ();
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
991
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
992 if (nargin > 0 && nargin < 4)
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
993 {
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
994 bool return_output = (nargin == 1 && nargout > 1);
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
995
5285
fe5ee25a5e6c [project @ 2005-04-19 15:02:49 by jwe]
jwe
parents: 5275
diff changeset
996 system_exec_type type = et_sync;
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
997
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
998 if (nargin == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
999 {
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
1000 std::string type_str = args(2).string_value ();
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
1001
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
1002 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1003 {
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
1004 if (type_str == "sync")
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
1005 type = et_sync;
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
1006 else if (type_str == "async")
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
1007 type = et_async;
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
1008 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1009 {
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12208
diff changeset
1010 error ("system: TYPE must be \"sync\" or \"async\"");
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
1011 return retval;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1012 }
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
1013 }
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
1014 else
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
1015 {
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12208
diff changeset
1016 error ("system: TYPE must be a character 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
1017 return retval;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1018 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1019 }
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
1020
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
1021 if (nargin > 1)
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
1022 {
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
1023 return_output = args(1).is_true ();
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
1024
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
1025 if (error_state)
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
1026 {
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12208
diff changeset
1027 error ("system: RETURN_OUTPUT must be boolean value true or false");
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
1028 return retval;
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
1029 }
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
1030 }
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
1031
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
1032 if (return_output && type == et_async)
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
1033 {
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
1034 error ("system: can't return output from commands run asynchronously");
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
1035 return retval;
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
1036 }
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
1037
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
1038 std::string cmd_str = args(0).string_value ();
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1039
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
1040 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1041 {
7104
b26d0cd10a42 [project @ 2007-11-06 17:18:41 by jwe]
jwe
parents: 7017
diff changeset
1042 #if defined (__WIN32__) && ! defined (__CYGWIN__)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1043 // Work around weird double-quote handling on Windows systems.
7104
b26d0cd10a42 [project @ 2007-11-06 17:18:41 by jwe]
jwe
parents: 7017
diff changeset
1044 if (type == et_sync)
b26d0cd10a42 [project @ 2007-11-06 17:18:41 by jwe]
jwe
parents: 7017
diff changeset
1045 cmd_str = "\"" + cmd_str + "\"";
b26d0cd10a42 [project @ 2007-11-06 17:18:41 by jwe]
jwe
parents: 7017
diff changeset
1046 #endif
b26d0cd10a42 [project @ 2007-11-06 17:18:41 by jwe]
jwe
parents: 7017
diff changeset
1047
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1048 if (type == et_async)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1049 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1050 // FIXME: maybe this should go in sysdep.cc?
4086
ddc722b38e87 [project @ 2002-10-03 19:08:45 by jwe]
jwe
parents: 4084
diff changeset
1051 #ifdef HAVE_FORK
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1052 pid_t pid = fork ();
2083
679d7262a525 [project @ 1996-04-25 04:29:27 by jwe]
jwe
parents: 2078
diff changeset
1053
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1054 if (pid < 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1055 error ("system: fork failed -- can't create child process");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1056 else if (pid == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1057 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1058 // FIXME: should probably replace this
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1059 // call with something portable.
3273
eb27ea9b7ff8 [project @ 1999-10-12 02:22:25 by jwe]
jwe
parents: 3258
diff changeset
1060
15756
ea1a1fb00744 Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents: 15596
diff changeset
1061 execl (SHELL_PATH, "sh", "-c", cmd_str.c_str (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1062 static_cast<void *> (0));
3273
eb27ea9b7ff8 [project @ 1999-10-12 02:22:25 by jwe]
jwe
parents: 3258
diff changeset
1063
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1064 panic_impossible ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1065 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1066 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1067 retval(0) = pid;
6222
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1068 #elif defined (__WIN32__)
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1069 STARTUPINFO si;
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1070 PROCESS_INFORMATION pi;
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1071 ZeroMemory (&si, sizeof (si));
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1072 ZeroMemory (&pi, sizeof (pi));
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14429
diff changeset
1073 OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length ()+1);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1074 strcpy (xcmd_str, cmd_str.c_str ());
6222
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1075
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1076 if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi))
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1077 error ("system: CreateProcess failed -- can't create child process");
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1078 else
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1079 {
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1080 retval(0) = pi.dwProcessId;
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1081 CloseHandle (pi.hProcess);
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1082 CloseHandle (pi.hThread);
07d967f75dba [project @ 2007-01-03 20:15:15 by jwe]
jwe
parents: 6124
diff changeset
1083 }
4086
ddc722b38e87 [project @ 2002-10-03 19:08:45 by jwe]
jwe
parents: 4084
diff changeset
1084 #else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1085 error ("asynchronous system calls are not supported");
4086
ddc722b38e87 [project @ 2002-10-03 19:08:45 by jwe]
jwe
parents: 4084
diff changeset
1086 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1087 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1088 else if (return_output)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1089 retval = run_command_and_return_output (cmd_str);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1090 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1091 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1092 int status = system (cmd_str.c_str ());
2321
dac9933079e6 [project @ 1996-07-15 21:08:05 by jwe]
jwe
parents: 2299
diff changeset
1093
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1094 // The value in status is as returned by waitpid. If
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1095 // the process exited normally, extract the actual exit
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1096 // status of the command. Otherwise, return 127 as a
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1097 // failure code.
2321
dac9933079e6 [project @ 1996-07-15 21:08:05 by jwe]
jwe
parents: 2299
diff changeset
1098
15221
a83b7b2f95ee avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1099 if (octave_wait::ifexited (status))
a83b7b2f95ee avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1100 status = octave_wait::exitstatus (status);
2321
dac9933079e6 [project @ 1996-07-15 21:08:05 by jwe]
jwe
parents: 2299
diff changeset
1101
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1102 retval(0) = status;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1103 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1104 }
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
1105 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12208
diff changeset
1106 error ("system: expecting string as first argument");
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1107 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1108 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5814
diff changeset
1109 print_usage ();
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1110
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1111 return retval;
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1112 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1113
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1114 /*
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1115 %!test
14018
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
1116 %! cmd = ls_command ();
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1117 %! [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
1118 %! assert (status, 0);
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1119 %! assert (ischar (output));
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1120 %! assert (! isempty (output));
14018
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
1121
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
1122 %!error system ()
5d5685216876 Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents: 14016
diff changeset
1123 %!error system (1, 2, 3)
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1124 */
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1125
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1126 void
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1127 octave_add_atexit_function (const std::string& fname)
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1128 {
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1129 octave_atexit_functions.push_front (fname);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1130 }
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1131
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1132 bool
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1133 octave_remove_atexit_function (const std::string& fname)
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1134 {
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1135 bool found = false;
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1136
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1137 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
1138 p != octave_atexit_functions.end (); p++)
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1139 {
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1140 if (*p == fname)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1141 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1142 octave_atexit_functions.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1143 found = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1144 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1145 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1146 }
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1147
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1148 return found;
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1149 }
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1150
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7361
diff changeset
1151
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1152 DEFUN (atexit, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1153 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10839
diff changeset
1154 @deftypefn {Built-in Function} {} atexit (@var{fcn})\n\
9133
c0cef1436788 Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents: 9079
diff changeset
1155 @deftypefnx {Built-in Function} {} atexit (@var{fcn}, @var{flag})\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3325
diff changeset
1156 Register a function to be called when Octave exits. For example,\n\
2077
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1157 \n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3325
diff changeset
1158 @example\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3325
diff changeset
1159 @group\n\
9035
57649dcecb55 Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
1160 function last_words ()\n\
6620
bf4bdc21dc8d [project @ 2007-05-14 17:35:46 by jwe]
jwe
parents: 6615
diff changeset
1161 disp (\"Bye bye\");\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3325
diff changeset
1162 endfunction\n\
9035
57649dcecb55 Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
1163 atexit (\"last_words\");\n\
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3325
diff changeset
1164 @end group\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3325
diff changeset
1165 @end example\n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3325
diff changeset
1166 \n\
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 3325
diff changeset
1167 @noindent\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16987
diff changeset
1168 will print the message @qcode{\"Bye bye\"} when Octave exits.\n\
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1169 \n\
9133
c0cef1436788 Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents: 9079
diff changeset
1170 The additional argument @var{flag} will register or unregister\n\
c0cef1436788 Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents: 9079
diff changeset
1171 @var{fcn} from the list of functions to be called when Octave\n\
c0cef1436788 Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents: 9079
diff changeset
1172 exits. If @var{flag} is true, the function is registered, and if\n\
c0cef1436788 Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents: 9079
diff changeset
1173 @var{flag} is false, it is unregistered. For example,\n\
c0cef1436788 Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents: 9079
diff changeset
1174 after registering the function @code{last_words} above,\n\
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1175 \n\
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1176 @example\n\
9035
57649dcecb55 Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
1177 atexit (\"last_words\", false);\n\
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1178 @end example\n\
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1179 \n\
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1180 @noindent\n\
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1181 will remove the function from the list and Octave will not call\n\
9133
c0cef1436788 Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents: 9079
diff changeset
1182 @code{last_words} when it exits.\n\
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1183 \n\
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6789
diff changeset
1184 Note that @code{atexit} only removes the first occurrence of a function\n\
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1185 from the list, so if a function was placed in the list multiple\n\
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1186 times with @code{atexit}, it must also be removed from the list\n\
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1187 multiple times.\n\
3333
15cddaacbc2d [project @ 1999-11-03 19:53:59 by jwe]
jwe
parents: 3332
diff changeset
1188 @end deftypefn")
2077
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1189 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 2084
diff changeset
1190 octave_value_list retval;
2077
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1191
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1192 int nargin = args.length ();
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1193
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1194 if (nargin == 1 || nargin == 2)
2077
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1195 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
1196 std::string arg = args(0).string_value ();
2077
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1197
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1198 if (! error_state)
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1199 {
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1200 bool add_mode = true;
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1201
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1202 if (nargin == 2)
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1203 {
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1204 add_mode = args(1).bool_value ();
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1205
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1206 if (error_state)
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12208
diff changeset
1207 error ("atexit: FLAG argument must be a logical value");
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1208 }
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1209
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1210 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1211 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1212 if (add_mode)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1213 octave_add_atexit_function (arg);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1214 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1215 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1216 bool found = octave_remove_atexit_function (arg);
6680
cd39d4a0b671 [project @ 2007-05-31 20:23:45 by jwe]
jwe
parents: 6676
diff changeset
1217
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1218 if (nargout > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1219 retval(0) = found;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1220 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1221 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1222 }
2077
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1223 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12208
diff changeset
1224 error ("atexit: FCN argument must be a string");
2077
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1225 }
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1226 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5814
diff changeset
1227 print_usage ();
2077
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1228
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1229 return retval;
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1230 }
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 2068
diff changeset
1231
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1232 DEFUN (octave_config_info, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1233 "-*- texinfo -*-\n\
12208
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12195
diff changeset
1234 @deftypefn {Built-in Function} {} octave_config_info ()\n\
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12195
diff changeset
1235 @deftypefnx {Built-in Function} {} octave_config_info (@var{option})\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
1236 Return a structure containing configuration and installation\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
1237 information for Octave.\n\
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1238 \n\
12208
9611014e7cf1 Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12195
diff changeset
1239 If @var{option} is a string, return the configuration information for the\n\
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1240 specified option.\n\
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1241 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3273
diff changeset
1242 @end deftypefn")
2162
a940dcdfe9de [project @ 1996-05-13 10:31:51 by jwe]
jwe
parents: 2145
diff changeset
1243 {
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1244 octave_value retval;
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1245
4128
919b2f6573ee [project @ 2002-10-25 20:36:14 by jwe]
jwe
parents: 4111
diff changeset
1246 #if defined (ENABLE_DYNAMIC_LINKING)
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1247 bool octave_supports_dynamic_linking = true;
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1248 #else
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1249 bool octave_supports_dynamic_linking = false;
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1250 #endif
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1251
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1252 static bool initialized = false;
11066
e678346a47d9 toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents: 11023
diff changeset
1253 static octave_scalar_map m;
2162
a940dcdfe9de [project @ 1996-05-13 10:31:51 by jwe]
jwe
parents: 2145
diff changeset
1254
6274
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
1255 struct conf_info_struct
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
1256 {
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
1257 bool subst_home;
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
1258 const char *key;
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
1259 const char *val;
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
1260 };
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
1261
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
1262 static const conf_info_struct conf_info[] =
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1263 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1264 { false, "ALL_CFLAGS", OCTAVE_CONF_ALL_CFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1265 { false, "ALL_CXXFLAGS", OCTAVE_CONF_ALL_CXXFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1266 { false, "ALL_FFLAGS", OCTAVE_CONF_ALL_FFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1267 { false, "ALL_LDFLAGS", OCTAVE_CONF_ALL_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1268 { false, "AMD_CPPFLAGS", OCTAVE_CONF_AMD_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1269 { false, "AMD_LDFLAGS", OCTAVE_CONF_AMD_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1270 { false, "AMD_LIBS", OCTAVE_CONF_AMD_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1271 { false, "AR", OCTAVE_CONF_AR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1272 { false, "ARFLAGS", OCTAVE_CONF_ARFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1273 { false, "ARPACK_CPPFLAGS", OCTAVE_CONF_ARPACK_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1274 { false, "ARPACK_LDFLAGS", OCTAVE_CONF_ARPACK_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1275 { false, "ARPACK_LIBS", OCTAVE_CONF_ARPACK_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1276 { false, "BLAS_LIBS", OCTAVE_CONF_BLAS_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1277 { false, "CAMD_CPPFLAGS", OCTAVE_CONF_CAMD_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1278 { false, "CAMD_LDFLAGS", OCTAVE_CONF_CAMD_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1279 { false, "CAMD_LIBS", OCTAVE_CONF_CAMD_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1280 { false, "CARBON_LIBS", OCTAVE_CONF_CARBON_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1281 { false, "CC", OCTAVE_CONF_CC },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1282 { false, "CCOLAMD_CPPFLAGS", OCTAVE_CONF_CCOLAMD_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1283 { false, "CCOLAMD_LDFLAGS", OCTAVE_CONF_CCOLAMD_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1284 { false, "CCOLAMD_LIBS", OCTAVE_CONF_CCOLAMD_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1285 { false, "CFLAGS", OCTAVE_CONF_CFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1286 { false, "CHOLMOD_CPPFLAGS", OCTAVE_CONF_CHOLMOD_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1287 { false, "CHOLMOD_LDFLAGS", OCTAVE_CONF_CHOLMOD_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1288 { false, "CHOLMOD_LIBS", OCTAVE_CONF_CHOLMOD_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1289 { false, "COLAMD_CPPFLAGS", OCTAVE_CONF_COLAMD_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1290 { false, "COLAMD_LDFLAGS", OCTAVE_CONF_COLAMD_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1291 { false, "COLAMD_LIBS", OCTAVE_CONF_COLAMD_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1292 { false, "CPICFLAG", OCTAVE_CONF_CPICFLAG },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1293 { false, "CPPFLAGS", OCTAVE_CONF_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1294 { false, "CURL_CPPFLAGS", OCTAVE_CONF_CURL_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1295 { false, "CURL_LDFLAGS", OCTAVE_CONF_CURL_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1296 { false, "CURL_LIBS", OCTAVE_CONF_CURL_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1297 { false, "CXSPARSE_CPPFLAGS", OCTAVE_CONF_CXSPARSE_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1298 { false, "CXSPARSE_LDFLAGS", OCTAVE_CONF_CXSPARSE_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1299 { false, "CXSPARSE_LIBS", OCTAVE_CONF_CXSPARSE_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1300 { false, "CXX", OCTAVE_CONF_CXX },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1301 { false, "CXXCPP", OCTAVE_CONF_CXXCPP },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1302 { false, "CXXFLAGS", OCTAVE_CONF_CXXFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1303 { false, "CXXPICFLAG", OCTAVE_CONF_CXXPICFLAG },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1304 { false, "DEFAULT_PAGER", OCTAVE_DEFAULT_PAGER },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1305 { false, "DEFS", OCTAVE_CONF_DEFS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1306 { false, "DL_LD", OCTAVE_CONF_DL_LD },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1307 { false, "DL_LDFLAGS", OCTAVE_CONF_DL_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1308 { false, "DL_LIBS", OCTAVE_CONF_DL_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1309 { false, "GCC_VERSION", OCTAVE_CONF_GCC_VERSION },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1310 { false, "GXX_VERSION", OCTAVE_CONF_GXX_VERSION },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1311 { false, "ENABLE_DYNAMIC_LINKING", OCTAVE_CONF_ENABLE_DYNAMIC_LINKING },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1312 { false, "EXEEXT", OCTAVE_CONF_EXEEXT },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1313 { false, "F77", OCTAVE_CONF_F77 },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1314 { false, "F77_FLOAT_STORE_FLAG", OCTAVE_CONF_F77_FLOAT_STORE_FLAG },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1315 { false, "F77_INTEGER_8_FLAG", OCTAVE_CONF_F77_INTEGER_8_FLAG },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1316 { false, "FC", OCTAVE_CONF_FC },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1317 { false, "FFLAGS", OCTAVE_CONF_FFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1318 { false, "FFTW3_CPPFLAGS", OCTAVE_CONF_FFTW3_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1319 { false, "FFTW3_LDFLAGS", OCTAVE_CONF_FFTW3_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1320 { false, "FFTW3_LIBS", OCTAVE_CONF_FFTW3_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1321 { false, "FFTW3F_CPPFLAGS", OCTAVE_CONF_FFTW3F_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1322 { false, "FFTW3F_LDFLAGS", OCTAVE_CONF_FFTW3F_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1323 { false, "FFTW3F_LIBS", OCTAVE_CONF_FFTW3F_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1324 { false, "FLIBS", OCTAVE_CONF_FLIBS },
17816
e6317049225b build: Remove FreeType and Fontconfig CPPFLAGS from XTRA_CXXFLAGS.
Rik <rik@octave.org>
parents: 17787
diff changeset
1325 { false, "FONTCONFIG_CFLAGS", OCTAVE_CONF_FONTCONFIG_CFLAGS },
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1326 { false, "FPICFLAG", OCTAVE_CONF_FPICFLAG },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1327 { false, "FT2_CFLAGS", OCTAVE_CONF_FT2_CFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1328 { false, "FT2_LIBS", OCTAVE_CONF_FT2_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1329 { false, "GLPK_CPPFLAGS", OCTAVE_CONF_GLPK_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1330 { false, "GLPK_LDFLAGS", OCTAVE_CONF_GLPK_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1331 { false, "GLPK_LIBS", OCTAVE_CONF_GLPK_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1332 { false, "GNUPLOT", OCTAVE_CONF_GNUPLOT },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1333 { false, "GRAPHICS_CFLAGS", OCTAVE_CONF_GRAPHICS_CFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1334 { false, "GRAPHICS_LIBS", OCTAVE_CONF_GRAPHICS_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1335 { false, "HDF5_CPPFLAGS", OCTAVE_CONF_HDF5_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1336 { false, "HDF5_LDFLAGS", OCTAVE_CONF_HDF5_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1337 { false, "HDF5_LIBS", OCTAVE_CONF_HDF5_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1338 { false, "LAPACK_LIBS", OCTAVE_CONF_LAPACK_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1339 { false, "LDFLAGS", OCTAVE_CONF_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1340 { false, "LD_CXX", OCTAVE_CONF_LD_CXX },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1341 { false, "LD_STATIC_FLAG", OCTAVE_CONF_LD_STATIC_FLAG },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1342 { false, "LEX", OCTAVE_CONF_LEX },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1343 { false, "LEXLIB", OCTAVE_CONF_LEXLIB },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1344 { false, "LFLAGS", OCTAVE_CONF_LFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1345 { false, "LIBEXT", OCTAVE_CONF_LIBEXT },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1346 { false, "LIBFLAGS", OCTAVE_CONF_LIBFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1347 { false, "LIBOCTAVE", OCTAVE_CONF_LIBOCTAVE },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1348 { false, "LIBOCTINTERP", OCTAVE_CONF_LIBOCTINTERP },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1349 { false, "LIBS", OCTAVE_CONF_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1350 { false, "LLVM_CPPFLAGS", OCTAVE_CONF_LLVM_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1351 { false, "LLVM_LDFLAGS", OCTAVE_CONF_LLVM_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1352 { false, "LLVM_LIBS", OCTAVE_CONF_LLVM_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1353 { false, "LN_S", OCTAVE_CONF_LN_S },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1354 { false, "MAGICK_CPPFLAGS", OCTAVE_CONF_MAGICK_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1355 { false, "MAGICK_LDFLAGS", OCTAVE_CONF_MAGICK_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1356 { false, "MAGICK_LIBS", OCTAVE_CONF_MAGICK_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1357 { false, "MKOCTFILE_DL_LDFLAGS", OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1358 { false, "OCTAVE_LINK_DEPS", OCTAVE_CONF_OCTAVE_LINK_DEPS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1359 { false, "OCTAVE_LINK_OPTS", OCTAVE_CONF_OCTAVE_LINK_OPTS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1360 { false, "OCT_LINK_DEPS", OCTAVE_CONF_OCT_LINK_DEPS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1361 { false, "OCT_LINK_OPTS", OCTAVE_CONF_OCT_LINK_OPTS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1362 { false, "OPENGL_LIBS", OCTAVE_CONF_OPENGL_LIBS },
17821
82c94987abc6 build: Remove REGEX_CPPFLAGS from XTRA_CXXFLAGS.
Rik <rik@octave.org>
parents: 17816
diff changeset
1363 { false, "PCRE_CPPFLAGS", OCTAVE_CONF_PCRE_CPPFLAGS },
82c94987abc6 build: Remove REGEX_CPPFLAGS from XTRA_CXXFLAGS.
Rik <rik@octave.org>
parents: 17816
diff changeset
1364 { false, "PCRE_LIBS", OCTAVE_CONF_PCRE_LIBS },
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1365 { false, "PTHREAD_CFLAGS", OCTAVE_CONF_PTHREAD_CFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1366 { false, "PTHREAD_LIBS", OCTAVE_CONF_PTHREAD_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1367 { false, "QHULL_CPPFLAGS", OCTAVE_CONF_QHULL_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1368 { false, "QHULL_LDFLAGS", OCTAVE_CONF_QHULL_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1369 { false, "QHULL_LIBS", OCTAVE_CONF_QHULL_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1370 { false, "QRUPDATE_CPPFLAGS", OCTAVE_CONF_QRUPDATE_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1371 { false, "QRUPDATE_LDFLAGS", OCTAVE_CONF_QRUPDATE_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1372 { false, "QRUPDATE_LIBS", OCTAVE_CONF_QRUPDATE_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1373 { false, "QT_CPPFLAGS", OCTAVE_CONF_QT_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1374 { false, "QT_LDFLAGS", OCTAVE_CONF_QT_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1375 { false, "QT_LIBS", OCTAVE_CONF_QT_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1376 { false, "RANLIB", OCTAVE_CONF_RANLIB },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1377 { false, "RDYNAMIC_FLAG", OCTAVE_CONF_RDYNAMIC_FLAG },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1378 { false, "READLINE_LIBS", OCTAVE_CONF_READLINE_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1379 { false, "SED", OCTAVE_CONF_SED },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1380 { false, "SHARED_LIBS", OCTAVE_CONF_SHARED_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1381 { false, "SHLEXT", OCTAVE_CONF_SHLEXT },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1382 { false, "SHLEXT_VER", OCTAVE_CONF_SHLEXT_VER },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1383 { false, "SH_LD", OCTAVE_CONF_SH_LD },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1384 { false, "SH_LDFLAGS", OCTAVE_CONF_SH_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1385 { false, "SONAME_FLAGS", OCTAVE_CONF_SONAME_FLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1386 { false, "STATIC_LIBS", OCTAVE_CONF_STATIC_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1387 { false, "TERM_LIBS", OCTAVE_CONF_TERM_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1388 { false, "UMFPACK_CPPFLAGS", OCTAVE_CONF_UMFPACK_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1389 { false, "UMFPACK_LDFLAGS", OCTAVE_CONF_UMFPACK_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1390 { false, "UMFPACK_LIBS", OCTAVE_CONF_UMFPACK_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1391 { false, "USE_64_BIT_IDX_T", OCTAVE_CONF_USE_64_BIT_IDX_T },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1392 { false, "WARN_CFLAGS", OCTAVE_CONF_WARN_CFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1393 { false, "WARN_CXXFLAGS", OCTAVE_CONF_WARN_CXXFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1394 { false, "X11_INCFLAGS", OCTAVE_CONF_X11_INCFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1395 { false, "X11_LIBS", OCTAVE_CONF_X11_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1396 { false, "XTRA_CFLAGS", OCTAVE_CONF_XTRA_CFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1397 { false, "XTRA_CXXFLAGS", OCTAVE_CONF_XTRA_CXXFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1398 { false, "YACC", OCTAVE_CONF_YACC },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1399 { false, "YFLAGS", OCTAVE_CONF_YFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1400 { false, "Z_CPPFLAGS", OCTAVE_CONF_Z_CPPFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1401 { false, "Z_LDFLAGS", OCTAVE_CONF_Z_LDFLAGS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1402 { false, "Z_LIBS", OCTAVE_CONF_Z_LIBS },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1403 { false, "api_version", OCTAVE_API_VERSION },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1404 { true, "archlibdir", OCTAVE_ARCHLIBDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1405 { true, "bindir", OCTAVE_BINDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1406 { false, "canonical_host_type", OCTAVE_CANONICAL_HOST_TYPE },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1407 { false, "config_opts", OCTAVE_CONF_config_opts },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1408 { true, "datadir", OCTAVE_DATADIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1409 { true, "datarootdir", OCTAVE_DATAROOTDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1410 { true, "exec_prefix", OCTAVE_EXEC_PREFIX },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1411 { true, "fcnfiledir", OCTAVE_FCNFILEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1412 { true, "imagedir", OCTAVE_IMAGEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1413 { true, "includedir", OCTAVE_INCLUDEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1414 { true, "infodir", OCTAVE_INFODIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1415 { true, "infofile", OCTAVE_INFOFILE },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1416 { true, "libdir", OCTAVE_LIBDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1417 { true, "libexecdir", OCTAVE_LIBEXECDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1418 { true, "localapiarchlibdir", OCTAVE_LOCALAPIARCHLIBDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1419 { true, "localapifcnfiledir", OCTAVE_LOCALAPIFCNFILEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1420 { true, "localapioctfiledir", OCTAVE_LOCALAPIOCTFILEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1421 { true, "localarchlibdir", OCTAVE_LOCALARCHLIBDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1422 { true, "localfcnfiledir", OCTAVE_LOCALFCNFILEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1423 { true, "localoctfiledir", OCTAVE_LOCALOCTFILEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1424 { true, "localstartupfiledir", OCTAVE_LOCALSTARTUPFILEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1425 { true, "localverarchlibdir", OCTAVE_LOCALVERARCHLIBDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1426 { true, "localverfcnfiledir", OCTAVE_LOCALVERFCNFILEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1427 { true, "localveroctfiledir", OCTAVE_LOCALVEROCTFILEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1428 { true, "man1dir", OCTAVE_MAN1DIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1429 { false, "man1ext", OCTAVE_MAN1EXT },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1430 { true, "mandir", OCTAVE_MANDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1431 { true, "octfiledir", OCTAVE_OCTFILEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1432 { true, "octetcdir", OCTAVE_OCTETCDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1433 { true, "octincludedir", OCTAVE_OCTINCLUDEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1434 { true, "octlibdir", OCTAVE_OCTLIBDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1435 { true, "octtestsdir", OCTAVE_OCTTESTSDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1436 { true, "prefix", OCTAVE_PREFIX },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1437 { true, "startupfiledir", OCTAVE_STARTUPFILEDIR },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1438 { false, "version", OCTAVE_VERSION },
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1439 { false, 0, 0 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17755
diff changeset
1440 };
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1441
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1442 if (! initialized)
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1443 {
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4494
diff changeset
1444 m.assign ("dld", octave_value (octave_supports_dynamic_linking));
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1445
4697
c26904f532f1 [project @ 2004-01-16 17:49:20 by jwe]
jwe
parents: 4691
diff changeset
1446 oct_mach_info::float_format ff = oct_mach_info::native_float_format ();
c26904f532f1 [project @ 2004-01-16 17:49:20 by jwe]
jwe
parents: 4691
diff changeset
1447 m.assign ("float_format",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1448 octave_value (oct_mach_info::float_format_as_string (ff)));
4697
c26904f532f1 [project @ 2004-01-16 17:49:20 by jwe]
jwe
parents: 4691
diff changeset
1449
c26904f532f1 [project @ 2004-01-16 17:49:20 by jwe]
jwe
parents: 4691
diff changeset
1450 m.assign ("words_big_endian",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1451 octave_value (oct_mach_info::words_big_endian ()));
4697
c26904f532f1 [project @ 2004-01-16 17:49:20 by jwe]
jwe
parents: 4691
diff changeset
1452
c26904f532f1 [project @ 2004-01-16 17:49:20 by jwe]
jwe
parents: 4691
diff changeset
1453 m.assign ("words_little_endian",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1454 octave_value (oct_mach_info::words_little_endian ()));
4697
c26904f532f1 [project @ 2004-01-16 17:49:20 by jwe]
jwe
parents: 4691
diff changeset
1455
16170
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 16164
diff changeset
1456 m.assign ("features", octave_value (octave_config_features ()));
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 16164
diff changeset
1457
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1458 int i = 0;
4440
0bca8443db39 [project @ 2003-07-02 22:45:29 by jwe]
jwe
parents: 4429
diff changeset
1459
0bca8443db39 [project @ 2003-07-02 22:45:29 by jwe]
jwe
parents: 4429
diff changeset
1460 while (true)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1461 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1462 const conf_info_struct& elt = conf_info[i++];
6274
d42abdfcb8e9 [project @ 2007-02-07 07:22:02 by jwe]
jwe
parents: 6222
diff changeset
1463
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1464 const char *key = elt.key;
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1465
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1466 if (key)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1467 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1468 if (elt.subst_home)
11066
e678346a47d9 toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents: 11023
diff changeset
1469 m.assign (key, subst_octave_home (elt.val));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1470 else
11066
e678346a47d9 toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents: 11023
diff changeset
1471 m.assign (key, elt.val);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1472 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1473 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1474 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1475 }
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1476
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1477 bool unix_system = true;
7013
f943e9635115 [project @ 2007-10-11 19:39:02 by jwe]
jwe
parents: 7010
diff changeset
1478 bool mac_system = false;
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1479 bool windows_system = false;
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1480
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1481 #if defined (WIN32)
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1482 windows_system = true;
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1483 #if !defined (__CYGWIN__)
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1484 unix_system = false;
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1485 #endif
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1486 #endif
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1487
8574
83b8c739d626 toplev.cc: check OCTAVE_USE_OS_X_API instead of __APPLE__ && __MACH__
John W. Eaton <jwe@octave.org>
parents: 8377
diff changeset
1488 #if defined (OCTAVE_USE_OS_X_API)
7010
f7d2f54008f5 [project @ 2007-10-11 17:50:34 by jwe]
jwe
parents: 7001
diff changeset
1489 mac_system = true;
f7d2f54008f5 [project @ 2007-10-11 17:50:34 by jwe]
jwe
parents: 7001
diff changeset
1490 #endif
f7d2f54008f5 [project @ 2007-10-11 17:50:34 by jwe]
jwe
parents: 7001
diff changeset
1491
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1492 m.assign ("unix", octave_value (unix_system));
7010
f7d2f54008f5 [project @ 2007-10-11 17:50:34 by jwe]
jwe
parents: 7001
diff changeset
1493 m.assign ("mac", octave_value (mac_system));
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1494 m.assign ("windows", octave_value (windows_system));
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4675
diff changeset
1495
4357
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1496 initialized = true;
d700cfed902a [project @ 2003-02-22 18:48:18 by jwe]
jwe
parents: 4356
diff changeset
1497 }
2162
a940dcdfe9de [project @ 1996-05-13 10:31:51 by jwe]
jwe
parents: 2145
diff changeset
1498
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1499 int nargin = args.length ();
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1500
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1501 if (nargin == 1)
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1502 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
1503 std::string arg = args(0).string_value ();
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1504
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1505 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1506 {
15307
b516da00c5e4 don't insert unknonwn parameters in internal octave_config_info struct
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
1507 if (m.isfield (arg))
b516da00c5e4 don't insert unknonwn parameters in internal octave_config_info struct
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
1508 {
b516da00c5e4 don't insert unknonwn parameters in internal octave_config_info struct
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
1509 Cell c = m.contents (arg);
5199
16a6247730d9 [project @ 2005-03-10 20:24:45 by jwe]
jwe
parents: 5189
diff changeset
1510
15307
b516da00c5e4 don't insert unknonwn parameters in internal octave_config_info struct
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
1511 if (c.is_empty ())
15467
049e8bbff782 maint: periodic merge of stable to default
John W. Eaton <jwe@octave.org>
parents: 15466 15451
diff changeset
1512 error ("octave_config_info: no info for '%s'", arg.c_str ());
15307
b516da00c5e4 don't insert unknonwn parameters in internal octave_config_info struct
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
1513 else
b516da00c5e4 don't insert unknonwn parameters in internal octave_config_info struct
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
1514 retval = c(0);
b516da00c5e4 don't insert unknonwn parameters in internal octave_config_info struct
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
1515 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1516 else
15467
049e8bbff782 maint: periodic merge of stable to default
John W. Eaton <jwe@octave.org>
parents: 15466 15451
diff changeset
1517 error ("octave_config_info: invalid parameter '%s'", arg.c_str ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10212
diff changeset
1518 }
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1519 }
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1520 else if (nargin == 0)
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4221
diff changeset
1521 retval = m;
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1522 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5814
diff changeset
1523 print_usage ();
2689
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1524
8c7955a8d49f [project @ 1997-02-18 09:06:10 by jwe]
jwe
parents: 2675
diff changeset
1525 return retval;
2162
a940dcdfe9de [project @ 1996-05-13 10:31:51 by jwe]
jwe
parents: 2145
diff changeset
1526 }
a940dcdfe9de [project @ 1996-05-13 10:31:51 by jwe]
jwe
parents: 2145
diff changeset
1527
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1528 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14156
diff changeset
1529 %!assert (ischar (octave_config_info ("version")))
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1530 %!test
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1531 %! x = octave_config_info ();
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1532 %! assert (isstruct (x));
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1533 %! assert (! isempty (x));
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14156
diff changeset
1534
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14156
diff changeset
1535 %!error octave_config_info (1, 2)
12846
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1536 */
9ce9e1e2d2c8 codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
1537
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1538 #if defined (__GNUG__) && defined (DEBUG_NEW_DELETE)
2806
187d5321cfa3 [project @ 1997-03-11 05:13:15 by jwe]
jwe
parents: 2802
diff changeset
1539
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1540 int debug_new_delete = 0;
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1541
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1542 typedef void (*vfp)(void);
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1543 extern vfp __new_handler;
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1544
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1545 void *
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1546 __builtin_new (size_t sz)
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1547 {
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1548 void *p;
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1549
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1550 /* malloc (0) is unpredictable; avoid it. */
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1551 if (sz == 0)
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1552 sz = 1;
15451
219479b461b8 build: Add missing tests and gnulib modules suggested by autoscan.
Rik <rik@octave.org>
parents: 15424
diff changeset
1553 p = gnulib::malloc (sz);
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1554 while (p == 0)
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1555 {
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1556 (*__new_handler) ();
15451
219479b461b8 build: Add missing tests and gnulib modules suggested by autoscan.
Rik <rik@octave.org>
parents: 15424
diff changeset
1557 p = gnulib::malloc (sz);
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1558 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1559
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1560 if (debug_new_delete)
5629
489a475073d7 [project @ 2006-02-20 21:47:12 by jwe]
jwe
parents: 5510
diff changeset
1561 std::cerr << "__builtin_new: " << p << std::endl;
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1562
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1563 return p;
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1564 }
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1565
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1566 void
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1567 __builtin_delete (void *ptr)
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1568 {
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1569 if (debug_new_delete)
5629
489a475073d7 [project @ 2006-02-20 21:47:12 by jwe]
jwe
parents: 5510
diff changeset
1570 std::cerr << "__builtin_delete: " << ptr << std::endl;
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1571
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1572 if (ptr)
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1573 free (ptr);
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1574 }
2806
187d5321cfa3 [project @ 1997-03-11 05:13:15 by jwe]
jwe
parents: 2802
diff changeset
1575
1683
5282f171363d [project @ 1995-12-30 03:46:07 by jwe]
jwe
parents:
diff changeset
1576 #endif