# HG changeset patch # User jwe # Date 848427381 0 # Node ID 0e5eb97cb1378c06e31b3c809d2ca068382936a5 # Parent d21eb2d6e135d80ee12246264fe16a0882b755d2 [project @ 1996-11-19 18:13:48 by jwe] diff --git a/src/help.cc b/src/help.cc --- a/src/help.cc +++ b/src/help.cc @@ -724,9 +724,6 @@ begin_unwind_frame ("Ftype"); - unwind_protect_str (Vps4); - Vps4 = ""; - int argc = args.length () + 1; string_vector argv = args.make_argv ("type"); @@ -738,12 +735,25 @@ { // XXX FIXME XXX -- we should really use getopt () - int quiet = 0; - int idx = 1; - if (argv[idx] == "-q") + bool quiet = false; + bool pr_orig_txt = true; + + int idx; + + for (idx = 1; idx < argc; idx++) { - quiet = 1; - idx++; + if (argv[idx] == "-q" || argv[idx] == "-quiet") + quiet = true; + else if (argv[idx] == "-t" || argv[idx] == "-transformed") + pr_orig_txt = false; + else + break; + } + + if (idx == argc) + { + print_usage ("type"); + return retval; } ostrstream output_buf; @@ -775,7 +785,7 @@ if (nargout == 0 && ! quiet) output_buf << argv[i] << " is a user-defined function\n"; - tree_print_code tpc (output_buf); + tree_print_code tpc (output_buf, "", pr_orig_txt); defn->accept (tpc); } @@ -831,7 +841,7 @@ } if (! tmp->is_map ()) { - tree_print_code tpc (output_buf); + tree_print_code tpc (output_buf, "", pr_orig_txt); tmp->accept (tpc); @@ -860,8 +870,6 @@ else print_usage ("type"); - run_unwind_frame ("Ftype"); - return retval; } diff --git a/src/pt-const.cc b/src/pt-const.cc --- a/src/pt-const.cc +++ b/src/pt-const.cc @@ -76,6 +76,15 @@ { } +void +tree_constant::print (ostream& os, bool pr_as_read_syntax, bool pr_orig_text) +{ + if (pr_orig_text && ! orig_text.empty ()) + os << orig_text; + else + val.print (os, pr_as_read_syntax); +} + octave_value tree_constant::eval (bool print_result) { @@ -115,6 +124,18 @@ } void +tree_constant::stash_original_text (const string& s) +{ + orig_text = s; +} + +string +tree_constant::original_text (void) const +{ + return orig_text; +} + +void tree_constant::accept (tree_walker& tw) { tw.visit_constant (*this); diff --git a/src/pt-const.h b/src/pt-const.h --- a/src/pt-const.h +++ b/src/pt-const.h @@ -281,12 +281,12 @@ Octave_map map_value (void) const; octave_value lookup_map_element (const string& ref, - bool insert = false, - bool silent = false); + bool insert = false, + bool silent = false); octave_value lookup_map_element (SLList& list, - bool insert = false, - bool silent = false); + bool insert = false, + bool silent = false); ColumnVector vector_value (bool /* frc_str_conv */ = false, bool /* frc_vec_conv */ = false) const @@ -325,8 +325,8 @@ void decrement (void) { val.decrement (); } void print (void); - void print (ostream& os, bool pr_as_read_syntax = false) - { val.print (os, pr_as_read_syntax); } + void print (ostream& os, bool pr_as_read_syntax = false, + bool pr_orig_txt = true); void print_with_name (const string& name, bool print_padding = true); void print_with_name (ostream& os, const string& name, @@ -339,9 +339,9 @@ // Store the original text corresponding to this constant for later // pretty printing. - void stash_original_text (const string& s) { orig_text = s; } + void stash_original_text (const string& s); - string original_text (void) { return orig_text; } + string original_text (void) const; void accept (tree_walker& tw); diff --git a/src/pt-exp.h b/src/pt-exp.h --- a/src/pt-exp.h +++ b/src/pt-exp.h @@ -391,8 +391,6 @@ delete op_increment; } - bool is_range_constant (void) const; - tree_colon_expression *chain (tree_expression *t); octave_value eval (bool print);