Mercurial > hg > octave-nkf
comparison src/octave.cc @ 581:bc813f5eb025
[project @ 1994-08-07 01:02:15 by jwe]
author | jwe |
---|---|
date | Sun, 07 Aug 1994 01:02:15 +0000 |
parents | d169be9237fb |
children | 14b2a186a5c0 |
comparison
equal
deleted
inserted
replaced
580:b0204e676508 | 581:bc813f5eb025 |
---|---|
169 { "version", 0, 0, 'v' }, | 169 { "version", 0, 0, 'v' }, |
170 { "echo-commands", 0, 0, 'x' }, | 170 { "echo-commands", 0, 0, 'x' }, |
171 { 0, 0, 0, 0 } | 171 { 0, 0, 0, 0 } |
172 }; | 172 }; |
173 | 173 |
174 /* | 174 // Initialize some global variables for later use. |
175 * Initialize some global variables for later use. | 175 |
176 */ | |
177 static void | 176 static void |
178 initialize_globals (char *name) | 177 initialize_globals (char *name) |
179 { | 178 { |
180 struct passwd *entry = getpwuid (getuid ()); | 179 struct passwd *entry = getpwuid (getuid ()); |
181 if (entry) | 180 if (entry) |
279 } | 278 } |
280 | 279 |
281 run_unwind_frame ("parse_and_execute_2"); | 280 run_unwind_frame ("parse_and_execute_2"); |
282 } | 281 } |
283 | 282 |
284 /* | 283 // Initialize by reading startup files. |
285 * Initialize by reading startup files. | 284 |
286 */ | |
287 static void | 285 static void |
288 execute_startup_files (void) | 286 execute_startup_files (void) |
289 { | 287 { |
290 begin_unwind_frame ("execute_startup_files"); | 288 begin_unwind_frame ("execute_startup_files"); |
291 | 289 |
322 parse_and_execute ("./.octaverc", 0, verbose); | 320 parse_and_execute ("./.octaverc", 0, verbose); |
323 | 321 |
324 run_unwind_frame ("execute_startup_files"); | 322 run_unwind_frame ("execute_startup_files"); |
325 } | 323 } |
326 | 324 |
327 /* | 325 // Usage message with extra help. |
328 * Usage message with extra help. | 326 |
329 */ | |
330 static void | 327 static void |
331 verbose_usage (void) | 328 verbose_usage (void) |
332 { | 329 { |
333 cout << "\n" | 330 cout << "\n" |
334 << " Octave, version " << version_string | 331 << " Octave, version " << version_string |
349 << "\n"; | 346 << "\n"; |
350 | 347 |
351 exit (1); | 348 exit (1); |
352 } | 349 } |
353 | 350 |
354 /* | 351 // Terse usage messsage. |
355 * Terse usage messsage. | 352 |
356 */ | |
357 static void | 353 static void |
358 usage (void) | 354 usage (void) |
359 { | 355 { |
360 cerr << "usage: " << usage_string << "\n"; | 356 cerr << "usage: " << usage_string << "\n"; |
361 exit (1); | 357 exit (1); |
362 } | 358 } |
363 | 359 |
364 /* | 360 // Fix up things before exiting. |
365 * Fix up things before exiting. | 361 |
366 */ | |
367 void | 362 void |
368 clean_up_and_exit (int retval) | 363 clean_up_and_exit (int retval) |
369 { | 364 { |
370 raw_mode (0); | 365 raw_mode (0); |
371 | 366 |
372 clean_up_history (); | 367 clean_up_history (); |
373 | 368 |
374 close_plot_stream (); | 369 close_plot_stream (); |
375 | 370 |
371 close_diary_file (); | |
372 | |
376 close_files (); | 373 close_files (); |
377 | 374 |
378 cleanup_tmp_files (); | 375 cleanup_tmp_files (); |
379 | 376 |
380 if (!quitting_gracefully && (interactive || forced_interactive)) | 377 if (!quitting_gracefully && (interactive || forced_interactive)) |
396 { | 393 { |
397 cout << "octave, version " << version_string << "\n"; | 394 cout << "octave, version " << version_string << "\n"; |
398 exit (0); | 395 exit (0); |
399 } | 396 } |
400 | 397 |
401 /* | 398 // You guessed it. |
402 * You guessed it. | 399 |
403 */ | |
404 int | 400 int |
405 main (int argc, char **argv) | 401 main (int argc, char **argv) |
406 { | 402 { |
407 // Allow for system dependent initialization. See sysdep.cc for more | 403 // Allow for system dependent initialization. See sysdep.cc for more |
408 // details. | 404 // details. |
464 // on_exit, we're going to leave some junk files around if we exit | 460 // on_exit, we're going to leave some junk files around if we exit |
465 // abnormally. | 461 // abnormally. |
466 atexit (cleanup_tmp_files); | 462 atexit (cleanup_tmp_files); |
467 #endif | 463 #endif |
468 | 464 |
465 initialize_pager (); | |
466 | |
469 initialize_history (); | 467 initialize_history (); |
470 | 468 |
471 initialize_file_io (); | 469 initialize_file_io (); |
472 | 470 |
473 initialize_symbol_tables (); | 471 initialize_symbol_tables (); |
474 | 472 |
475 install_builtins (); | 473 install_builtins (); |
476 | 474 |
477 initialize_readline (); | 475 initialize_readline (); |
478 | |
479 initialize_pager (); | |
480 | 476 |
481 install_signal_handlers (); | 477 install_signal_handlers (); |
482 | 478 |
483 if (! inhibit_startup_message) | 479 if (! inhibit_startup_message) |
484 cout << "Octave, version " << version_string | 480 cout << "Octave, version " << version_string |
766 print_usage ("eval"); | 762 print_usage ("eval"); |
767 | 763 |
768 return retval; | 764 return retval; |
769 } | 765 } |
770 | 766 |
771 /* | 767 // Execute a shell command. |
772 * Execute a shell command. | 768 |
773 */ | |
774 DEFUN ("shell_cmd", Fshell_cmd, Sshell_cmd, 2, 1, | 769 DEFUN ("shell_cmd", Fshell_cmd, Sshell_cmd, 2, 1, |
775 "shell_cmd (string [, return_output]): execute shell commands") | 770 "shell_cmd (string [, return_output]): execute shell commands") |
776 { | 771 { |
777 Octave_object retval; | 772 Octave_object retval; |
778 | 773 |