# HG changeset patch # User jwe # Date 799010634 0 # Node ID fcdf6c5d03029c046df7cc2e551e8fff767c3ad0 # Parent b01f9577b0dac2c113458e10f699e494b5648bb8 [project @ 1995-04-27 19:21:47 by jwe] diff --git a/src/help.cc b/src/help.cc --- a/src/help.cc +++ b/src/help.cc @@ -771,7 +771,22 @@ if (! *argv || ! **argv) continue; - symbol_record *sym_rec = lookup_by_name (*argv, 0); + char *id = strsave (*argv); + char *elts = 0; + char *ptr = strchr (id, '.'); + if (ptr) + { + *ptr = '\0'; + + elts = ptr + 1; + ptr = strrchr (elts, '.'); + if (ptr) + *ptr = '\0'; + else + elts = 0; + } + + symbol_record *sym_rec = lookup_by_name (id, 0); if (sym_rec) { @@ -791,35 +806,52 @@ output_buf << *argv << " is a builtin text-function\n"; else if (sym_rec->is_builtin_function ()) output_buf << *argv << " is a builtin function\n"; - else if (sym_rec->is_user_variable ()) + else if (sym_rec->is_user_variable () + || sym_rec->is_builtin_variable ()) { tree_fvc *defn = sym_rec->def (); - if (nargout == 0 && ! quiet) - output_buf << *argv << " is a user-defined variable\n"; + assert (defn->is_constant ()); + + tree_constant *tmp = (tree_constant *) defn; - defn->print_code (output_buf); + int var_ok = 1; + if (tmp && tmp->is_map ()) + { + if (elts && *elts) + { + tree_constant ult; + ult = tmp->lookup_map_element (elts, 0, 1); - if (nargout == 0) - output_buf << "\n"; - } - else if (sym_rec->is_builtin_variable ()) - { - tree_fvc *defn = sym_rec->def (); + 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"; + else + output_buf << " is a built-in variable\n"; + } - if (nargout == 0 && ! quiet) - output_buf << *argv << " is a builtin variable\n"; + if (! tmp->is_map ()) + { + tmp->print_code (output_buf); - defn->print_code (output_buf); - - if (nargout == 0) - output_buf << "\n"; + if (nargout == 0) + output_buf << "\n"; + } } else output_buf << "type: `" << *argv << "' has unknown type!\n"; } else output_buf << "type: `" << *argv << "' undefined\n"; + + delete [] id; } output_buf << ends; diff --git a/src/variables.cc b/src/variables.cc --- a/src/variables.cc +++ b/src/variables.cc @@ -1440,11 +1440,15 @@ bind_ans (const tree_constant& val, int print) { static symbol_record *sr = global_sym_tab->lookup ("ans", 1, 0); - static tree_identifier ans_id (sr); + tree_identifier *ans_id = new tree_identifier (sr); tree_constant *tmp = new tree_constant (val); - tree_simple_assignment_expression tmp_ass (&ans_id, tmp, 1, 1); + // XXX FIXME XXX -- making ans_id static, passing its address to + // tree_simple_assignment_expression along with a flag to not delete + // it seems to create a memory leak. Hmm. + + tree_simple_assignment_expression tmp_ass (ans_id, tmp, 0, 1); tmp_ass.eval (print); }