diff src/help.cc @ 1288:4acabfbdd381

[project @ 1995-04-28 20:23:04 by jwe]
author jwe
date Fri, 28 Apr 1995 20:31:13 +0000
parents fcdf6c5d0302
children 34295bf6aac6
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