Mercurial > hg > octave-avbm
changeset 4005:fc000ebb19df
[project @ 2002-07-25 21:01:16 by jwe]
author | jwe |
---|---|
date | Thu, 25 Jul 2002 21:01:16 +0000 |
parents | ca854fb51a88 |
children | efac4b97bb09 |
files | src/ChangeLog src/ov.cc src/pt-stmt.cc |
diffstat | 3 files changed, 54 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2002-07-25 John W. Eaton <jwe@bevo.che.wisc.edu> + + * ov.cc (silent_functions, Vsilent_functions): Move here. + (octave_value::print_with_name): Don't print anything if we are + evaluating a function and Vsilent_functions is true. + + * pt-stmt.cc: From here. + (symbols_of_pt_stmt): Delete. + (tree_statement_list::eval): Don't bother with Vsilent_functions here. + 2002-07-24 John W. Eaton <jwe@bevo.che.wisc.edu> * Makefile.in (OPT_HANDLERS): New targets.
--- a/src/ov.cc +++ b/src/ov.cc @@ -59,6 +59,7 @@ #include "error.h" #include "gripes.h" #include "pager.h" +#include "parse.h" #include "pr-output.h" #include "utils.h" #include "variables.h" @@ -67,6 +68,10 @@ // make the grow_size large. DEFINE_OCTAVE_ALLOCATOR2(octave_value, 1024); +// If TRUE, turn off printing of results in functions (as if a +// semicolon has been appended to each statement). +static bool Vsilent_functions; + // If TRUE, allow assignments like // // octave> A(1) = 3; A(2) = 5 @@ -942,15 +947,19 @@ } void -octave_value::print_with_name (std::ostream& output_buf, const std::string& name, +octave_value::print_with_name (std::ostream& output_buf, + const std::string& name, bool print_padding) const { - bool pad_after = print_name_tag (output_buf, name); + if (! (evaluating_function_body && Vsilent_functions)) + { + bool pad_after = print_name_tag (output_buf, name); - print (output_buf); + print (output_buf); - if (print_padding && pad_after) - newline (output_buf); + if (print_padding && pad_after) + newline (output_buf); + } } static void @@ -1608,6 +1617,14 @@ } static int +silent_functions (void) +{ + Vsilent_functions = check_preference ("silent_functions"); + + return 0; +} + +static int struct_levels_to_print (void) { double val; @@ -1721,6 +1738,27 @@ control is returned to the top level. The default value is 1.\n\ @end defvr"); + DEFVAR (silent_functions, 0.0, silent_functions, + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} silent_functions\n\ +If the value of @code{silent_functions} is nonzero, internal output\n\ +from a function is suppressed. Otherwise, the results of expressions\n\ +within a function body that are not terminated with a semicolon will\n\ +have their values printed. The default value is 0.\n\ +\n\ +For example, if the function\n\ +\n\ +@example\n\ +function f ()\n\ + 2 + 2\n\ +endfunction\n\ +@end example\n\ +\n\ +@noindent\n\ +is executed, Octave will either print @samp{ans = 4} or nothing\n\ +depending on the value of @code{silent_functions}.\n\ +@end defvr"); + DEFVAR (struct_levels_to_print, 2.0, struct_levels_to_print, "-*- texinfo -*-\n\ @defvr {Built-in Variable} struct_levels_to_print\n\
--- a/src/pt-stmt.cc +++ b/src/pt-stmt.cc @@ -48,10 +48,6 @@ #include "utils.h" #include "variables.h" -// If TRUE, turn off printing of results in functions (as if a -// semicolon has been appended to each statement). -static bool Vsilent_functions; - // Pointer to the current statement being executed. tree_statement *curr_statement = 0; @@ -160,10 +156,7 @@ if (elt) { - bool silent_flag = - silent ? true : (function_body ? Vsilent_functions : false); - - retval = elt->eval (silent_flag, nargout, function_body); + retval = elt->eval (silent, nargout, function_body); if (error_state) break; @@ -230,39 +223,6 @@ tw.visit_statement_list (*this); } -static int -silent_functions (void) -{ - Vsilent_functions = check_preference ("silent_functions"); - - return 0; -} - -void -symbols_of_pt_stmt (void) -{ - DEFVAR (silent_functions, 0.0, silent_functions, - "-*- texinfo -*-\n\ -@defvr {Built-in Variable} silent_functions\n\ -If the value of @code{silent_functions} is nonzero, internal output\n\ -from a function is suppressed. Otherwise, the results of expressions\n\ -within a function body that are not terminated with a semicolon will\n\ -have their values printed. The default value is 0.\n\ -\n\ -For example, if the function\n\ -\n\ -@example\n\ -function f ()\n\ - 2 + 2\n\ -endfunction\n\ -@end example\n\ -\n\ -@noindent\n\ -is executed, Octave will either print @samp{ans = 4} or nothing\n\ -depending on the value of @code{silent_functions}.\n\ -@end defvr"); -} - /* ;;; Local Variables: *** ;;; mode: C++ ***