Mercurial > hg > octave-lyh
comparison src/variables.cc @ 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 | 174de3807b61 |
children | e2c950dd96d2 |
comparison
equal
deleted
inserted
replaced
158:76926a2d39a6 | 159:abc5f0a0785f |
---|---|
367 * See if the identifier is in scope. | 367 * See if the identifier is in scope. |
368 */ | 368 */ |
369 int | 369 int |
370 identifier_exists (char *name) | 370 identifier_exists (char *name) |
371 { | 371 { |
372 int status = 0; | 372 symbol_record *sr = curr_sym_tab->lookup (name, 0, 0); |
373 | 373 if (sr == (symbol_record *) NULL) |
374 if (curr_sym_tab->lookup (name, 0, 0) != (symbol_record *) NULL | 374 sr = global_sym_tab->lookup (name, 0, 0); |
375 || global_sym_tab->lookup (name, 0, 0) != (symbol_record *) NULL) | 375 |
376 status = 1; | 376 if (sr != (symbol_record *) NULL && sr->is_variable ()) |
377 return 1; | |
378 else if (sr != (symbol_record *) NULL && sr->is_function ()) | |
379 return 2; | |
377 else | 380 else |
378 { | 381 { |
379 char *path = m_file_in_path (name); | 382 char *path = m_file_in_path (name); |
380 if (path != (char *) NULL) | 383 if (path != (char *) NULL) |
381 { | 384 { |
382 delete [] path; | 385 delete [] path; |
383 status = 2; | 386 return 2; |
384 } | 387 } |
385 else | 388 else |
386 { | 389 { |
387 struct stat buf; | 390 struct stat buf; |
388 if (stat (name, &buf) == 0 && S_ISREG (buf.st_mode)) | 391 if (stat (name, &buf) == 0 && S_ISREG (buf.st_mode)) |
389 status = 2; | 392 return 2; |
390 } | 393 } |
391 | 394 |
392 } | 395 } |
393 return status; | 396 return 0; |
394 } | 397 } |
395 | 398 |
396 /* | 399 /* |
397 * Is this tree_constant a valid function? | 400 * Is this tree_constant a valid function? |
398 */ | 401 */ |