changeset 1907:8c6cea97eb80

[project @ 1996-02-10 01:12:46 by jwe]
author jwe
date Sat, 10 Feb 1996 01:17:59 +0000
parents fb2b7ebf77e4
children 435e692e73fd
files src/dynamic-ld.cc src/dynamic-ld.h src/octave.cc src/pt-fvc.cc src/toplev.cc src/toplev.h src/user-prefs.cc src/variables.cc
diffstat 8 files changed, 80 insertions(+), 97 deletions(-) [+]
line wrap: on
line diff
--- a/src/dynamic-ld.cc
+++ b/src/dynamic-ld.cc
@@ -66,15 +66,6 @@
 // function, the struct, and the helper function.
 
 static string
-mangle_octave_builtin_name (const string& name)
-{
-  string retval ("F");
-  retval.append (name);
-  retval.append ("__FRC13Octave_objecti");
-  return retval;
-}
-
-static string
 mangle_octave_oct_file_name (const string& name)
 {
   string retval ("FS");
@@ -173,26 +164,6 @@
 }
 #endif
 
-Octave_builtin_fcn
-#if defined (WITH_DYNAMIC_LINKING)
-load_octave_builtin (const string& name)
-#else
-load_octave_builtin (const string&)
-#endif
-{
-  Octave_builtin_fcn retval = 0;
-
-#if defined (WITH_DYNAMIC_LINKING)
-
-  string mangled_name = mangle_octave_builtin_name (name);
-
-  retval = (Octave_builtin_fcn) resolve_octave_reference (mangled_name);
-
-#endif
-
-  return retval;
-}
-
 int
 load_octave_oct_file (const string& name)
 {
@@ -202,7 +173,7 @@
 
   string oct_file = oct_file_in_path (name);
 
-  if (oct_file.empty ())
+  if (! oct_file.empty ())
     {
       string mangled_name = mangle_octave_oct_file_name (name);
 
@@ -216,7 +187,7 @@
 
 	  if (s)
 	    {
-	      install_builtin_function (s);
+	      install_builtin_function (*s);
 	      retval = 1;
 	    }
 	}
--- a/src/dynamic-ld.h
+++ b/src/dynamic-ld.h
@@ -28,8 +28,6 @@
 
 typedef Octave_object (*Octave_builtin_fcn)(const Octave_object&, int);
 
-extern Octave_builtin_fcn load_octave_builtin (const string& name);
-
 extern int load_octave_oct_file (const string& name);
 
 extern void init_dynamic_linker (void);
--- a/src/octave.cc
+++ b/src/octave.cc
@@ -28,7 +28,6 @@
 #endif
 
 #include <cassert>
-#include <csetjmp>
 #include <csignal>
 #include <cstdlib>
 #include <cstring>
@@ -46,6 +45,7 @@
 #include <pwd.h>
 
 #include "lo-error.h"
+#include "str-vec.h"
 
 #include "builtins.h"
 #include "defaults.h"
@@ -92,8 +92,8 @@
 // This is from readline's paren.c:
 extern int rl_blink_matching_paren;
 
-// Top level context (?)
-jmp_buf toplevel;
+// The command-line options.
+static string_vector octave_argv;
 
 // Nonzero means we read ~/.octaverc and ./.octaverc.
 // (--norc; --ignore-init-file; -f)
@@ -166,13 +166,15 @@
 	    max_len = tmp_len;
 	}
 
-      octave_argv.resize (argc-1, max_len, 0);
+      octave_argv.resize (argc-1);
 
       for (int i = 1; i < argc; i++)
-	octave_argv.insert (argv[i], i-1, 0);
+	octave_argv[i-1] = argv[i];
 
       bind_builtin_variable ("argv", octave_argv, 1, 1, 0);
     }
+
+  bind_builtin_variable ("nargin", (double) argc-1, 1, 1, 0);
 }
 
 // Initialize some global variables for later use.
@@ -575,7 +577,7 @@
   // Force input to be echoed if not really interactive, but the user
   // has forced interactive behavior.
 
-  if (!interactive && forced_interactive)
+  if (! interactive && forced_interactive)
     {
       rl_blink_matching_paren = 0;
 
@@ -588,38 +590,7 @@
   if (! interactive)
     using_readline = 0;
 
-  // Allow the user to interrupt us without exiting.
-
-  if (setjmp (toplevel) != 0)
-    {
-      raw_mode (0);
-
-      cout << "\n";
-    }
-
-  can_interrupt = 1;
-
-  catch_interrupts ();
-
-  // The big loop.
-
-  int retval;
-  do
-    {
-      curr_sym_tab = top_level_sym_tab;
-
-      reset_parser ();
-
-      retval = yyparse ();
-
-      if (retval == 0 && global_command)
-	{
-	  global_command->eval (1);
-	  delete global_command;
-	  current_command_number++;
-	}
-    }
-  while (retval == 0);
+  int retval = main_loop ();
 
   if (retval == 1 && ! error_state)
     retval = 0;
--- a/src/pt-fvc.cc
+++ b/src/pt-fvc.cc
@@ -643,8 +643,6 @@
 
   if (fcn)
     {
-    eval_fcn:
-
       Octave_object args;
       Octave_object tmp = (*fcn) (args, 0);
       if (tmp.length () > 0)
@@ -655,14 +653,7 @@
       ::error ("%s: too few arguments", my_name.c_str ());
     }
   else
-    {
-      fcn = load_octave_builtin (my_name);
-
-      if (fcn)
-	goto eval_fcn;
-      else
-	::error ("unable to load builtin function %s", my_name.c_str ());
-    }
+    panic_impossible ();
 
   return retval;
 }
