changeset 186:7a647cf4850c

[project @ 1993-10-25 23:15:50 by jwe]
author jwe
date Mon, 25 Oct 1993 23:15:50 +0000
parents 2c7bce68e3d8
children 24d1f404fe43
files src/lex.l src/octave.cc src/symtab.cc src/symtab.h src/t-builtins.cc src/toplev.h src/user-prefs.cc src/user-prefs.h src/utils.cc src/utils.h
diffstat 10 files changed, 121 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/src/lex.l	Mon Oct 25 23:01:07 1993 +0000
+++ b/src/lex.l	Mon Oct 25 23:15:50 1993 +0000
@@ -1017,11 +1017,13 @@
   if (curr_sym_tab == top_level_sym_tab)
     {
       symbol_record *lsr = curr_sym_tab->lookup (name, 0, 0);
-      if (lsr != (symbol_record *) NULL)
+      if (lsr != (symbol_record *) NULL && lsr->is_defined ())
 	return lsr;
 
       symbol_record *gsr = global_sym_tab->lookup (name, 0, 0);
-      if (gsr != (symbol_record *) NULL && ! (looping || iffing))
+      if (gsr != (symbol_record *) NULL
+	  && ! (looping || iffing)
+	  && (gsr->is_defined () || gsr->is_forced_global ()))
 	return gsr;
     }
 
--- a/src/octave.cc	Mon Oct 25 23:01:07 1993 +0000
+++ b/src/octave.cc	Mon Oct 25 23:15:50 1993 +0000
@@ -98,6 +98,9 @@
 // Load path specified on command line.
 char *load_path = (char *) NULL;
 
+// Name of the info file specified on command line.
+char *info_file = (char *) NULL;
+
 // If nonzero, don't do fancy line editing.
 int no_line_editing = 0;
 
@@ -122,19 +125,21 @@
 // Usage message
 static const char *usage_string = 
   "octave [-?dfhiqvx] [-p path] [--debug] [--help] [--interactive]\n\
-         [--norc] [--path path] [--quiet] [--version] [--echo-commands]\n\
-         [file]";
+         [--info-file file] [--norc] [--path path] [--quiet] [--version]\n\
+         [--echo-commands] [file]";
 
 // This is here so that it\'s more likely that the usage message and
 // the real set of options will agree.
 static const char *short_opts = "?dfhip:qvx";
 
 // Long options.
+#define INFO_FILE_OPTION 1
 static struct option long_opts[] =
   {
     { "debug", 0, 0, 'd' },
     { "help", 0, 0, 'h' },
     { "interactive", 0, 0, 'i' },
+    { "info-file", 1, 0, INFO_FILE_OPTION },
     { "norc", 0, 0, 'f' },
     { "path", 1, 0, 'p' },
     { "quiet", 0, 0, 'q' },
@@ -172,6 +177,8 @@
   prog_name = strsave ("octave");
 
   load_path = default_path ();
+
+  info_file = default_info_file ();
 }
 
 void
@@ -384,6 +391,10 @@
 	case 'v':
 	  print_version_and_exit ();
 	  break;
+	case INFO_FILE_OPTION:
+	  if (optarg != (char *) NULL)
+	    info_file = strsave (optarg);
+	  break;
 	default:
 	  usage ();
 	  break;
--- a/src/symtab.cc	Mon Oct 25 23:01:07 1993 +0000
+++ b/src/symtab.cc	Mon Oct 25 23:15:50 1993 +0000
@@ -425,22 +425,33 @@
   return status;
 }
 
-void
+int
 symbol_record::clear_visible (void)
 {
-  if (var != (symbol_def *) NULL && var->lifespan != symbol_def::eternal)
+  int status = 0;
+
+  if (is_defined ())
     {
-      if (--var->count <= 0)
-	delete var;
-      var = (symbol_def *) NULL;
-      forced_global = 0;
+      if (var != (symbol_def *) NULL
+	  && var->lifespan != symbol_def::eternal)
+	{
+	  if (--var->count <= 0)
+	    delete var;
+	  var = (symbol_def *) NULL;
+	  forced_global = 0;
+	  status = 1;
+	}
+      else if (fcn != (symbol_def *) NULL
+	       && fcn->lifespan != symbol_def::eternal)
+	{
+	  if (--fcn->count <= 0)
+	    delete fcn;
+	  fcn = (symbol_def *) NULL;
+	  status = 1;
+	}
     }
-  else if (fcn != (symbol_def *) NULL && fcn->lifespan != symbol_def::eternal)
-    {
-      if (--fcn->count <= 0)
-	delete fcn;
-      fcn = (symbol_def *) NULL;
-    }
+
+  return status;
 }
 
 void
@@ -583,9 +594,8 @@
     {
       if (strcmp (curr->name (), nm) == 0)
 	{
-	  curr->clear_visible ();
-
-	  return 1;
+	  if (curr->clear_visible ())
+	    return 1;
 	}
       prev = curr;
       curr = curr->next ();
--- a/src/symtab.h	Mon Oct 25 23:01:07 1993 +0000
+++ b/src/symtab.h	Mon Oct 25 23:15:50 1993 +0000
@@ -154,7 +154,7 @@
 
   int save (ostream& os, int mark_as_global = 0);
 
-  void clear_visible (void);
+  int clear_visible (void);
   void clear_all (void);
 
   void mark_as_formal_parameter (void);
@@ -177,7 +177,7 @@
   sv_Function sv_fcn;
   symbol_record *next_elem;
 
-  symbol_record (const symbol_record& s);
+  symbol_record (const symbol_record& s) { assert (0); }
   symbol_record& operator = (const symbol_record& s);
 };
 
