# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1315361716 18000 # Node ID 969ed305dde593e141fbb8ea15ce760c4c47af0c # Parent ebb42fb2da04b484ae757171aa20936beafa26bb Remove all blank lines with "format compact" * pr-output.h (Vcompact_format): New global variable. * pr-output.cc (Vcompact_format): No longer a static variable. (pr_scale_header, pr_col_num_header, octave_print_internal): Use Vcompact_format to eliminate some newlines. (Vformat): Document this change. * ov-base.cc (octave_base_value::print_name_tag, octave_base_value::print_with_name): Use Vcompact_format variable to omit newlines. * ov-class.cc (octave_class::print_name_tag): Ditto. * ov-range.cc (octave_range::print_name_tag): Ditto. * ov-struct.cc (octave_scalar_struct::print_raw): Ditto. diff -r ebb42fb2da04 -r 969ed305dde5 src/ov-base.cc --- a/src/ov-base.cc Wed Sep 07 20:13:18 2011 +0200 +++ b/src/ov-base.cc Tue Sep 06 21:15:16 2011 -0500 @@ -50,6 +50,7 @@ #include "ov-str-mat.h" #include "ov-fcn-handle.h" #include "parse.h" +#include "pr-output.h" #include "utils.h" #include "variables.h" @@ -419,7 +420,9 @@ { os << name << " ="; newline (os); - newline (os); + if (! Vcompact_format) + newline (os); + retval = true; } @@ -435,7 +438,7 @@ print (output_buf); - if (print_padding && pad_after) + if (print_padding && pad_after && ! Vcompact_format) newline (output_buf); } diff -r ebb42fb2da04 -r 969ed305dde5 src/ov-class.cc --- a/src/ov-class.cc Wed Sep 07 20:13:18 2011 +0200 +++ b/src/ov-class.cc Tue Sep 06 21:15:16 2011 -0500 @@ -1020,7 +1020,8 @@ indent (os); os << name << " ="; newline (os); - newline (os); + if (! Vcompact_format) + newline (os); return retval; } diff -r ebb42fb2da04 -r 969ed305dde5 src/ov-range.cc --- a/src/ov-range.cc Wed Sep 07 20:13:18 2011 +0200 +++ b/src/ov-range.cc Tue Sep 06 21:15:16 2011 -0500 @@ -370,7 +370,9 @@ { os << name << " ="; newline (os); - newline (os); + if (! Vcompact_format) + newline (os); + retval = true; } diff -r ebb42fb2da04 -r 969ed305dde5 src/ov-struct.cc --- a/src/ov-struct.cc Wed Sep 07 20:13:18 2011 +0200 +++ b/src/ov-struct.cc Tue Sep 06 21:15:16 2011 -0500 @@ -1335,11 +1335,14 @@ increment_indent_level (); - newline (os); + if (! Vcompact_format) + newline (os); + indent (os); os << "scalar structure containing the fields:"; newline (os); - newline (os); + if (! Vcompact_format) + newline (os); increment_indent_level (); diff -r ebb42fb2da04 -r 969ed305dde5 src/pr-output.cc --- a/src/pr-output.cc Wed Sep 07 20:13:18 2011 +0200 +++ b/src/pr-output.cc Tue Sep 06 21:15:16 2011 -0500 @@ -103,7 +103,7 @@ static int bit_format = 0; // TRUE means don't put newlines around the column number headers. -static bool compact_format = false; +bool Vcompact_format = false; // TRUE means use an e format. static bool print_e = false; @@ -1658,7 +1658,7 @@ << std::resetiosflags (std::ios::scientific|std::ios::left) << " *\n"; - if (! compact_format) + if (! Vcompact_format) os << "\n"; } } @@ -1671,7 +1671,7 @@ { if (col != 0) { - if (compact_format) + if (Vcompact_format) os << "\n"; else os << "\n\n"; @@ -1688,7 +1688,7 @@ else os << " Columns " << col + 1 << " through " << lim << ":\n"; - if (! compact_format) + if (! Vcompact_format) os << "\n"; } } @@ -1956,7 +1956,10 @@ } else { - os << "Diagonal Matrix\n\n"; + os << "Diagonal Matrix\n"; + if (! Vcompact_format) + os << "\n"; + pr_scale_header (os, scale); // kluge. Get the true width of a number. @@ -2369,7 +2372,10 @@ } else { - os << "Diagonal Matrix\n\n"; + os << "Diagonal Matrix\n"; + if (! Vcompact_format) + os << "\n"; + pr_scale_header (os, scale); // kluge. Get the true width of a number. @@ -2514,7 +2520,9 @@ } else { - os << "Permutation Matrix\n\n"; + os << "Permutation Matrix\n"; + if (! Vcompact_format) + os << "\n"; for (octave_idx_type col = 0; col < nc; col += inc) { @@ -2909,7 +2917,9 @@ octave_idx_type n_rows = page.rows (); octave_idx_type n_cols = page.cols (); - os << nm << " =\n\n"; + os << nm << " =\n"; + if (! Vcompact_format) + os << "\n"; for (octave_idx_type ii = 0; ii < n_rows; ii++) { @@ -3157,7 +3167,9 @@ nm += buf.str (); - os << nm << " =\n\n"; + os << nm << " =\n"; + if (! Vcompact_format) + os << "\n"; } Array idx (dim_vector (ndims, 1)); @@ -3262,7 +3274,9 @@ nm += buf.str (); - os << nm << " =\n\n"; + os << nm << " =\n"; + if (! Vcompact_format) + os << "\n"; } Array idx (dim_vector (ndims, 1)); @@ -3544,7 +3558,7 @@ bank_format = false; hex_format = 0; bit_format = 0; - compact_format = false; + Vcompact_format = false; print_e = false; print_big_e = false; print_g = false; @@ -3719,11 +3733,11 @@ } else if (arg == "compact") { - compact_format = true; + Vcompact_format = true; } else if (arg == "loose") { - compact_format = false; + Vcompact_format = false; } else error ("format: unrecognized format state `%s'", arg.c_str ()); @@ -3895,12 +3909,12 @@ \n\ @table @code\n\ @item compact\n\ -Remove extra blank space around column number labels producing more compact\n\ -output with more data per page.\n\ +Remove blank lines around column number labels and between\n\ +matrices producing more compact output with more data per page.\n\ \n\ @item loose\n\ -Insert blank lines above and below column number labels to produce a more\n\ -readable output with less data per page. (default).\n\ +Insert blank lines above and below column number labels and between matrices\n\ +to produce a more readable output with less data per page. (default).\n\ @end table\n\ @seealso{fixed_point_format, output_max_field_width, output_precision, split_long_rows, rats}\n\ @end deftypefn") diff -r ebb42fb2da04 -r 969ed305dde5 src/pr-output.h --- a/src/pr-output.h Wed Sep 07 20:13:18 2011 +0200 +++ b/src/pr-output.h Tue Sep 06 21:15:16 2011 -0500 @@ -256,4 +256,7 @@ // like this: x = [](2x0). extern bool Vprint_empty_dimensions; +// TRUE means don't put empty lines in output +extern bool Vcompact_format; + #endif