1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
20 |
|
21 */ |
|
22 |
|
23 // Born February 20, 1992. |
|
24 |
240
|
25 #ifdef HAVE_CONFIG_H |
1192
|
26 #include <config.h> |
1
|
27 #endif |
|
28 |
1355
|
29 #include <cassert> |
|
30 #include <cstdlib> |
|
31 #include <cstring> |
|
32 #include <ctime> |
|
33 |
3503
|
34 #include <fstream> |
|
35 #include <iostream> |
1355
|
36 |
|
37 #ifdef HAVE_UNISTD_H |
2442
|
38 #ifdef HAVE_SYS_TYPES_H |
1
|
39 #include <sys/types.h> |
2442
|
40 #endif |
139
|
41 #include <unistd.h> |
|
42 #endif |
1355
|
43 |
2926
|
44 #include "cmd-edit.h" |
3690
|
45 #include "f77-fcn.h" |
4097
|
46 #include "file-ops.h" |
2926
|
47 #include "file-stat.h" |
240
|
48 #include "lo-error.h" |
2926
|
49 #include "oct-env.h" |
3019
|
50 #include "pathsearch.h" |
1907
|
51 #include "str-vec.h" |
223
|
52 |
2492
|
53 #include <defaults.h> |
3933
|
54 #include "Cell.h" |
1355
|
55 #include "defun.h" |
|
56 #include "error.h" |
|
57 #include "file-io.h" |
1
|
58 #include "input.h" |
|
59 #include "lex.h" |
4113
|
60 #include "octave.h" |
1742
|
61 #include "oct-hist.h" |
3195
|
62 #include "oct-obj.h" |
2375
|
63 #include "ops.h" |
1670
|
64 #include "toplev.h" |
1
|
65 #include "parse.h" |
2982
|
66 #include "pt-plot.h" |
562
|
67 #include "procstream.h" |
1817
|
68 #include "prog-args.h" |
1355
|
69 #include "sighandlers.h" |
|
70 #include "sysdep.h" |
2375
|
71 #include "ov.h" |
1
|
72 #include "unwind-prot.h" |
1355
|
73 #include "utils.h" |
|
74 #include "variables.h" |
2492
|
75 #include <version.h> |
1
|
76 |
4159
|
77 // Kluge. |
|
78 extern "C" void F77_FUNC (xerbla, XERBLA) (const char *, int, long); |
|
79 |
2910
|
80 extern void install_builtins (void); |
|
81 |
1704
|
82 #if !defined (HAVE_ATEXIT) && defined (HAVE_ON_EXIT) |
|
83 extern "C" int on_exit (); |
|
84 #define atexit on_exit |
|
85 #endif |
|
86 |
1907
|
87 // The command-line options. |
|
88 static string_vector octave_argv; |
1
|
89 |
2239
|
90 // TRUE means we read ~/.octaverc and ./.octaverc. |
|
91 // (--norc; --no-init-file; -f) |
|
92 static bool read_init_files = true; |
|
93 |
|
94 // TRUE means we read the site-wide octaverc files. |
|
95 // (--norc; --no-site-file; -f) |
2240
|
96 static bool read_site_files = true; |
1
|
97 |
3019
|
98 // TRUE means we don't print the usual startup message. |
616
|
99 // (--quiet; --silent; -q) |
2239
|
100 static bool inhibit_startup_message = false; |
1
|
101 |
3019
|
102 // TRUE means we turn on compatibility options. |
1410
|
103 // (--traditional) |
2239
|
104 static bool traditional = false; |
1410
|
105 |
3019
|
106 // If TRUE, print verbose info in some cases. |
1825
|
107 // (--verbose; -V) |
2239
|
108 static bool verbose_flag = false; |
1825
|
109 |
1
|
110 // Usage message |
139
|
111 static const char *usage_string = |
3180
|
112 "octave [-?HVdfhiqvx] [--debug] [--echo-commands] [--exec-path path]\n\ |
4356
|
113 [--funcall FUNC] [--help] [--info-file file] [--info-program prog]\n\ |
|
114 [--interactive] [--no-history] [--no-init-file] [--no-line-editing]\n\ |
|
115 [--no-site-file] [-p path] [--path path] [--silent] [--traditional]\n\ |
|
116 [--verbose] [--version] [file]"; |
1
|
117 |
1358
|
118 // This is here so that it's more likely that the usage message and |
1410
|
119 // the real set of options will agree. Note: the `+' must come first |
|
120 // to prevent getopt from permuting arguments! |
3180
|
121 static const char *short_opts = "+?HVdfhip:qvx"; |
139
|
122 |
4356
|
123 // The name of the optional initial function to call at startup. |
|
124 // (--funcall FUNC) |
|
125 static std::string fun_to_call; |
|
126 |
1103
|
127 // Long options. See the comments in getopt.h for the meanings of the |
|
128 // fields in this structure. |
1613
|
129 #define EXEC_PATH_OPTION 1 |
4356
|
130 #define FUNCALL_OPTION 2 |
|
131 #define INFO_FILE_OPTION 3 |
|
132 #define INFO_PROG_OPTION 4 |
|
133 #define NO_INIT_FILE_OPTION 5 |
|
134 #define NO_LINE_EDITING_OPTION 6 |
|
135 #define NO_SITE_FILE_OPTION 7 |
|
136 #define TRADITIONAL_OPTION 8 |
1817
|
137 long_options long_opts[] = |
139
|
138 { |
1855
|
139 { "debug", prog_args::no_arg, 0, 'd' }, |
2277
|
140 { "braindead", prog_args::no_arg, 0, TRADITIONAL_OPTION }, |
1855
|
141 { "echo-commands", prog_args::no_arg, 0, 'x' }, |
|
142 { "exec-path", prog_args::required_arg, 0, EXEC_PATH_OPTION }, |
4356
|
143 { "funcall", prog_args::required_arg, 0, FUNCALL_OPTION }, |
1855
|
144 { "help", prog_args::no_arg, 0, 'h' }, |
|
145 { "info-file", prog_args::required_arg, 0, INFO_FILE_OPTION }, |
|
146 { "info-program", prog_args::required_arg, 0, INFO_PROG_OPTION }, |
|
147 { "interactive", prog_args::no_arg, 0, 'i' }, |
3180
|
148 { "no-history", prog_args::no_arg, 0, 'H' }, |
2239
|
149 { "no-init-file", prog_args::no_arg, 0, NO_INIT_FILE_OPTION }, |
1855
|
150 { "no-line-editing", prog_args::no_arg, 0, NO_LINE_EDITING_OPTION }, |
2239
|
151 { "no-site-file", prog_args::no_arg, 0, NO_SITE_FILE_OPTION }, |
1855
|
152 { "norc", prog_args::no_arg, 0, 'f' }, |
|
153 { "path", prog_args::required_arg, 0, 'p' }, |
|
154 { "quiet", prog_args::no_arg, 0, 'q' }, |
|
155 { "silent", prog_args::no_arg, 0, 'q' }, |
|
156 { "traditional", prog_args::no_arg, 0, TRADITIONAL_OPTION }, |
|
157 { "verbose", prog_args::no_arg, 0, 'V' }, |
|
158 { "version", prog_args::no_arg, 0, 'v' }, |
3019
|
159 { 0, 0, 0, 0 } |
139
|
160 }; |
1
|
161 |
1355
|
162 // Store the command-line options for later use. |
|
163 |
|
164 static void |
|
165 intern_argv (int argc, char **argv) |
|
166 { |
4700
|
167 bind_builtin_variable ("__nargin__", argc-1, true, true, 0); |
3195
|
168 |
4587
|
169 Cell args; |
3195
|
170 |
1355
|
171 if (argc > 1) |
|
172 { |
3933
|
173 Array<octave_value> tmp (argc-1); |
|
174 |
2495
|
175 // Skip program name in argv. |
3933
|
176 int i = argc; |
|
177 while (--i > 0) |
|
178 tmp(i-1) = octave_value (*(argv+i)); |
1411
|
179 |
4587
|
180 args = Cell (tmp, argc-1, 1); |
1355
|
181 } |
1907
|
182 |
4587
|
183 bind_builtin_constant ("argv", args, true, true); |
1355
|
184 } |
|
185 |
1792
|
186 static void |
|
187 initialize_pathsearch (void) |
|
188 { |
|
189 // This may seem odd, but doing it this way means that we don't have |
|
190 // to modify the kpathsea library... |
|
191 |
3523
|
192 std::string odb = octave_env::getenv ("OCTAVE_DB_PATH"); |
3141
|
193 |
|
194 // For backward compatibility. |
1792
|
195 |
2926
|
196 if (odb.empty ()) |
3141
|
197 odb = octave_env::getenv ("OCTAVE_DB_DIR"); |
1792
|
198 |
3141
|
199 if (odb.empty ()) |
4101
|
200 odb = Vdata_dir + file_ops::dir_sep_str + "octave:" |
|
201 + Vlibexec_dir + file_ops::dir_sep_str + "octave"; |
1792
|
202 } |
|
203 |
581
|
204 // Initialize by reading startup files. |
|
205 |
1
|
206 static void |
|
207 execute_startup_files (void) |
|
208 { |
2985
|
209 unwind_protect::begin_frame ("execute_startup_files"); |
315
|
210 |
1651
|
211 // XXX FIXME XXX -- need to make it possible to set this in startup |
|
212 // files. |
1588
|
213 |
3019
|
214 unwind_protect_bool (input_from_startup_file); |
1651
|
215 |
3019
|
216 input_from_startup_file = true; |
315
|
217 |
793
|
218 int verbose = (verbose_flag && ! inhibit_startup_message); |
578
|
219 |
2239
|
220 if (read_site_files) |
1
|
221 { |
2239
|
222 // Execute commands from the site-wide configuration file. |
|
223 // First from the file $(prefix)/lib/octave/site/m/octaverc |
|
224 // (if it exists), then from the file |
3597
|
225 // $(prefix)/share/octave/$(version)/m/octaverc (if it exists). |
1755
|
226 |
2897
|
227 parse_and_execute (Vlocal_site_defaults_file, verbose); |
1755
|
228 |
2897
|
229 parse_and_execute (Vsite_defaults_file, verbose); |
1
|
230 } |
|
231 |
2239
|
232 if (read_init_files) |
|
233 { |
2512
|
234 // Try to execute commands from $HOME/$OCTAVE_INITFILE and |
|
235 // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set, .octaverc |
|
236 // is assumed. |
2239
|
237 |
4804
|
238 bool home_rc_already_executed = false; |
2512
|
239 |
3523
|
240 std::string initfile = octave_env::getenv ("OCTAVE_INITFILE"); |
2512
|
241 |
2926
|
242 if (initfile.empty ()) |
2512
|
243 initfile = ".octaverc"; |
|
244 |
3523
|
245 std::string home_dir = octave_env::get_home_directory (); |
2926
|
246 |
4804
|
247 std::string home_rc = octave_env::make_absolute (initfile, home_dir); |
|
248 |
|
249 std::string local_rc; |
2239
|
250 |
2926
|
251 if (! home_dir.empty ()) |
2239
|
252 { |
2897
|
253 parse_and_execute (home_rc, verbose); |
2239
|
254 |
|
255 // Names alone are not enough. |
|
256 |
|
257 file_stat fs_home_rc (home_rc); |
|
258 |
|
259 if (fs_home_rc) |
|
260 { |
4804
|
261 // We want to check for curr_dir after executing home_rc |
|
262 // because doing that may change the working directory. |
|
263 |
|
264 std::string curr_dir = octave_env::getcwd (); |
|
265 |
|
266 local_rc = octave_env::make_absolute (initfile, curr_dir); |
|
267 |
2512
|
268 file_stat fs_dot_rc (local_rc); |
2239
|
269 |
|
270 if (fs_dot_rc && fs_home_rc.ino () == fs_dot_rc.ino ()) |
4804
|
271 home_rc_already_executed = true; |
2239
|
272 } |
|
273 } |
|
274 |
|
275 if (! home_rc_already_executed) |
4804
|
276 { |
|
277 if (local_rc.empty ()) |
|
278 { |
|
279 std::string curr_dir = octave_env::getcwd (); |
|
280 |
|
281 local_rc = octave_env::make_absolute (initfile, curr_dir); |
|
282 } |
|
283 |
|
284 parse_and_execute (local_rc, verbose); |
|
285 } |
2239
|
286 } |
315
|
287 |
2985
|
288 unwind_protect::run_frame ("execute_startup_files"); |
1
|
289 } |
|
290 |
581
|
291 // Usage message with extra help. |
|
292 |
1
|
293 static void |
|
294 verbose_usage (void) |
|
295 { |
3922
|
296 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY "\n\ |
1613
|
297 \n\ |
|
298 Usage: octave [options]\n\ |
|
299 \n\ |
|
300 Options:\n\ |
1119
|
301 \n\ |
3180
|
302 --debug, -d Enter parser debugging mode.\n\ |
|
303 --echo-commands, -x Echo commands as they are executed.\n\ |
1613
|
304 --exec-path PATH Set path for executing subprograms.\n\ |
4356
|
305 --funcall FUNC Call Octave function FUNC with no arguments.\n\ |
3180
|
306 --help, -h, -? Print short help message and exit.\n\ |
1613
|
307 --info-file FILE Use top-level info file FILE.\n\ |
|
308 --info-program PROGRAM Use PROGRAM for reading info files.\n\ |
3180
|
309 --interactive, -i Force interactive behavior.\n\ |
|
310 --no-history, -H Don't save commands to the history list\n\ |
2470
|
311 --no-init-file Don't read the ~/.octaverc or .octaverc files.\n\ |
2212
|
312 --no-line-editing Don't use readline for command-line editing.\n\ |
2470
|
313 --no-site-file Don't read the site-wide octaverc file.\n\ |
3238
|
314 --norc, -f Don't read any initialization files.\n\ |
3180
|
315 --path PATH, -p PATH Set initial LOADPATH to PATH.\n\ |
|
316 --silent, -q Don't print message at startup.\n\ |
1613
|
317 --traditional Set compatibility variables.\n\ |
3180
|
318 --verbose, -V Enable verbose output in some cases.\n\ |
|
319 --version, -v Print version number and exit.\n\ |
1119
|
320 \n\ |
1613
|
321 FILE Execute commands from FILE.\n\ |
4829
|
322 \n" |
|
323 OCTAVE_WWW_STATEMENT "\n\ |
4356
|
324 \n" |
|
325 OCTAVE_CONTRIB_STATEMENT "\n\ |
|
326 \n" |
|
327 OCTAVE_BUGS_STATEMENT "\n"; |
285
|
328 |
613
|
329 exit (0); |
1
|
330 } |
|
331 |
581
|
332 // Terse usage messsage. |
|
333 |
1
|
334 static void |
|
335 usage (void) |
|
336 { |
3531
|
337 std::cerr << "usage: " << usage_string << "\n"; |
1
|
338 exit (1); |
|
339 } |
|
340 |
|
341 static void |
|
342 print_version_and_exit (void) |
|
343 { |
3922
|
344 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS "\n"; |
1
|
345 exit (0); |
|
346 } |
|
347 |
721
|
348 static void |
|
349 initialize_error_handlers () |
|
350 { |
|
351 set_liboctave_error_handler (error); |
3325
|
352 set_liboctave_warning_handler (warning); |
721
|
353 } |
|
354 |
1410
|
355 // What happens on --traditional. |
|
356 |
|
357 static void |
|
358 maximum_braindamage (void) |
|
359 { |
|
360 bind_builtin_variable ("PS1", ">> "); |
|
361 bind_builtin_variable ("PS2", ""); |
4324
|
362 bind_builtin_variable ("beep_on_error", true); |
|
363 bind_builtin_variable ("crash_dumps_octave_core", false); |
1410
|
364 bind_builtin_variable ("default_save_format", "mat-binary"); |
4324
|
365 bind_builtin_variable ("fixed_point_format", true); |
|
366 bind_builtin_variable ("page_screen_output", false); |
|
367 bind_builtin_variable ("print_empty_dimensions", false); |
|
368 bind_builtin_variable ("warn_function_name_clash", false); |
4476
|
369 bind_builtin_variable ("warn_matlab_incompatible", true); |
1410
|
370 } |
|
371 |
581
|
372 // You guessed it. |
|
373 |
1
|
374 int |
4368
|
375 octave_main (int argc, char **argv, int embedded) |
1
|
376 { |
3019
|
377 octave_env::set_program_name (argv[0]); |
|
378 |
2205
|
379 // The order of these calls is important. The call to |
2926
|
380 // install_defaults must come before install_builtins because |
3019
|
381 // default variable values must be available for the variables to be |
2205
|
382 // installed, and the call to install_builtins must come before the |
|
383 // options are processed because some command line options override |
|
384 // defaults by calling bind_builtin_variable. |
721
|
385 |
1
|
386 sysdep_init (); |
|
387 |
4159
|
388 // The idea here is to force xerbla to be referenced so that we will |
|
389 // link to our own version instead of the one provided by the BLAS |
|
390 // library. But octave_NaN should never be -1, so we should never |
|
391 // actually call xerbla. |
|
392 |
|
393 if (octave_NaN == -1) |
|
394 F77_FUNC (xerbla, XERBLA) ("octave", 13, 6L); |
|
395 |
721
|
396 initialize_error_handlers (); |
223
|
397 |
2926
|
398 install_defaults (); |
1
|
399 |
1792
|
400 initialize_pathsearch (); |
1744
|
401 |
4368
|
402 if (! embedded) |
|
403 install_signal_handlers (); |
2205
|
404 |
|
405 initialize_file_io (); |
|
406 |
2375
|
407 initialize_symbol_tables (); |
|
408 |
|
409 install_types (); |
|
410 |
|
411 install_ops (); |
2205
|
412 |
|
413 install_builtins (); |
|
414 |
1817
|
415 prog_args args (argc, argv, short_opts, long_opts); |
|
416 |
139
|
417 int optc; |
1817
|
418 while ((optc = args.getopt ()) != EOF) |
1
|
419 { |
139
|
420 switch (optc) |
1
|
421 { |
3180
|
422 case 'H': |
4324
|
423 bind_builtin_variable ("saving_history", false); |
3180
|
424 break; |
|
425 |
793
|
426 case 'V': |
2239
|
427 verbose_flag = true; |
793
|
428 break; |
|
429 |
1
|
430 case 'd': |
4753
|
431 // This is the same as yydebug in parse.y. |
|
432 octave_debug++; |
1
|
433 break; |
777
|
434 |
1
|
435 case 'f': |
2239
|
436 read_init_files = false; |
|
437 read_site_files = false; |
1
|
438 break; |
777
|
439 |
1
|
440 case 'h': |
|
441 case '?': |
|
442 verbose_usage (); |
|
443 break; |
777
|
444 |
1
|
445 case 'i': |
3019
|
446 forced_interactive = true; |
1
|
447 break; |
777
|
448 |
1
|
449 case 'p': |
1817
|
450 if (args.optarg ()) |
2205
|
451 bind_builtin_variable ("LOADPATH", args.optarg ()); |
1
|
452 break; |
777
|
453 |
1
|
454 case 'q': |
2239
|
455 inhibit_startup_message = true; |
1
|
456 break; |
777
|
457 |
1
|
458 case 'x': |
2205
|
459 { |
|
460 double tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_CMD_LINE); |
|
461 bind_builtin_variable ("echo_executing_commands", tmp); |
|
462 } |
1
|
463 break; |
777
|
464 |
1
|
465 case 'v': |
|
466 print_version_and_exit (); |
|
467 break; |
777
|
468 |
1613
|
469 case EXEC_PATH_OPTION: |
1817
|
470 if (args.optarg ()) |
2205
|
471 bind_builtin_variable ("EXEC_PATH", args.optarg ()); |
1613
|
472 break; |
|
473 |
4356
|
474 case FUNCALL_OPTION: |
|
475 if (args.optarg ()) |
|
476 fun_to_call = args.optarg (); |
|
477 break; |
|
478 |
186
|
479 case INFO_FILE_OPTION: |
1817
|
480 if (args.optarg ()) |
2205
|
481 bind_builtin_variable ("INFO_FILE", args.optarg ()); |
186
|
482 break; |
777
|
483 |
1613
|
484 case INFO_PROG_OPTION: |
1817
|
485 if (args.optarg ()) |
2205
|
486 bind_builtin_variable ("INFO_PROGRAM", args.optarg ()); |
1613
|
487 break; |
|
488 |
2239
|
489 case NO_INIT_FILE_OPTION: |
|
490 read_init_files = false; |
|
491 break; |
|
492 |
1821
|
493 case NO_LINE_EDITING_OPTION: |
3019
|
494 line_editing = false; |
2239
|
495 break; |
|
496 |
|
497 case NO_SITE_FILE_OPTION: |
|
498 read_site_files = 0; |
1821
|
499 break; |
|
500 |
1410
|
501 case TRADITIONAL_OPTION: |
2239
|
502 traditional = true; |
1410
|
503 break; |
|
504 |
1
|
505 default: |
|
506 usage (); |
|
507 break; |
|
508 } |
|
509 } |
|
510 |
1651
|
511 #if defined (HAVE_ATEXIT) || defined (HAVE_ON_EXIT) |
2077
|
512 // Make sure we clean up when we exit. Also allow users to register |
|
513 // functions. If we don't have atexit or on_exit, we're going to |
|
514 // leave some junk files around if we exit abnormally. |
|
515 |
|
516 atexit (do_octave_atexit); |
318
|
517 #endif |
1
|
518 |
1358
|
519 // These can come after command line args since none of them set any |
|
520 // defaults that might be changed by command line options. |
581
|
521 |
2926
|
522 initialize_command_input (); |
315
|
523 |
578
|
524 if (! inhibit_startup_message) |
3538
|
525 std::cout << OCTAVE_STARTUP_MESSAGE "\n" << std::endl; |
578
|
526 |
1410
|
527 if (traditional) |
|
528 maximum_braindamage (); |
|
529 |
4217
|
530 octave_interpreter_ready = true; |
|
531 |
|
532 execute_default_pkg_add_files (); |
|
533 |
2239
|
534 execute_startup_files (); |
1651
|
535 |
2926
|
536 command_history::read (false); |
1
|
537 |
578
|
538 if (! inhibit_startup_message && reading_startup_message_printed) |
3538
|
539 std::cout << std::endl; |
578
|
540 |
1358
|
541 // Avoid counting commands executed from startup files. |
|
542 |
2926
|
543 command_editor::reset_current_command_number (1); |
1
|
544 |
1358
|
545 // If there is an extra argument, see if it names a file to read. |
|
546 // Additional arguments are taken as command line options for the |
|
547 // script. |
1
|
548 |
1817
|
549 int last_arg_idx = args.optind (); |
3019
|
550 |
1817
|
551 int remaining_args = argc - last_arg_idx; |
3019
|
552 |
1355
|
553 if (remaining_args > 0) |
149
|
554 { |
3019
|
555 reading_script_file = true; |
|
556 |
1817
|
557 curr_fcn_file_name = argv[last_arg_idx]; |
1608
|
558 curr_fcn_file_full_name = curr_fcn_file_name; |
1411
|
559 |
984
|
560 FILE *infile = get_input_from_file (curr_fcn_file_name); |
1411
|
561 |
529
|
562 if (infile) |
287
|
563 { |
3019
|
564 input_from_command_line_file = true; |
1516
|
565 |
1411
|
566 bind_builtin_variable ("program_invocation_name", |
|
567 curr_fcn_file_name); |
|
568 |
4101
|
569 size_t pos |
|
570 = curr_fcn_file_name.find_last_of (file_ops::dir_sep_chars); |
1755
|
571 |
3523
|
572 std::string tmp = (pos != NPOS) |
1755
|
573 ? curr_fcn_file_name.substr (pos+1) : curr_fcn_file_name; |
1411
|
574 |
|
575 bind_builtin_variable ("program_name", tmp); |
|
576 |
1817
|
577 intern_argv (remaining_args, argv+last_arg_idx); |
1411
|
578 |
2926
|
579 command_editor::blink_matching_paren (false); |
|
580 |
287
|
581 switch_to_buffer (create_buffer (infile)); |
|
582 } |
529
|
583 else |
|
584 clean_up_and_exit (1); |
1
|
585 } |
|
586 else |
|
587 { |
1355
|
588 // Is input coming from a terminal? If so, we are probably |
|
589 // interactive. |
1
|
590 |
4368
|
591 interactive = (! embedded |
|
592 && isatty (fileno (stdin)) && isatty (fileno (stdout))); |
1355
|
593 |
|
594 intern_argv (argc, argv); |
|
595 |
4368
|
596 if (! embedded) |
|
597 switch_to_buffer (create_buffer (get_input_from_stdin ())); |
1
|
598 } |
|
599 |
1358
|
600 // Force input to be echoed if not really interactive, but the user |
|
601 // has forced interactive behavior. |
1
|
602 |
1907
|
603 if (! interactive && forced_interactive) |
287
|
604 { |
2926
|
605 command_editor::blink_matching_paren (false); |
1588
|
606 |
|
607 // XXX FIXME XXX -- is this the right thing to do? |
|
608 |
4233
|
609 bind_builtin_variable ("echo_executing_commands", ECHO_CMD_LINE); |
287
|
610 } |
1
|
611 |
1410
|
612 if (! interactive) |
3019
|
613 line_editing = false; |
1
|
614 |
4368
|
615 if (embedded) |
|
616 return 1; |
|
617 |
4356
|
618 int retval = main_loop (fun_to_call); |
1
|
619 |
1005
|
620 if (retval == 1 && ! error_state) |
|
621 retval = 0; |
|
622 |
1
|
623 clean_up_and_exit (retval); |
4247
|
624 |
|
625 return 0; |
1
|
626 } |
|
627 |
560
|
628 /* |
1
|
629 ;;; Local Variables: *** |
|
630 ;;; mode: C++ *** |
|
631 ;;; End: *** |
|
632 */ |