@@ -766,8 +757,6 @@
 
   if (fcn)
     {
-    eval_fcn:
-
       if (any_arg_is_magic_colon (args))
 	::error ("invalid use of colon in function argument list");
       else
@@ -791,14 +780,7 @@
 	}
     }
   else
-    {
-      fcn = load_octave_builtin (my_name);
-
-      if (fcn)
-	goto eval_fcn;
-      else
-	::error ("unable to load builtin function %s", my_name.c_str ());
-    }
+    panic_impossible ();
 
   return retval;
 }
--- a/src/toplev.cc
+++ b/src/toplev.cc
@@ -135,13 +135,13 @@
 // Nonzero means input is coming from startup file.
 int input_from_startup_file = 0;
 
-// The command-line options.
-charMatrix octave_argv;
-
 // Nonzero means that input is coming from a file that was named on
 // the command line.
 int input_from_command_line_file = 1;
 
+// Top level context (?)
+jmp_buf toplevel;
+
 void
 parse_and_execute (FILE *f, int print)
 {
@@ -223,6 +223,45 @@
   run_unwind_frame ("parse_and_execute_2");
 }
 
+int
+main_loop (void)
+{
+  // Allow the user to interrupt us without exiting.
+
+  if (setjmp (toplevel) != 0)
+    {
+      raw_mode (0);
+
+      cout << "\n";
+    }
+
+  can_interrupt = 1;
+
+  catch_interrupts ();
+
+  // The big loop.
+
+  int retval;
+  do
+    {
+      curr_sym_tab = top_level_sym_tab;
+
+      reset_parser ();
+
+      retval = yyparse ();
+
+      if (retval == 0 && global_command)
+	{
+	  global_command->eval (1);
+	  delete global_command;
+	  current_command_number++;
+	}
+    }
+  while (retval == 0);
+
+  return retval;
+}
+
 DEFUN ("source", Fsource, Ssource, 10,
   "source (FILE)\n\
 \n\
--- a/src/toplev.h
+++ b/src/toplev.h
@@ -44,6 +44,8 @@
 extern tree_constant eval_string (const string&, int print,
 				  int& parse_status);
 
+extern int main_loop (void);
+
 // argv[0] for this program.
 extern string raw_prog_name;
 
@@ -98,9 +100,6 @@
 // Nonzero means input is coming from startup file.
 extern int input_from_startup_file;
 
-// The command-line options.
-extern charMatrix octave_argv;
-
 // Nonzero means that input is coming from a file that was named on
 // the command line.
 extern int input_from_command_line_file;
--- a/src/user-prefs.cc
+++ b/src/user-prefs.cc
@@ -29,6 +29,8 @@
 #include <cstdlib>
 #include <cstring>
 
+#include "Array-flags.h"
+
 #include "error.h"
 #include "gripes.h"
 #include "mappers.h"
@@ -188,6 +190,8 @@
   user_pref.do_fortran_indexing =
     check_preference ("do_fortran_indexing"); 
 
+  liboctave_dfi_flag = user_pref.do_fortran_indexing;
+
   return 0;
 }
 
@@ -336,6 +340,8 @@
   user_pref.prefer_column_vectors =
     check_preference ("prefer_column_vectors");
 
+  liboctave_pcv_flag = user_pref.prefer_column_vectors;
+
   return 0;
 }
 
@@ -352,6 +358,8 @@
   user_pref.prefer_zero_one_indexing =
     check_preference ("prefer_zero_one_indexing");
 
+  liboctave_pzo_flag = user_pref.prefer_zero_one_indexing;
+
   return 0;
 }
 
@@ -417,6 +425,8 @@
   user_pref.resize_on_range_error =
     check_preference ("resize_on_range_error");
 
+  liboctave_rre_flag = user_pref.resize_on_range_error;
+
   return 0;
 }
 
--- a/src/variables.cc
+++ b/src/variables.cc
@@ -672,6 +672,12 @@
   return status;
 }
 
+static void
+restore_command_history (void *)
+{
+  octave_command_history.ignore_entries (! user_pref.saving_history);
+}
+
 static int
 parse_fcn_file (int exec_script, const string& ff)
 {
@@ -707,6 +713,13 @@
 
       if (is_function_file (ffile))
 	{
+	  // XXX FIXME XXX -- we shouldn't need both the
+	  // octave_command_history object and the
+	  // user_pref.saving_history variable...
+	  octave_command_history.ignore_entries ();
+
+	  add_unwind_protect (restore_command_history, 0);
+
 	  unwind_protect_int (user_pref.echo_executing_commands);
 	  unwind_protect_int (user_pref.saving_history);
 	  unwind_protect_int (reading_fcn_file);