bugGNU Octave - Bugs: bug #53421, Excessive newlines displayed for...

 
 

bug #53421: Excessive newlines displayed for deep structs

Submitter:  Ceral Paquet <octavebugs>
Submitted:  Thu 22 Mar 2018 12:51:33 PM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  3 - Low Item Group:  None
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 14 Jan 2019 10:50:21 PM UTC, comment #6: 

One extra note - even in non-nested structs, there's an extra new line at the end under "format compact".


>> format compact
>> x = 1
x =  1
>> str = 'foobar'
str = foobar
>> obj = MyClass
obj =
<object MyClass>

>> struct('foo',1,'bar',2)
ans =
  scalar structure containing the fields:
    foo =  1
    bar =  2

>> {1,2}
ans =
{
  [1,1] =  1
  [1,2] =  2
}

>>


Andrew Janke <apjanke>
Sun 25 Mar 2018 10:46:11 AM UTC, comment #5: 

From what I gather, the solution lies in this condition.

  if (print_padding && pad_after && ! Vcompact_format)
    newline (output_buf);


print_padding is always true as can be seen here. Maybe if we can introduce one more condition in the above if Vstruct_levels_to_print <= 2
 or put some condition which will regulate when to make print_padding as false? When Vstruct_levels_to_print <= 2 evaluates to true, print a newline else do not. And it looks kinda ugly if we completely remove the if condition at all as can be seen in below examples:


The padded lines are not there at the end

octave:1> struct_levels_to_print(10)
octave:2> s.s.s.s.s.A = 1:10
s =

  scalar structure containing the fields:

    s =

      scalar structure containing the fields:

        s =

          scalar structure containing the fields:

            s =

              scalar structure containing the fields:

                s =

                  scalar structure containing the fields:

                    A =

                        1    2    3    4    5    6    7    8    9   10

octave:3>


Padding should be there in the below two cases, which can be accompanied if we introduce a new condition about the levels of struct to print.

octave:14> a.A = 10;
octave:15> a.B = 10;
octave:16> a.C = 10;
octave:17> a.D = 1:10;
octave:18> a.E = 10;
octave:19> a
a =

  scalar structure containing the fields:

    A =  10
    B =  10
    C =  10
    D =

        1    2    3    4    5    6    7    8    9   10
    E =  10

octave:20>



octave:25> a.A = 10;
octave:26> a.B = 10;
octave:27> a.C = 10;
octave:28> a.D = 1:10;
octave:29> a.E = 1:10;
octave:30> a.F = 1:10;
octave:31> a
a =

  scalar structure containing the fields:

    A =  10
    B =  10
    C =  10
    D =

        1    2    3    4    5    6    7    8    9   10
    E =

        1    2    3    4    5    6    7    8    9   10
    F =

        1    2    3    4    5    6    7    8    9   10

octave:32>


Sahil <batterylow>
Thu 22 Mar 2018 08:59:18 PM UTC, comment #4: 

I think there might already be a bug report about the extra newline(s).  But yes, there shouldn't be 5 newlines at the end of the presentation of a struct.

Rik <rik5>
Group administrator
Thu 22 Mar 2018 08:53:24 PM UTC, comment #3: 

Might it be worth looking at compacting multiple blank lines into one though? When an array is inside a struct, you get a blank line for the array, and then the surrounding blank line for the struct.


>> A = 1:10
A =

    1    2    3    4    5    6    7    8    9   10

>> s.A = 1:10
s =

  scalar structure containing the fields:

    A =

        1    2    3    4    5    6    7    8    9   10



That's two blank lines at the end, one from the row vector s.A, and one for the struct s.

This can get a little pathological:


>> struct_levels_to_print (10)
>> s.s.s.s.A = 1:10
s =

  scalar structure containing the fields:

    A =

        1    2    3    4    5    6    7    8    9   10

    s =

      scalar structure containing the fields:

        s =

          scalar structure containing the fields:

            s =

              scalar structure containing the fields:

                A =

                    1    2    3    4    5    6    7    8    9   10






Five blank lines at the end for all the nesting.

Mike Miller <mtmiller>
Group Member
Thu 22 Mar 2018 08:47:47 PM UTC, comment #2: 

Aiighhh you're right, my bad. Thanks for the correction.

Ceral Paquet <octavebugs>
Thu 22 Mar 2018 06:36:10 PM UTC, comment #1: 

Is it excessive, or just the same as the regular display of a vector as opposed to a scalar?  The struct aspect of the variable doesn't seem to matter here.  See below


octave:1> c = [1 2]
c =

   1   2

octave:2> format compact
octave:3> c
c =
   1   2


The default case for any array, as opposed to scalars, is to put newlines above and belowe the values unless the "compact" modifier is used.


Rik <rik5>
Group administrator
Thu 22 Mar 2018 12:51:33 PM UTC, original submission:  


>> clear
>> str.a=1
str =

  scalar structure containing the fields:

    a =  1

>> str.b=2
str =

  scalar structure containing the fields:

    a =  1
    b =  2

>> str.c=[1 2]
str =

  scalar structure containing the fields:

    a =  1
    b =  2
    c =

       1   2


>> disp(str)

  scalar structure containing the fields:

    a =  1
    b =  2
    c =

       1   2

>>



The member "c" has newline characters before and after it.

Ceral Paquet <octavebugs>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by apjanke (Posted a comment)
  • -email is unavailable- added by batterylow (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by octavebugs (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-01-14 mtmiller Carbon-CopyRemoved 80942 -
    2019-01-14 rik5 Dependencies- bugs #55460 is dependent
    2018-03-22 rik5 Priority5 - Normal 3 - Low
    2018-03-22 rik5 CategoryNone Interpreter
        Severity3 - Normal 2 - Minor
        StatusNeed Info Confirmed
        Release4.2.1 dev
        SummaryExcessive whitespace displaying struct.array Excessive newlines displayed for deep structs
    2018-03-22 rik5 StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code