--- a/src/t-builtins.cc	Mon Oct 25 23:01:07 1993 +0000
+++ b/src/t-builtins.cc	Mon Oct 25 23:15:50 1993 +0000
@@ -423,7 +423,7 @@
 {
   int status = 0;
 
-  char *directory_name = strsave (DEFAULT_INFO_FILE);
+  char *directory_name = strsave (user_pref.info_file);
   char *temp = filename_non_directory (directory_name);
 
   if (temp != directory_name)
@@ -434,47 +434,49 @@
 
   delete [] directory_name;
 
-  NODE *initial_node = info_get_node (DEFAULT_INFO_FILE, (char *)NULL);
+  NODE *initial_node = info_get_node (user_pref.info_file, (char *)NULL);
 
   if (! initial_node)
     {
       warning ("can't find info file!\n");
-      return status;
+      status = -1;
     }
-
-  initialize_info_session (initial_node, 0);
-
-  if (force || index_entry_exists (windows, string))
+  else
     {
-      terminal_clear_screen ();
+      initialize_info_session (initial_node, 0);
 
-      terminal_prep_terminal ();
+      if (force || index_entry_exists (windows, string))
+	{
+	  terminal_clear_screen ();
 
-      display_update_display (windows);
+	  terminal_prep_terminal ();
 
-      info_last_executed_command = (VFunction *)NULL;
+	  display_update_display (windows);
 
-      if (! force)
-	do_info_index_search (windows, 0, string);
+	  info_last_executed_command = (VFunction *)NULL;
+
+	  if (! force)
+	    do_info_index_search (windows, 0, string);
 
-      char *format = replace_in_documentation
-	("Type \"\\[quit]\" to quit, \"\\[get-help-window]\" for help.");
+	  char *format = replace_in_documentation
+	    ("Type \"\\[quit]\" to quit, \"\\[get-help-window]\" for help.");
 
-      window_message_in_echo_area (format);
+	  window_message_in_echo_area (format);
 
-      info_read_and_dispatch ();
+	  info_read_and_dispatch ();
 
-      terminal_goto_xy (0, screenheight - 1);
+	  terminal_goto_xy (0, screenheight - 1);
 
-      terminal_clear_to_eol ();
+	  terminal_clear_to_eol ();
 
-      terminal_unprep_terminal ();
+	  terminal_unprep_terminal ();
 
-      status = 1;
+	  status = 1;
+	}
+
+      finish_info_session (initial_node, 0);
     }
 
-  finish_info_session (initial_node, 0);
-
   return status;
 }
 
--- a/src/toplev.h	Mon Oct 25 23:01:07 1993 +0000
+++ b/src/toplev.h	Mon Oct 25 23:15:50 1993 +0000
@@ -53,6 +53,9 @@
 // Load path specified on command line.
 extern char *load_path;
 
+// Name of the info file specified on command line.
+extern char *info_file;
+
 // If nonzero, don't do fancy line editing.
 extern int no_line_editing;
 
--- a/src/user-prefs.cc	Mon Oct 25 23:01:07 1993 +0000
+++ b/src/user-prefs.cc	Mon Oct 25 23:15:50 1993 +0000
@@ -397,6 +397,26 @@
 }
 
 int
+sv_info_file (void)
+{
+  int status = 0;
+
+  char *s = octave_string_variable ("INFO_FILE");
+  if (s != (char *) NULL)
+    {
+      delete [] user_pref.info_file;
+      user_pref.info_file = s;
+    }
+  else
+    {
+      warning ("invalid value specified for INFO_FILE");
+      status = -1;
+    }
+
+  return status;
+}
+
+int
 sv_ps1 (void)
 {
   int status = 0;
--- a/src/user-prefs.h	Mon Oct 25 23:01:07 1993 +0000
+++ b/src/user-prefs.h	Mon Oct 25 23:15:50 1993 +0000
@@ -52,6 +52,7 @@
   int output_precision;
 
   char *loadpath;
+  char *info_file;
   char *ps1;
   char *ps2;
   char *pwd;
@@ -84,6 +85,7 @@
 extern int set_output_precision (void);
 
 extern int sv_loadpath (void);
+extern int sv_info_file (void);
 extern int sv_pager_binary (void);
 extern int sv_ps1 (void);
 extern int sv_ps2 (void);
--- a/src/utils.cc	Mon Oct 25 23:01:07 1993 +0000
+++ b/src/utils.cc	Mon Oct 25 23:15:50 1993 +0000
@@ -410,6 +410,16 @@
   return ol;
 }
 
+static char *
+octave_info_dir (void)
+{
+  static char *oi = (char *) NULL;
+  delete [] oi;
+  char *oh = octave_home ();
+  oi = strconcat (oh, "/info/");
+  return oi;
+}
+
 char *
 default_path (void)
 {
@@ -427,6 +437,22 @@
 }
 
 char *
+default_info_file (void)
+{
+  static char *info_file_string = (char *) NULL;
+  delete [] info_file_string;
+  char *oct_info_file = getenv ("OCTAVE_INFO_FILE");
+  if (oct_info_file != (char *) NULL)
+    info_file_string = strsave (oct_info_file);
+  else
+    {
+      char *infodir = octave_info_dir ();
+      info_file_string = strconcat (infodir, "octave.info");
+    }
+  return info_file_string;
+}
+
+char *
 get_site_defaults (void)
 {
   static char *sd = (char *) NULL;
--- a/src/utils.h	Mon Oct 25 23:01:07 1993 +0000
+++ b/src/utils.h	Mon Oct 25 23:15:50 1993 +0000
@@ -42,6 +42,7 @@
 extern int kbhit (void);
 extern char **pathstring_to_vector (char *);
 extern char *default_path (void);
+extern char *default_info_file (void);
 extern char *get_site_defaults (void);
 extern char *default_pager (void);
 extern char *file_in_path (const char *, const char *);