changeset 1288:4acabfbdd381

[project @ 1995-04-28 20:23:04 by jwe]
author jwe
date Fri, 28 Apr 1995 20:31:13 +0000
parents 3f49454bc68c
children db2ff37920d2
files src/help.cc src/input.cc src/lex.l src/octave.cc src/token.cc src/token.h
diffstat 6 files changed, 61 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/help.cc
+++ b/src/help.cc
@@ -773,17 +773,14 @@
 
 	  char *id = strsave (*argv);
 	  char *elts = 0;
-	  char *ptr = strchr (id, '.');
-	  if (ptr)
+	  if (id[strlen (id) - 1] != '.')
 	    {
-	      *ptr = '\0';
-
-	      elts = ptr + 1;
-	      ptr = strrchr (elts, '.');
+	      char *ptr = strchr (id, '.');
 	      if (ptr)
-		*ptr = '\0';
-	      else
-		elts = 0;
+		{
+		  *ptr = '\0';
+		  elts = ptr + 1;
+		}
 	    }
 
 	  symbol_record *sym_rec = lookup_by_name (id, 0);
@@ -811,7 +808,7 @@
 		{
 		  tree_fvc *defn = sym_rec->def ();
 
-		  assert (defn->is_constant ());
+		  assert (defn && defn->is_constant ());
 
 		  tree_constant *tmp = (tree_constant *) defn;
 
@@ -820,23 +817,34 @@
 		    {
 		      if (elts && *elts)
 			{
-			  tree_constant ult;
-			  ult = tmp->lookup_map_element (elts, 0, 1);
+			  tree_constant ult =
+			    tmp->lookup_map_element (elts, 0, 1);
 
 			  if (! ult.is_defined ())
 			    var_ok = 0;			    
 			}
 		    }
-		  
+
 		  if (nargout == 0 && ! quiet)
 		    {
-		      output_buf << *argv;
-		      if (sym_rec->is_user_variable ())
-			output_buf << " is a user-defined variable\n";
+		      if (var_ok)
+			{
+			  output_buf << *argv;
+			  if (sym_rec->is_user_variable ())
+			    output_buf << " is a user-defined variable\n";
+			  else
+			    output_buf << " is a built-in variable\n";
+			}
 		      else
-			output_buf << " is a built-in variable\n";
+			{
+			  if (elts && *elts)
+			    output_buf << "type: structure `" << id
+			      << "' has no member `" << elts << "'\n";
+			  else
+			    output_buf << "type: `" << id
+			      << "' has unknown type!";
+			}
 		    }
-
 		  if (! tmp->is_map ())
 		    {
 		      tmp->print_code (output_buf);
@@ -862,7 +870,7 @@
 	{
 	  char *s = output_buf.str ();
 	  retval = s;
-	  delete s;
+	  delete [] s;
 	}
     }
   else
--- a/src/input.cc
+++ b/src/input.cc
@@ -460,7 +460,6 @@
     }
 }
 
-
 // Use GNU readline to get an input line and store it in the history
 // list.
 
@@ -638,6 +637,8 @@
 {
   char **names = 0;
 
+  assert (text);
+
   char *id = strsave (text);
   char *ptr = strchr (id, '.');
   *ptr = '\0';
@@ -653,6 +654,7 @@
   ptr = strrchr (prefix, '.');
   *ptr = '\0';
 
+  delete [] hint;
   hint = strsave (ptr + 1);
 
   symbol_record *sr = curr_sym_tab->lookup (id, 0, 0);
@@ -703,15 +705,9 @@
   if (text && *text && *text != '.')
     {
       if (strrchr (text, '.'))
-	{
-	  names = generate_struct_completions (text, prefix, hint);
-	}
+	names = generate_struct_completions (text, prefix, hint);
       else
-	{
-	  hint = strsave (text);
-
-	  names = make_name_list ();
-	}
+	names = make_name_list ();
     }
 
   return names;
@@ -722,6 +718,8 @@
 {
   int retval = 0;
 
+  assert (nm);
+
   char *id = strsave (nm);
   char *elts = 0;
   char *ptr = strchr (id, '.');
@@ -795,17 +793,16 @@
       prefix = 0;
 
       delete [] hint;
-      prefix = 0;
+      hint = strsave (text);
 
       name_list = generate_possible_completions (text, prefix, hint);
 
       prefix_len = 0;
       if (prefix)
-	prefix_len = strlen (prefix) + 1;
+	prefix_len = strlen (prefix);
 	
-      hint_len = 0;
-      if (hint)
-	hint_len = strlen (hint);
+      assert (hint);
+      hint_len = strlen (hint);
 
       matches = 0;
       if (name_list)
@@ -825,8 +822,8 @@
 	  list_index++;
 	  if (strncmp (name, hint, hint_len) == 0)
 	    {
-	      int len = 3 + prefix_len + strlen (name);
-	      char *buf = xmalloc (len);
+	      int len = 2 + prefix_len + strlen (name);
+	      char *buf = (char *) xmalloc (len);
 
 	      if (prefix)
 		{
--- a/src/lex.l
+++ b/src/lex.l
@@ -186,9 +186,7 @@
 
 <HELP_FCN>[^ \t\n]*{S}*	|
 <TEXT_FCN>[^ \t\n\;\,]*{S}* {
-    static char *tok = 0;
-    delete [] tok;
-    tok = strip_trailing_whitespace (yytext);
+    char *tok = strip_trailing_whitespace (yytext);
     TOK_PUSH_AND_RETURN (tok, TEXT);
   }
 
@@ -403,9 +401,7 @@
 %}
 
 {IDENT}{S}* {
-    static char *tok = 0;
-    delete [] tok;
-    tok = strip_trailing_whitespace (yytext);
+    char *tok = strip_trailing_whitespace (yytext);
     int c = yytext[yyleng-1];
     int cont_is_spc = eat_continuation ();
     int spc_gobbled = (cont_is_spc || c == ' ' || c == '\t');
--- a/src/octave.cc
+++ b/src/octave.cc
@@ -70,6 +70,7 @@
 #include "procstream.h"
 #include "unwind-prot.h"
 #include "octave-hist.h"
+#include "pathsearch.h"
 #include "builtins.h"
 #include "version.h"
 #include "file-io.h"
@@ -262,6 +263,8 @@
   raw_prog_name = strsave (name);
   prog_name = strsave ("octave");
 
+  kpse_set_progname (name);
+
   load_path = default_path ();
 
   info_file = default_info_file ();
--- a/src/token.cc
+++ b/src/token.cc
@@ -27,6 +27,7 @@
 
 #include <assert.h>
 
+#include "error.h"
 #include "token.h"
 #include "utils.h"
 #include "symtab.h"
@@ -54,7 +55,7 @@
   column_num = c;
   type_tag = double_token;
   num = d;
-  orig_text = strsave (s);
+  orig_text = 0; // strsave (s);
 }
 
 token::token (end_tok_type t, int l, int c)
@@ -144,6 +145,17 @@
   return orig_text;
 }
 
+token::token (const token& tok)
+{
+  panic_impossible ();
+}
+
+token&
+operator = (const token& tok)
+{
+  panic_impossible ();
+}
+
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/src/token.h
+++ b/src/token.h
@@ -78,6 +78,9 @@
   char *text_rep (void);
 
 private:
+  token (const token& tok);
+  token& operator = (const token& tok);
+
   int line_num;
   int column_num;
   token_type type_tag;