changeset 159:abc5f0a0785f

[project @ 1993-10-14 00:38:27 by jwe] (identifier_exists): Only return non-zero if the name has a definition.
author jwe
date Thu, 14 Oct 1993 00:38:27 +0000
parents 76926a2d39a6
children be50d501b2a7
files src/variables.cc
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/variables.cc	Wed Oct 13 20:48:27 1993 +0000
+++ b/src/variables.cc	Thu Oct 14 00:38:27 1993 +0000
@@ -369,28 +369,31 @@
 int
 identifier_exists (char *name)
 {
-  int status = 0;
+  symbol_record *sr = curr_sym_tab->lookup (name, 0, 0);
+  if (sr == (symbol_record *) NULL)
+    sr = global_sym_tab->lookup (name, 0, 0);
 
-  if (curr_sym_tab->lookup (name, 0, 0) != (symbol_record *) NULL
-      || global_sym_tab->lookup (name, 0, 0) != (symbol_record *) NULL)
-    status = 1;
+  if (sr != (symbol_record *) NULL && sr->is_variable ())
+    return 1;
+  else if (sr != (symbol_record *) NULL && sr->is_function ())
+    return 2;
   else
     {
       char *path = m_file_in_path (name);
       if (path != (char *) NULL)
 	{
 	  delete [] path;
-	  status = 2;
+	  return 2;
 	}
       else
 	{
 	  struct stat buf;
 	  if (stat (name, &buf) == 0 && S_ISREG (buf.st_mode))
-	    status = 2;
+	    return 2;
 	}
 	
     }
-  return status;
+  return 0;
 }
 
 /*