changeset 3016:f512c16826d1

[project @ 1997-06-03 03:16:13 by jwe]
author jwe
date Tue, 03 Jun 1997 03:21:08 +0000
parents 2e114e914b77
children d7edf1442471
files src/ChangeLog src/help.cc src/help.h src/input.cc src/oct-hist.cc src/oct-hist.h src/parse.y src/variables.cc src/variables.h
diffstat 9 files changed, 322 insertions(+), 218 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,109 @@
+Mon Jun  2 00:40:10 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* variables.h (Octave_builtin_fcn): Delete typedef.
+
+	* help.cc (make_name_list): Move here from variables.cc.
+	(keyword_help, names): Now static.
+	(struct help_list): Move declaration here from help.h.
+
+	* oct-hist.cc (Vhistory_file, Vhistory_size, Vsaving_history):
+	Move here from variables.cc.
+	(symbols_of_oct_hist): New function.
+
+	* version.h: Protect against multiple inclusion.
+
+	* defun.cc (check_version): New function.
+	* defun-int.h (DEFINE_FUN_INSTALLER_FUN): Use it.
+
+	* help.h, help.cc (additional_help_message): Now extern.
+	(operator_help): Now static. 
+
+	* defun.cc (print_usage): Move here from help.cc
+	* DLD-FUNCTIONS/*.cc, data.cc, dirfns.cc, file-io.cc, input.cc,
+	load-save.cc, octave.cc, ov-list.cc, ov-typeinfo.cc,
+	ov-usr-fcn.cc, pager.cc, pr-output.cc, pt-plot.cc, strfns.cc,
+	syscalls.cc, sysdep.cc, utils.cc, toplev.cc:
+	Don't include help.h.
+
+	* TEMPLATE-INST/Array-sym.cc: New file.
+
+	* load-save.cc (do_load): Don't use ostream::form.
+	* pr-output.cc: Likewise, at least where it is easy to do so.
+	* oct-stream.cc: Ditto.
+
+	* symtab.h (symbol_record::symbol_def::rows): New function.
+	(symbol_record::symbol_def::columns): Ditto.
+	(symbol_record::symbol_def::type_name): Ditto.
+	(symbol_record::rows): Ditto
+	(symbol_record::columns): Ditto
+	(symbol_record::type_name): Ditto
+
+	* symtab.h, symtab.cc (symbol_record::hides_fcn): New function.
+	(symbol_record::hides_builtin): Ditto.
+	(symbol_record::print_symbol_info_line): Ditto.
+	(symbol_table::long_list): Delete.
+	(symbol_table::symbol_list): New function.
+	(symbol_table::maybe_list): Delete argc arg.
+	(symbol_table::name_list): Rename from symbol_table::list.
+	Change all callers.
+
+	* symtab.h, symtab.cc (class symbol_record_info): Delete.
+
+	* symtab.cc (matches_patterns): Use vector form of glob_match.
+
+Sun Jun  1 14:04:26 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* pt-check.h, pt-check.cc: New files, for semantic checking of
+	parse trees.
+
+	* symtab.h (class symbol_def): Now nested in symbol_record class.
+	(enum TYPE): Move from symbol_def to symbol record class.  Change
+	all uses.
+
+	* symtab.h, symtab.cc (symbol_table::maybe_list): New function,
+	from variables.cc.  Change all uses.
+
+	* pt-idx.h (tree_identifier::lvalue_ok): New function.
+	* pt-id.h (tree_index_expression::lvalue_ok): Likewise.
+	* pt-indir.h (tree_indirect_ref::lvalue_ok): Likewise.
+
+	* pt-pr-code.h, pt-pr-code.cc (tree_print_code::visit_oct_obj): Delete.
+	* pt-walk.h (tree_walker::visit_oct_obj): Delete declaration.
+
+	* lex.h (class lexical_feedback): Delete maybe_screwed_again.
+	* lex.l (lexical_feedback::init): Don't set it.
+
+Fri May 30 16:07:22 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* mappers.cc: Include <cfloat> here.
+
+Tue May 27 10:08:43 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* toplev.cc (eval_string): Don't index tmp if it is empty.
+
+Sat May 24 00:18:41 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* load-save.cc (valid_identifier): Move here and make static.
+	* symtab.h, symtab.cc (valid_identifier): Delete declaration and
+	definition.
+
+Fri May 23 22:54:28 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* symtab.h (symbol_def::symbol_def): Use initializer list instead
+	of calling init_state.
+	(symbol_def::init_state): Delete.
+
+	* symtab.cc (symbol_table::print_stats): New function.
+	* variables.cc (F__dump_symtab_info__): New function.
+
+	* symtab.h, symtab.cc (symbol_table::hash): Return masked value.
+	(symbol_table::table_size): New data member.
+	(symbol_table::symbol_table): Set size of table in constructor.
+	(HASH_TABLE_SIZE): Replace uses with table_size.
+	(HASH_MASK): Delete.
+	* variables.cc (initialize_symbol_tables): Set top-level and
+	global symbol table sizes here.
+
 Thu May 22 13:32:55 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* dynamic-ld.cc (octave_shl_load_dynamic_loader::resolve_reference): 
--- a/src/help.cc
+++ b/src/help.cc
@@ -77,6 +77,14 @@
 // functions.
 static bool Vsuppress_verbose_help_message;
 
+// XXX FIXME XXX -- maybe this should use string instead of char*.
+
+struct help_list
+{
+  const char *name;
+  const char *help;
+};
+
 static help_list operators[] =
 {
   { "!",
@@ -287,7 +295,7 @@
 
 // Return a copy of the operator or keyword names.
 
-string_vector
+static string_vector
 names (help_list *lst, int& count)
 {
   string_vector retval;
@@ -321,12 +329,69 @@
   return operators;
 }
 
-help_list *
+static help_list *
 keyword_help (void)
 {
   return keywords;
 }
 
+// It's not likely that this does the right thing now.  XXX FIXME XXX
+
+string_vector
+make_name_list (void)
+{
+  int key_len = 0;
+  int glb_len = 0;
+  int top_len = 0;
+  int lcl_len = 0;
+
+  string_vector key;
+  string_vector glb;
+  string_vector top;
+  string_vector lcl;
+  string_vector ffl;
+
+  // Each of these functions returns a new vector of pointers to new
+  // strings.
+
+  key = names (keyword_help (), key_len);
+
+  glb = global_sym_tab->name_list (glb_len);
+
+  top = top_level_sym_tab->name_list (top_len);
+
+  if (top_level_sym_tab != curr_sym_tab)
+    lcl = curr_sym_tab->name_list (lcl_len);
+
+  ffl = octave_fcn_file_name_cache::list_no_suffix ();
+  int ffl_len = ffl.length ();
+
+  int total_len = key_len + glb_len + top_len + lcl_len + ffl_len;
+
+  string_vector list (total_len);
+
+  // Put all the symbols in one big list.
+
+  int j = 0;
+  int i = 0;
+  for (i = 0; i < key_len; i++)
+    list[j++] = key[i];
+
+  for (i = 0; i < glb_len; i++)
+    list[j++] = glb[i];
+
+  for (i = 0; i < top_len; i++)
+    list[j++] = top[i];
+
+  for (i = 0; i < lcl_len; i++)
+    list[j++] = lcl[i];
+
+  for (i = 0; i < ffl_len; i++)
+    list[j++] = ffl[i];
+
+  return list;
+}
+
 #if defined (USE_GNU_INFO)
 
 void
--- a/src/help.h
+++ b/src/help.h
@@ -29,17 +29,7 @@
 
 class string_vector;
 
-// XXX FIXME XXX -- should probably use string, not char*.
-
-struct help_list
-{
-  const char *name;
-  const char *help;
-};
-
-extern string_vector names (help_list *l, int& count);
-
-extern help_list *keyword_help (void);
+extern string_vector make_name_list (void);
 
 extern void additional_help_message (ostream&);
 
--- a/src/input.cc
+++ b/src/input.cc
@@ -51,6 +51,7 @@
 #include "dirfns.h"
 #include "error.h"
 #include "gripes.h"
+#include "help.h"
 #include "input.h"
 #include "oct-map.h"
 #include "oct-hist.h"
--- a/src/oct-hist.cc
+++ b/src/oct-hist.cc
@@ -52,12 +52,14 @@
 
 #include "cmd-hist.h"
 #include "file-ops.h"
+#include "lo-mappers.h"
 #include "oct-env.h"
 #include "str-vec.h"
 
 #include <defaults.h>
 #include "defun.h"
 #include "error.h"
+#include "gripes.h"
 #include "input.h"
 #include "oct-hist.h"
 #include "oct-obj.h"
@@ -72,6 +74,15 @@
 // Nonzero means input is coming from temporary history file.
 int input_from_tmp_history_file = 0;
 
+// Where history is saved.
+static string Vhistory_file;
+
+// The number of lines to keep in the history file.
+static int Vhistory_size;
+
+// TRUE if we are saving history.
+int Vsaving_history;
+
 // Get some default values, possibly reading them from the
 // environment.
 
@@ -574,6 +585,71 @@
   return retval;
 }
 
+static int
+history_size (void)
+{
+  double val;
+  if (builtin_real_scalar_variable ("history_size", val)
+      && ! xisnan (val))
+    {
+      int ival = NINT (val);
+      if (ival >= 0 && ival == val)
+	{
+	  Vhistory_size = ival;
+	  command_history::set_size (ival);
+	  return 0;
+	}
+    }
+  gripe_invalid_value_specified ("history_size");
+  return -1;
+}
+
+static int
+history_file (void)
+{
+  int status = 0;
+
+  string s = builtin_string_variable ("history_file");
+
+  if (s.empty ())
+    {
+      gripe_invalid_value_specified ("history_file");
+      status = -1;
+    }
+  else
+    {
+      Vhistory_file = s;
+      command_history::set_file (file_ops::tilde_expand (s));
+    }
+
+  return status;
+}
+
+static int
+saving_history (void)
+{
+  Vsaving_history = check_preference ("saving_history");
+
+  command_history::ignore_entries (! Vsaving_history);
+
+  return 0;
+}
+
+void
+symbols_of_oct_hist (void)
+{
+  DEFVAR (history_file, default_history_file (), 0, history_file,
+    "name of command history file");
+
+  double tmp_hist_size = default_history_size ();
+
+  DEFVAR (history_size, tmp_hist_size, 0, history_size,
+    "number of commands to save in the history list");
+
+  DEFVAR (saving_history, 1.0, 0, saving_history,
+    "save command history");
+}
+
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/src/oct-hist.h
+++ b/src/oct-hist.h
@@ -33,6 +33,9 @@
 // Nonzero means input is coming from temporary history file.
 extern int input_from_tmp_history_file;
 
+// TRUE if we are saving history.
+extern int Vsaving_history;
+
 #endif
 
 /*
--- a/src/parse.y
+++ b/src/parse.y
@@ -2180,7 +2180,7 @@
   else
     panic_impossible ();
 
-  id->define (fcn, symbol_def::USER_FUNCTION);
+  id->define (fcn, symbol_record::USER_FUNCTION);
 
   id->document (help_buf);
 
--- a/src/variables.cc
+++ b/src/variables.cc
@@ -86,19 +86,10 @@
 // more than one state can be active at once.
 int Vecho_executing_commands;
 
-// Where history is saved.
-static string Vhistory_file;
-
-// The number of lines to keep in the history file.
-static int Vhistory_size;
-
 // Should Octave always check to see if function files have changed
 // since they were last compiled?
 static int Vignore_function_time_stamp;
 
-// TRUE if we are saving history.
-static int Vsaving_history;
-
 // Symbol table for symbols at the top level.
 symbol_table *top_level_sym_tab = 0;
 
@@ -1133,69 +1124,6 @@
     }
 }
 
-// Help stuff.  Shouldn't this go in help.cc?
-
-// It's not likely that this does the right thing now.  XXX FIXME XXX
-
-string_vector
-make_name_list (void)
-{
-  int key_len = 0;
-  int glb_len = 0;
-  int top_len = 0;
-  int lcl_len = 0;
-
-  string_vector key;
-  string_vector glb;
-  string_vector top;
-  string_vector lcl;
-  string_vector ffl;
-
-  // Each of these functions returns a new vector of pointers to new
-  // strings.
-
-  key = names (keyword_help (), key_len);
-
-  glb = global_sym_tab->name_list (glb_len);
-
-  top = top_level_sym_tab->name_list (top_len);
-
-  if (top_level_sym_tab != curr_sym_tab)
-    lcl = curr_sym_tab->name_list (lcl_len);
-
-  ffl = octave_fcn_file_name_cache::list_no_suffix ();
-  int ffl_len = ffl.length ();
-
-  int total_len = key_len + glb_len + top_len + lcl_len + ffl_len;
-
-  string_vector list (total_len);
-
-  // Put all the symbols in one big list.  Only copy pointers, not the
-  // strings they point to, then only delete the original array of
-  // pointers, and not the strings they point to.
-
-  int j = 0;
-  int i = 0;
-  for (i = 0; i < key_len; i++)
-    list[j++] = key[i];
-
-  for (i = 0; i < glb_len; i++)
-    list[j++] = glb[i];
-
-  for (i = 0; i < top_len; i++)
-    list[j++] = top[i];
-
-  for (i = 0; i < lcl_len; i++)
-    list[j++] = lcl[i];
-
-  for (i = 0; i < ffl_len; i++)
-    list[j++] = ffl[i];
-
-  return list;
-}
-
-// List variable names.
-
 DEFUN (document, args, ,
   "document (NAME, STRING)\n\
 \n\
@@ -1463,134 +1391,6 @@
   sr->document (help);
 }
 
-// XXX FIXME XXX -- some of these should do their own checking to be
-// able to provide more meaningful warning or error messages.
-
-static int
-echo_executing_commands (void)
-{
-  Vecho_executing_commands = check_preference ("echo_executing_commands"); 
-
-  return 0;
-}
-
-static int
-history_size (void)
-{
-  double val;
-  if (builtin_real_scalar_variable ("history_size", val)
-      && ! xisnan (val))
-    {
-      int ival = NINT (val);
-      if (ival >= 0 && ival == val)
-	{
-	  Vhistory_size = ival;
-	  command_history::set_size (ival);
-	  return 0;
-	}
-    }
-  gripe_invalid_value_specified ("history_size");
-  return -1;
-}
-
-static int
-history_file (void)
-{
-  int status = 0;
-
-  string s = builtin_string_variable ("history_file");
-
-  if (s.empty ())
-    {
-      gripe_invalid_value_specified ("history_file");
-      status = -1;
-    }
-  else
-    {
-      Vhistory_file = s;
-      command_history::set_file (file_ops::tilde_expand (s));
-    }
-
-  return status;
-}
-
-static int
-ignore_function_time_stamp (void)
-{
-  int pref = 0;
-
-  string val = builtin_string_variable ("ignore_function_time_stamp");
-
-  if (! val.empty ())
-    {
-      if (val.compare ("all", 0, 3) == 0)
-	pref = 2;
-      if (val.compare ("system", 0, 6) == 0)
-	pref = 1;
-    }
-
-  Vignore_function_time_stamp = pref;
-
-  return 0;
-}
-
-static int
-saving_history (void)
-{
-  Vsaving_history = check_preference ("saving_history");
-
-  command_history::ignore_entries (! Vsaving_history);
-
-  return 0;
-}
-
-// XXX FIXME XXX -- there still may be better places for some of these
-// to be defined.
-
-void
-symbols_of_variables (void)
-{
-  DEFVAR (ans, , 0, 0,
-    "");
-
-  DEFCONST (argv, , 0, 0,
-    "the command line arguments this program was invoked with");
-
-  DEFVAR (echo_executing_commands, static_cast<double> (ECHO_OFF), 0,
-	  echo_executing_commands,
-    "echo commands as they are executed");
-
-  DEFCONST (error_text, "", 0, 0,
-    "the text of error messages that would have been printed in the\n\
-body of the most recent unwind_protect statement or the TRY part of\n\
-the most recent eval() command.  Outside of unwind_protect and\n\
-eval(), or if no error has ocurred within them, the value of\n\
-__error_text__ is guaranteed to be the empty string.");
-
-  DEFVAR (history_file, default_history_file (), 0, history_file,
-    "name of command history file");
-
-  double tmp_hist_size = default_history_size ();
-
-  DEFVAR (history_size, tmp_hist_size, 0, history_size,
-    "number of commands to save in the history list");
-
-  DEFVAR (ignore_function_time_stamp, "system", 0, ignore_function_time_stamp,
-    "don't check to see if function files have changed since they were\n\
-  last compiled.  Possible values are \"system\" and \"all\"");
-
-  DEFCONST (program_invocation_name,
-	    octave_env::get_program_invocation_name (), 0, 0,
-    "the full name of the current program or script, including the\n\
-directory specification");
-
-  DEFCONST (program_name, octave_env::get_program_name (), 0, 0,
-    "the name of the current program or script");
-
-  DEFVAR (saving_history, 1.0, 0, saving_history,
-    "save command history");
-}
-
 // Deleting names from the symbol tables.
 
 DEFUN_TEXT (clear, args, ,
@@ -1735,6 +1535,73 @@
   return retval;
 }
 
+// XXX FIXME XXX -- some of these should do their own checking to be
+// able to provide more meaningful warning or error messages.
+
+static int
+echo_executing_commands (void)
+{
+  Vecho_executing_commands = check_preference ("echo_executing_commands"); 
+
+  return 0;
+}
+
+static int
+ignore_function_time_stamp (void)
+{
+  int pref = 0;
+
+  string val = builtin_string_variable ("ignore_function_time_stamp");
+
+  if (! val.empty ())
+    {
+      if (val.compare ("all", 0, 3) == 0)
+	pref = 2;
+      if (val.compare ("system", 0, 6) == 0)
+	pref = 1;
+    }
+
+  Vignore_function_time_stamp = pref;
+
+  return 0;
+}
+
+// XXX FIXME XXX -- there still may be better places for some of these
+// to be defined.
+
+void
+symbols_of_variables (void)
+{
+  DEFVAR (ans, , 0, 0,
+    "");
+
+  DEFCONST (argv, , 0, 0,
+    "the command line arguments this program was invoked with");
+
+  DEFVAR (echo_executing_commands, static_cast<double> (ECHO_OFF), 0,
+	  echo_executing_commands,
+    "echo commands as they are executed");
+
+  DEFCONST (error_text, "", 0, 0,
+    "the text of error messages that would have been printed in the\n\
+body of the most recent unwind_protect statement or the TRY part of\n\
+the most recent eval() command.  Outside of unwind_protect and\n\
+eval(), or if no error has ocurred within them, the value of\n\
+__error_text__ is guaranteed to be the empty string.");
+
+  DEFVAR (ignore_function_time_stamp, "system", 0, ignore_function_time_stamp,
+    "don't check to see if function files have changed since they were\n\
+  last compiled.  Possible values are \"system\" and \"all\"");
+
+  DEFCONST (program_invocation_name,
+	    octave_env::get_program_invocation_name (), 0, 0,
+    "the full name of the current program or script, including the\n\
+directory specification");
+
+  DEFCONST (program_name, octave_env::get_program_name (), 0, 0,
+    "the name of the current program or script");
+}
+
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/src/variables.h
+++ b/src/variables.h
@@ -41,8 +41,6 @@
 #include "ov-builtin.h"
 #include "symtab.h"
 
-typedef octave_value_list (*Octave_builtin_fcn)(const octave_value_list&, int);
-
 extern void initialize_symbol_tables (void);
 
 extern bool lookup (symbol_record *s, bool exec_script = true);
@@ -90,8 +88,6 @@
 generate_struct_completions (const string& text, string& prefix,
 			     string& hint);
 
-extern string_vector make_name_list (void);
-
 extern void bind_ans (const octave_value& val, bool print);
 
 extern void bind_global_error_variable (void);