# HG changeset patch # User Rik # Date 1621959329 25200 # Node ID 777c16616c4063d0963bd2399d4192742ae0a626 # Parent 3a684b0e7406980613cae72a38ea7e888b96d74c Make disp() Matlab-compatible for scalar struct variables (bug #60643). * ov-struct.cc (octave_struct::print_raw): Use parentheses around initialization of variable "max_depth_reached" with a conditional for readability. * ov-struct.cc (octave_scaler_struct::print_raw): Use parentheses around initialization of variable "max_depth_reached" with a conditional for readability. Delete code to print tag "scalar structure containing the fields:". * ov-struct.cc (octave_scaler_struct::print_name_tag): Add code to print tag "scalar struct containing the fields:". diff -r 3a684b0e7406 -r 777c16616c40 libinterp/octave-value/ov-struct.cc --- a/libinterp/octave-value/ov-struct.cc Mon May 24 18:39:30 2021 -0400 +++ b/libinterp/octave-value/ov-struct.cc Tue May 25 09:15:29 2021 -0700 @@ -602,10 +602,10 @@ if (Vstruct_levels_to_print >= 0) { - bool max_depth_reached = Vstruct_levels_to_print-- == 0; - - bool print_fieldnames_only - = (max_depth_reached || ! Vprint_struct_array_contents); + bool max_depth_reached = (Vstruct_levels_to_print-- == 0); + + bool print_fieldnames_only = (max_depth_reached + || ! Vprint_struct_array_contents); increment_indent_level (); @@ -1320,18 +1320,11 @@ if (Vstruct_levels_to_print >= 0) { - bool max_depth_reached = Vstruct_levels_to_print-- == 0; + bool max_depth_reached = (Vstruct_levels_to_print-- == 0); bool print_fieldnames_only = max_depth_reached; increment_indent_level (); - - indent (os); - os << "scalar structure containing the fields:"; - newline (os); - if (! Vcompact_format) - newline (os); - increment_indent_level (); string_vector key_list = map.fieldnames (); @@ -1382,6 +1375,16 @@ if (! Vcompact_format) newline (os); + increment_indent_level (); + + indent (os); + os << "scalar structure containing the fields:"; + newline (os); + if (! Vcompact_format) + newline (os); + + decrement_indent_level (); + retval = true; }