Mercurial > hg > octave-nkf
changeset 4463:322453495d75
[project @ 2003-07-12 05:03:33 by jwe]
author | jwe |
---|---|
date | Sat, 12 Jul 2003 05:03:33 +0000 |
parents | 3e48e60a1f8b |
children | 184fc19a7d99 |
files | doc/faq/Octave-FAQ.texi doc/interpreter/basics.txi doc/interpreter/eval.txi doc/interpreter/var.txi scripts/ChangeLog scripts/image/colormap.m scripts/miscellaneous/dump_prefs.m src/ChangeLog src/octave.cc src/parse.y test/octave.test/eval/eval-1.m test/octave.test/eval/eval-10.m test/octave.test/eval/eval-2.m test/octave.test/eval/eval-3.m test/octave.test/eval/eval-4.m test/octave.test/eval/eval-7.m test/octave.test/eval/eval-8.m test/octave.test/eval/eval-9.m test/octave.test/eval/eval.exp |
diffstat | 19 files changed, 85 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/faq/Octave-FAQ.texi +++ b/doc/faq/Octave-FAQ.texi @@ -720,7 +720,6 @@ PS2 = "" beep_on_error = true crash_dumps_octave_core = false - default_eval_print_flag = false default_global_variable_value = [] default_save_format = "mat-binary" define_all_return_values = true
--- a/doc/interpreter/basics.txi +++ b/doc/interpreter/basics.txi @@ -160,7 +160,6 @@ PS2 = "" beep_on_error = true crash_dumps_octave_core = false - default_eval_print_flag = false default_global_variable_value = [] default_save_format = "mat-binary" define_all_return_values = true
--- a/doc/interpreter/eval.txi +++ b/doc/interpreter/eval.txi @@ -18,8 +18,6 @@ @DOCSTRING(eval) -@DOCSTRING(default_eval_print_flag) - @DOCSTRING(feval) Here is a simple-minded function using @code{feval} that finds the root
--- a/doc/interpreter/var.txi +++ b/doc/interpreter/var.txi @@ -241,11 +241,6 @@ Default value: @code{" "}. -@item default_eval_print_flag -@xref{Evaluation}. - -Default value: 1. - @item default_return_value @xref{Multiple Return Values}.
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,33 @@ 2003-07-11 John W. Eaton <jwe@bevo.che.wisc.edu> + * image/colormap.m: Don't save and restore default_eval_print_flag. + + * miscellaneous/dump_prefs.m: Delete default_eval_print_flag. + + * control/util/zgshsr.m: Use x OP= y instead of x = x OP y. + * control/system/sys2fir.m: Likewise. + + * control/system/is_siso.m: Use && instead of & where appropriate. + * control/system/__tf2sysl__.m: Likewise. + + * control/system/__tf2sysl__.m: Use end instead of length(X). + + * control/freqchkw.m: Use %-escapes for error instead of num2str + and [] concatenation. + * control/system/sys2fir.m: Likewise. + + * control/base/dgram.m, control/base/freqchkw.m, + control/base/gram.m, control/system/__abcddims__.m, + control/system/__sysdefstname__.m, control/system/__tf2sysl__.m, + control/system/is_sample.m, control/system/is_signal_list.m, + control/system/is_siso.m, control/system/sys2fir.m, + control/system/syschtsam.m, control/system/sysgettsam.m, + control/system/sysgettype.m, control/system/tf2zp.m, + control/system/ugain.m, control/util/prompt.m, + control/util/run_cmd.m, control/util/zgrownorm.m, + control/util/zgshsr.m: + Improve conformance to Octave coding style. + * miscellaneous/dump_prefs.m: Add warn_resize_on_reange_error to the list. Delete resize_on_range_error from the list.
--- a/scripts/image/colormap.m +++ b/scripts/image/colormap.m @@ -51,13 +51,7 @@ if (strcmp (map, "default")) map = gray (); else - unwind_protect - save_default_eval_print_flag = default_eval_print_flag; - default_eval_print_flag = 0; - map = eval (map); - unwind_protect_cleanup - default_eval_print_flag = save_default_eval_print_flag; - end_unwind_protect + map = eval (map); endif endif
--- a/scripts/miscellaneous/dump_prefs.m +++ b/scripts/miscellaneous/dump_prefs.m @@ -53,7 +53,6 @@ "beep_on_error"; "completion_append_char"; "crash_dumps_octave_core"; - "default_eval_print_flag"; "default_global_variable_value"; "default_return_value"; "default_save_format";
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ 2003-07-11 John W. Eaton <jwe@bevo.che.wisc.edu> + * octave.cc (maximum_braindamage): Don't set default_eval_print_flag. + + * parse.y (Vdefault_eval_print_flag): Delete: + (default_eval_print_flag): Delete. + (symbols_of_parse): Delete DEFVAR for default_eval_print_flag. + (Feval, Fevalin): Return empty octave_value_list and turn printing + on in eval_string if nargout is zero. + * ov-list.cc (octave_list::assign): Check Vwarn_resize_on_range_error, not Vresize_on_range_error.
--- a/src/octave.cc +++ b/src/octave.cc @@ -346,7 +346,6 @@ bind_builtin_variable ("PS2", ""); bind_builtin_variable ("beep_on_error", true); bind_builtin_variable ("crash_dumps_octave_core", false); - bind_builtin_variable ("default_eval_print_flag", false); bind_builtin_variable ("default_global_variable_value", Matrix ()); bind_builtin_variable ("default_save_format", "mat-binary"); bind_builtin_variable ("define_all_return_values", true);
--- a/src/parse.y +++ b/src/parse.y @@ -69,9 +69,6 @@ #include "utils.h" #include "variables.h" -// TRUE means we print -static bool Vdefault_eval_print_flag = true; - // If TRUE, generate a warning for the assignment in things like // // octave> if (a = 2 < n) @@ -3745,33 +3742,9 @@ "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} eval (@var{try}, @var{catch})\n\ Parse the string @var{try} and evaluate it as if it were an Octave\n\ -program, returning the last value computed. If that fails, evaluate\n\ -the string @var{catch}. The string @var{try} is evaluated in the\n\ -current context, so any results remain available after @code{eval}\n\ -returns. For example,\n\ -\n\ -@example\n\ -@group\n\ -eval (\"a = 13\")\n\ - @print{} a = 13\n\ - @result{} 13\n\ -@end group\n\ -@end example\n\ -\n\ -In this case, the value of the evaluated expression is printed and it is\n\ -also returned returned from @code{eval}. Just as with any other\n\ -expression, you can turn printing off by ending the expression in a\n\ -semicolon. For example,\n\ -\n\ -@example\n\ -eval (\"a = 13;\")\n\ - @result{} 13\n\ -@end example\n\ -\n\ -In this example, the variable @code{a} has been given the value 13, but\n\ -the value of the expression is not printed. You can also turn off\n\ -automatic printing for all expressions executed by @code{eval} using the\n\ -variable @code{default_eval_print_flag}.\n\ +program. If that fails, evaluate the string @var{catch}.\n\ +The string @var{try} is evaluated in the current context,\n\ +so any results remain available after @code{eval} returns.\n\ @end deftypefn") { octave_value_list retval; @@ -3790,8 +3763,11 @@ int parse_status = 0; - retval = eval_string (args(0), ! Vdefault_eval_print_flag, - parse_status, nargout); + octave_value_list tmp = eval_string (args(0), nargout > 0, + parse_status, nargout); + + if (nargout > 0) + retval = tmp; if (nargin > 1 && (parse_status != 0 || error_state)) { @@ -3924,8 +3900,11 @@ int parse_status = 0; - retval = eval_string (args(1), ! Vdefault_eval_print_flag, - parse_status, nargout); + octave_value_list tmp = eval_string (args(1), nargout > 0, + parse_status, nargout); + + if (nargout > 0) + retval = tmp; if (nargin > 2 && (parse_status != 0 || error_state)) { @@ -3958,14 +3937,6 @@ } static int -default_eval_print_flag (void) -{ - Vdefault_eval_print_flag = check_preference ("default_eval_print_flag"); - - return 0; -} - -static int warn_assign_as_truth_value (void) { Vwarn_assign_as_truth_value @@ -4018,14 +3989,6 @@ void symbols_of_parse (void) { - DEFVAR (default_eval_print_flag, true, default_eval_print_flag, - "-*- texinfo -*-\n\ -@defvr {Built-in Variable} default_eval_print_flag\n\ -If the value of this variable is nonzero, Octave prints the results of\n\ -commands executed by @code{eval} that do not end with semicolons. If it\n\ -is zero, automatic printing is suppressed. The default value is 1.\n\ -@end defvr"); - DEFVAR (warn_assign_as_truth_value, true, warn_assign_as_truth_value, "-*- texinfo -*-\n\ @defvr {Built-in Variable} warn_assign_as_truth_value\n\
--- a/test/octave.test/eval/eval-1.m +++ b/test/octave.test/eval/eval-1.m @@ -1,2 +1,2 @@ -default_eval_print_flag = 1; -eval ("x = 1"); +x = 1; +eval ("x");
--- a/test/octave.test/eval/eval-10.m +++ b/test/octave.test/eval/eval-10.m @@ -1,2 +1,2 @@ -default_eval_print_flag = 0; eval ("x = 1") +x == 1
--- a/test/octave.test/eval/eval-2.m +++ b/test/octave.test/eval/eval-2.m @@ -1,2 +1,2 @@ -default_eval_print_flag = 1; -eval ("x = 1;") +x = 1; +eval ("x;")
--- a/test/octave.test/eval/eval-3.m +++ b/test/octave.test/eval/eval-3.m @@ -1,2 +1,2 @@ -default_eval_print_flag = 1; -eval ("x = 1;"); +x = 1 +eval ("x;");
--- a/test/octave.test/eval/eval-4.m +++ b/test/octave.test/eval/eval-4.m @@ -1,2 +1,2 @@ -default_eval_print_flag = 1; -eval ("x = 1") +x = 1; +eval ("x")
--- a/test/octave.test/eval/eval-7.m +++ b/test/octave.test/eval/eval-7.m @@ -1,2 +1,2 @@ -default_eval_print_flag = 0; eval ("x = 1"); +x == 1
--- a/test/octave.test/eval/eval-8.m +++ b/test/octave.test/eval/eval-8.m @@ -1,2 +1,2 @@ -default_eval_print_flag = 0; eval ("x = 1;") +x == 1
--- a/test/octave.test/eval/eval-9.m +++ b/test/octave.test/eval/eval-9.m @@ -1,2 +1,2 @@ -default_eval_print_flag = 0; eval ("x = 1;"); +x == 1
--- a/test/octave.test/eval/eval.exp +++ b/test/octave.test/eval/eval.exp @@ -3,19 +3,19 @@ do_test eval-1.m set test eval-2 -set prog_output "^ans = 1" +set prog_output "^$" do_test eval-2.m set test eval-3 -set prog_output "^$" +set prog_output "^x = 1" do_test eval-3.m set test eval-4 -set prog_output "x = 1\nans = 1" +set prog_output "^x = 1" do_test eval-4.m set test eval-5 -set prog_output "flipud = 2" +set prog_output "^flipud = 2" do_test eval-5.m set test eval-6 @@ -23,7 +23,7 @@ do_test eval-6.m set test eval-7 -set prog_output "^$" +set prog_output "^x = 1\nans = 1" do_test eval-7.m set test eval-8 @@ -31,10 +31,26 @@ do_test eval-8.m set test eval-9 -set prog_output "^$" +set prog_output "^ans = 1" do_test eval-9.m set test eval-10 -set prog_output "^ans = 1" +set prog_output "^x = 1\nans = 1" do_test eval-10.m +set test eval-11 +set prog_output "^ans = 1" +do_test eval-11.m + +set test eval-12 +set prog_output "^y = 1" +do_test eval-12.m + +set test eval-13 +set prog_output "^ans = 1" +do_test eval-13.m + +set test eval-14 +set prog_output "^y = 1" +do_test eval-14.m +