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 { |
4892
|
167 symbol_record *nargin_sr = top_level_sym_tab->lookup ("__nargin__", true); |
|
168 |
|
169 nargin_sr->mark_as_static (); |
|
170 |
|
171 nargin_sr->define (argc-1); |
3195
|
172 |
4587
|
173 Cell args; |
3195
|
174 |
1355
|
175 if (argc > 1) |
|
176 { |
3933
|
177 Array<octave_value> tmp (argc-1); |
|
178 |
2495
|
179 // Skip program name in argv. |
3933
|
180 int i = argc; |
|
181 while (--i > 0) |
|
182 tmp(i-1) = octave_value (*(argv+i)); |
1411
|
183 |
4587
|
184 args = Cell (tmp, argc-1, 1); |
1355
|
185 } |
1907
|
186 |
4587
|
187 bind_builtin_constant ("argv", args, true, true); |
1355
|
188 } |
|
189 |
1792
|
190 static void |
|
191 initialize_pathsearch (void) |
|
192 { |
|
193 // This may seem odd, but doing it this way means that we don't have |
|
194 // to modify the kpathsea library... |
|
195 |
3523
|
196 std::string odb = octave_env::getenv ("OCTAVE_DB_PATH"); |
3141
|
197 |
|
198 // For backward compatibility. |
1792
|
199 |
2926
|
200 if (odb.empty ()) |
3141
|
201 odb = octave_env::getenv ("OCTAVE_DB_DIR"); |
1792
|
202 |
3141
|
203 if (odb.empty ()) |
4101
|
204 odb = Vdata_dir + file_ops::dir_sep_str + "octave:" |
|
205 + Vlibexec_dir + file_ops::dir_sep_str + "octave"; |
1792
|
206 } |
|
207 |
581
|
208 // Initialize by reading startup files. |
|
209 |
1
|
210 static void |
|
211 execute_startup_files (void) |
|
212 { |
2985
|
213 unwind_protect::begin_frame ("execute_startup_files"); |
315
|
214 |
1651
|
215 // XXX FIXME XXX -- need to make it possible to set this in startup |
|
216 // files. |
1588
|
217 |
3019
|
218 unwind_protect_bool (input_from_startup_file); |
1651
|
219 |
3019
|
220 input_from_startup_file = true; |
315
|
221 |
793
|
222 int verbose = (verbose_flag && ! inhibit_startup_message); |
578
|
223 |
2239
|
224 if (read_site_files) |
1
|
225 { |
2239
|
226 // Execute commands from the site-wide configuration file. |
|
227 // First from the file $(prefix)/lib/octave/site/m/octaverc |
|
228 // (if it exists), then from the file |
3597
|
229 // $(prefix)/share/octave/$(version)/m/octaverc (if it exists). |
1755
|
230 |
2897
|
231 parse_and_execute (Vlocal_site_defaults_file, verbose); |
1755
|
232 |
2897
|
233 parse_and_execute (Vsite_defaults_file, verbose); |
1
|
234 } |
|
235 |
2239
|
236 if (read_init_files) |
|
237 { |
2512
|
238 // Try to execute commands from $HOME/$OCTAVE_INITFILE and |
|
239 // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set, .octaverc |
|
240 // is assumed. |
2239
|
241 |
4804
|
242 bool home_rc_already_executed = false; |
2512
|
243 |
3523
|
244 std::string initfile = octave_env::getenv ("OCTAVE_INITFILE"); |
2512
|
245 |
2926
|
246 if (initfile.empty ()) |
2512
|
247 initfile = ".octaverc"; |
|
248 |
3523
|
249 std::string home_dir = octave_env::get_home_directory (); |
2926
|
250 |
4804
|
251 std::string home_rc = octave_env::make_absolute (initfile, home_dir); |
|
252 |
|
253 std::string local_rc; |
2239
|
254 |
2926
|
255 if (! home_dir.empty ()) |
2239
|
256 { |
2897
|
257 parse_and_execute (home_rc, verbose); |
2239
|
258 |
|
259 // Names alone are not enough. |
|
260 |
|
261 file_stat fs_home_rc (home_rc); |
|
262 |
|
263 if (fs_home_rc) |
|
264 { |
4804
|
265 // We want to check for curr_dir after executing home_rc |
|
266 // because doing that may change the working directory. |
|
267 |
|
268 std::string curr_dir = octave_env::getcwd (); |
|
269 |
|
270 local_rc = octave_env::make_absolute (initfile, curr_dir); |
|
271 |
2512
|
272 file_stat fs_dot_rc (local_rc); |
2239
|
273 |
|
274 if (fs_dot_rc && fs_home_rc.ino () == fs_dot_rc.ino ()) |
4804
|
275 home_rc_already_executed = true; |
2239
|
276 } |
|
277 } |
|
278 |
|
279 if (! home_rc_already_executed) |
4804
|
280 { |
|
281 if (local_rc.empty ()) |
|
282 { |
|
283 std::string curr_dir = octave_env::getcwd (); |
|
284 |
|
285 local_rc = octave_env::make_absolute (initfile, curr_dir); |
|
286 } |
|
287 |
|
288 parse_and_execute (local_rc, verbose); |
|
289 } |
2239
|
290 } |
315
|
291 |
2985
|
292 unwind_protect::run_frame ("execute_startup_files"); |
1
|
293 } |
|
294 |
581
|
295 // Usage message with extra help. |
|
296 |
1
|
297 static void |
|
298 verbose_usage (void) |
|
299 { |
3922
|
300 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY "\n\ |
1613
|
301 \n\ |
|
302 Usage: octave [options]\n\ |
|
303 \n\ |
|
304 Options:\n\ |
1119
|
305 \n\ |
3180
|
306 --debug, -d Enter parser debugging mode.\n\ |
|
307 --echo-commands, -x Echo commands as they are executed.\n\ |
1613
|
308 --exec-path PATH Set path for executing subprograms.\n\ |
4356
|
309 --funcall FUNC Call Octave function FUNC with no arguments.\n\ |
3180
|
310 --help, -h, -? Print short help message and exit.\n\ |
1613
|
311 --info-file FILE Use top-level info file FILE.\n\ |
|
312 --info-program PROGRAM Use PROGRAM for reading info files.\n\ |
3180
|
313 --interactive, -i Force interactive behavior.\n\ |
|
314 --no-history, -H Don't save commands to the history list\n\ |
2470
|
315 --no-init-file Don't read the ~/.octaverc or .octaverc files.\n\ |
2212
|
316 --no-line-editing Don't use readline for command-line editing.\n\ |
2470
|
317 --no-site-file Don't read the site-wide octaverc file.\n\ |
3238
|
318 --norc, -f Don't read any initialization files.\n\ |
3180
|
319 --path PATH, -p PATH Set initial LOADPATH to PATH.\n\ |
|
320 --silent, -q Don't print message at startup.\n\ |
1613
|
321 --traditional Set compatibility variables.\n\ |
3180
|
322 --verbose, -V Enable verbose output in some cases.\n\ |
|
323 --version, -v Print version number and exit.\n\ |
1119
|
324 \n\ |
1613
|
325 FILE Execute commands from FILE.\n\ |
4829
|
326 \n" |
|
327 OCTAVE_WWW_STATEMENT "\n\ |
4356
|
328 \n" |
|
329 OCTAVE_CONTRIB_STATEMENT "\n\ |
|
330 \n" |
|
331 OCTAVE_BUGS_STATEMENT "\n"; |
285
|
332 |
613
|
333 exit (0); |
1
|
334 } |
|
335 |
581
|
336 // Terse usage messsage. |
|
337 |
1
|
338 static void |
|
339 usage (void) |
|
340 { |
3531
|
341 std::cerr << "usage: " << usage_string << "\n"; |
1
|
342 exit (1); |
|
343 } |
|
344 |
|
345 static void |
|
346 print_version_and_exit (void) |
|
347 { |
3922
|
348 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS "\n"; |
1
|
349 exit (0); |
|
350 } |
|
351 |
721
|
352 static void |
|
353 initialize_error_handlers () |
|
354 { |
|
355 set_liboctave_error_handler (error); |
3325
|
356 set_liboctave_warning_handler (warning); |
721
|
357 } |
|
358 |
1410
|
359 // What happens on --traditional. |
|
360 |
|
361 static void |
|
362 maximum_braindamage (void) |
|
363 { |
|
364 bind_builtin_variable ("PS1", ">> "); |
|
365 bind_builtin_variable ("PS2", ""); |
4324
|
366 bind_builtin_variable ("beep_on_error", true); |
|
367 bind_builtin_variable ("crash_dumps_octave_core", false); |
1410
|
368 bind_builtin_variable ("default_save_format", "mat-binary"); |
4324
|
369 bind_builtin_variable ("fixed_point_format", true); |
|
370 bind_builtin_variable ("page_screen_output", false); |
|
371 bind_builtin_variable ("print_empty_dimensions", false); |
|
372 bind_builtin_variable ("warn_function_name_clash", false); |
4476
|
373 bind_builtin_variable ("warn_matlab_incompatible", true); |
1410
|
374 } |
|
375 |
581
|
376 // You guessed it. |
|
377 |
1
|
378 int |
4368
|
379 octave_main (int argc, char **argv, int embedded) |
1
|
380 { |
3019
|
381 octave_env::set_program_name (argv[0]); |
|
382 |
2205
|
383 // The order of these calls is important. The call to |
2926
|
384 // install_defaults must come before install_builtins because |
3019
|
385 // default variable values must be available for the variables to be |
2205
|
386 // installed, and the call to install_builtins must come before the |
|
387 // options are processed because some command line options override |
|
388 // defaults by calling bind_builtin_variable. |
721
|
389 |
1
|
390 sysdep_init (); |
|
391 |
4159
|
392 // The idea here is to force xerbla to be referenced so that we will |
|
393 // link to our own version instead of the one provided by the BLAS |
|
394 // library. But octave_NaN should never be -1, so we should never |
|
395 // actually call xerbla. |
|
396 |
|
397 if (octave_NaN == -1) |
|
398 F77_FUNC (xerbla, XERBLA) ("octave", 13, 6L); |
|
399 |
721
|
400 initialize_error_handlers (); |
223
|
401 |
2926
|
402 install_defaults (); |
1
|
403 |
1792
|
404 initialize_pathsearch (); |
1744
|
405 |
4368
|
406 if (! embedded) |
|
407 install_signal_handlers (); |
2205
|
408 |
|
409 initialize_file_io (); |
|
410 |
2375
|
411 initialize_symbol_tables (); |
|
412 |
|
413 install_types (); |
|
414 |
|
415 install_ops (); |
2205
|
416 |
|
417 install_builtins (); |
|
418 |
1817
|
419 prog_args args (argc, argv, short_opts, long_opts); |
|
420 |
139
|
421 int optc; |
1817
|
422 while ((optc = args.getopt ()) != EOF) |
1
|
423 { |
139
|
424 switch (optc) |
1
|
425 { |
3180
|
426 case 'H': |
4324
|
427 bind_builtin_variable ("saving_history", false); |
3180
|
428 break; |
|
429 |
793
|
430 case 'V': |
2239
|
431 verbose_flag = true; |
793
|
432 break; |
|
433 |
1
|
434 case 'd': |
4753
|
435 // This is the same as yydebug in parse.y. |
|
436 octave_debug++; |
1
|
437 break; |
777
|
438 |
1
|
439 case 'f': |
2239
|
440 read_init_files = false; |
|
441 read_site_files = false; |
1
|
442 break; |
777
|
443 |
1
|
444 case 'h': |
|
445 case '?': |
|
446 verbose_usage (); |
|
447 break; |
777
|
448 |
1
|
449 case 'i': |
3019
|
450 forced_interactive = true; |
1
|
451 break; |
777
|
452 |
1
|
453 case 'p': |
1817
|
454 if (args.optarg ()) |
2205
|
455 bind_builtin_variable ("LOADPATH", args.optarg ()); |
1
|
456 break; |
777
|
457 |
1
|
458 case 'q': |
2239
|
459 inhibit_startup_message = true; |
1
|
460 break; |
777
|
461 |
1
|
462 case 'x': |
2205
|
463 { |
|
464 double tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_CMD_LINE); |
|
465 bind_builtin_variable ("echo_executing_commands", tmp); |
|
466 } |
1
|
467 break; |
777
|
468 |
1
|
469 case 'v': |
|
470 print_version_and_exit (); |
|
471 break; |
777
|
472 |
1613
|
473 case EXEC_PATH_OPTION: |
1817
|
474 if (args.optarg ()) |
2205
|
475 bind_builtin_variable ("EXEC_PATH", args.optarg ()); |
1613
|
476 break; |
|
477 |
4356
|
478 case FUNCALL_OPTION: |
|
479 if (args.optarg ()) |
|
480 fun_to_call = args.optarg (); |
|
481 break; |
|
482 |
186
|
483 case INFO_FILE_OPTION: |
1817
|
484 if (args.optarg ()) |
2205
|
485 bind_builtin_variable ("INFO_FILE", args.optarg ()); |
186
|
486 break; |
777
|
487 |
1613
|
488 case INFO_PROG_OPTION: |
1817
|
489 if (args.optarg ()) |
2205
|
490 bind_builtin_variable ("INFO_PROGRAM", args.optarg ()); |
1613
|
491 break; |
|
492 |
2239
|
493 case NO_INIT_FILE_OPTION: |
|
494 read_init_files = false; |
|
495 break; |
|
496 |
1821
|
497 case NO_LINE_EDITING_OPTION: |
3019
|
498 line_editing = false; |
2239
|
499 break; |
|
500 |
|
501 case NO_SITE_FILE_OPTION: |
|
502 read_site_files = 0; |
1821
|
503 break; |
|
504 |
1410
|
505 case TRADITIONAL_OPTION: |
2239
|
506 traditional = true; |
1410
|
507 break; |
|
508 |
1
|
509 default: |
|
510 usage (); |
|
511 break; |
|
512 } |
|
513 } |
|
514 |
1651
|
515 #if defined (HAVE_ATEXIT) || defined (HAVE_ON_EXIT) |
2077
|
516 // Make sure we clean up when we exit. Also allow users to register |
|
517 // functions. If we don't have atexit or on_exit, we're going to |
|
518 // leave some junk files around if we exit abnormally. |
|
519 |
|
520 atexit (do_octave_atexit); |
318
|
521 #endif |
1
|
522 |
1358
|
523 // These can come after command line args since none of them set any |
|
524 // defaults that might be changed by command line options. |
581
|
525 |
2926
|
526 initialize_command_input (); |
315
|
527 |
578
|
528 if (! inhibit_startup_message) |
3538
|
529 std::cout << OCTAVE_STARTUP_MESSAGE "\n" << std::endl; |
578
|
530 |
1410
|
531 if (traditional) |
|
532 maximum_braindamage (); |
|
533 |
4217
|
534 octave_interpreter_ready = true; |
|
535 |
|
536 execute_default_pkg_add_files (); |
|
537 |
2239
|
538 execute_startup_files (); |
1651
|
539 |
2926
|
540 command_history::read (false); |
1
|
541 |
578
|
542 if (! inhibit_startup_message && reading_startup_message_printed) |
3538
|
543 std::cout << std::endl; |
578
|
544 |
1358
|
545 // Avoid counting commands executed from startup files. |
|
546 |
2926
|
547 command_editor::reset_current_command_number (1); |
1
|
548 |
1358
|
549 // If there is an extra argument, see if it names a file to read. |
|
550 // Additional arguments are taken as command line options for the |
|
551 // script. |
1
|
552 |
1817
|
553 int last_arg_idx = args.optind (); |
3019
|
554 |
1817
|
555 int remaining_args = argc - last_arg_idx; |
3019
|
556 |
1355
|
557 if (remaining_args > 0) |
149
|
558 { |
3019
|
559 reading_script_file = true; |
|
560 |
1817
|
561 curr_fcn_file_name = argv[last_arg_idx]; |
1608
|
562 curr_fcn_file_full_name = curr_fcn_file_name; |
1411
|
563 |
984
|
564 FILE *infile = get_input_from_file (curr_fcn_file_name); |
1411
|
565 |
529
|
566 if (infile) |
287
|
567 { |
3019
|
568 input_from_command_line_file = true; |
1516
|
569 |
1411
|
570 bind_builtin_variable ("program_invocation_name", |
|
571 curr_fcn_file_name); |
|
572 |
4101
|
573 size_t pos |
|
574 = curr_fcn_file_name.find_last_of (file_ops::dir_sep_chars); |
1755
|
575 |
3523
|
576 std::string tmp = (pos != NPOS) |
1755
|
577 ? curr_fcn_file_name.substr (pos+1) : curr_fcn_file_name; |
1411
|
578 |
|
579 bind_builtin_variable ("program_name", tmp); |
|
580 |
1817
|
581 intern_argv (remaining_args, argv+last_arg_idx); |
1411
|
582 |
2926
|
583 command_editor::blink_matching_paren (false); |
|
584 |
287
|
585 switch_to_buffer (create_buffer (infile)); |
|
586 } |
529
|
587 else |
|
588 clean_up_and_exit (1); |
1
|
589 } |
|
590 else |
|
591 { |
1355
|
592 // Is input coming from a terminal? If so, we are probably |
|
593 // interactive. |
1
|
594 |
4368
|
595 interactive = (! embedded |
|
596 && isatty (fileno (stdin)) && isatty (fileno (stdout))); |
1355
|
597 |
|
598 intern_argv (argc, argv); |
|
599 |
4368
|
600 if (! embedded) |
|
601 switch_to_buffer (create_buffer (get_input_from_stdin ())); |
1
|
602 } |
|
603 |
1358
|
604 // Force input to be echoed if not really interactive, but the user |
|
605 // has forced interactive behavior. |
1
|
606 |
1907
|
607 if (! interactive && forced_interactive) |
287
|
608 { |
2926
|
609 command_editor::blink_matching_paren (false); |
1588
|
610 |
|
611 // XXX FIXME XXX -- is this the right thing to do? |
|
612 |
4233
|
613 bind_builtin_variable ("echo_executing_commands", ECHO_CMD_LINE); |
287
|
614 } |
1
|
615 |
1410
|
616 if (! interactive) |
3019
|
617 line_editing = false; |
1
|
618 |
4368
|
619 if (embedded) |
|
620 return 1; |
|
621 |
4356
|
622 int retval = main_loop (fun_to_call); |
1
|
623 |
1005
|
624 if (retval == 1 && ! error_state) |
|
625 retval = 0; |
|
626 |
1
|
627 clean_up_and_exit (retval); |
4247
|
628 |
|
629 return 0; |
1
|
630 } |
|
631 |
560
|
632 /* |
1
|
633 ;;; Local Variables: *** |
|
634 ;;; mode: C++ *** |
|
635 ;;; End: *** |
|
636 */ |