Mercurial > octave
changeset 25107:13cd142c3f88 stable
Don't reset compact/loose spacing when changing numerical format (Bug #53427).
* pr-output.cc (init_format_state): Remove line to reset Vcompact_format to false.
* pr-output.cc (set_format_style): Set Vcompact_format to false if called with
no arguments (reset).
* pr-output.cc (Fformat): If called with outputs and inputs, emit a warning that
format cannot be both queried and set. Perform only query operation. Add new
BIST tests for bug #53427 and for new warning message.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 03 Apr 2018 22:12:05 -0700 |
parents | d7ad543255c5 |
children | 7561fb4ab972 |
files | libinterp/corefcn/pr-output.cc |
diffstat | 1 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/pr-output.cc Tue Apr 03 21:37:29 2018 -0700 +++ b/libinterp/corefcn/pr-output.cc Tue Apr 03 22:12:05 2018 -0700 @@ -3507,7 +3507,6 @@ bank_format = false; hex_format = 0; bit_format = 0; - Vcompact_format = false; print_e = false; print_big_e = false; print_g = false; @@ -3751,6 +3750,7 @@ init_format_state (); set_output_prec (5); format = "short"; + Vcompact_format = false; } format_string = format; @@ -3938,6 +3938,9 @@ } else { + if (args.length () > 0) + warning ("format: cannot query and set format at the same time, ignoring set operation"); + if (nargout >= 2) retval(1) = (Vcompact_format ? "compact" : "loose"); @@ -3971,6 +3974,25 @@ %! format (old_fmt); %! format (old_spacing); %! end_unwind_protect + +%!test <*53427> +%! [old_fmt, old_spacing] = format (); +%! unwind_protect +%! format; # reset format to short and loose +%! format compact; # set compact format +%! format long; # set long format +%! [fmt, spacing] = format (); +%! assert (fmt, "long"); +%! assert (spacing, "compact"); +%! unwind_protect_cleanup +%! format (old_fmt); +%! format (old_spacing); +%! end_unwind_protect + +## Test input validation +%!test +%! fail ("fmt = format ('long')", "warning", "cannot query and set format"); + */ DEFUN (fixed_point_format, args, nargout,