changeset 24737:5be92b26ef8f

Fix alignment of numbers in fixed_point_format display (bug #53083). * pr-output.cc (make_real_matrix_format): Increase fw (fixed width) by 1 to accomodate minus sign. * pr-output.cc (pr_scale_header): Don't add extra space between scale factor and multiplication symbol '*'. * pr-output.cc: Change "col +inc" to "col + inc" for clarity.
author Rik <rik@octave.org>
date Sun, 11 Feb 2018 10:26:22 -0800
parents cd25b9c5f808
children 3695c2cd69b8
files libinterp/corefcn/pr-output.cc
diffstat 1 files changed, 14 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/pr-output.cc	Sun Feb 11 12:58:11 2018 -0500
+++ b/libinterp/corefcn/pr-output.cc	Sun Feb 11 10:26:22 2018 -0800
@@ -585,7 +585,7 @@
   else if (Vfixed_point_format && ! print_g)
     {
       rd = prec;
-      fw = rd + 2;
+      fw = rd + 3;
       if (inf_or_nan && fw < 4)
         fw = 4;
     }
@@ -1549,7 +1549,7 @@
          << std::setw (8) << std::setprecision (1)
          << std::setiosflags (std::ios::scientific | std::ios::left)
          << scale
-         << " *\n";
+         << "*\n";
 
       if (! Vcompact_format)
         os << "\n";
@@ -1760,7 +1760,7 @@
 
           for (octave_idx_type col = 0; col < nc; col += inc)
             {
-              octave_idx_type lim = (col +inc < nc ? col + inc : nc);
+              octave_idx_type lim = (col + inc < nc ? col + inc : nc);
 
               pr_col_num_header (os, total_width, max_width, lim, col,
                                  extra_indent);
@@ -1855,7 +1855,7 @@
           octave_idx_type col = 0;
           while (col < nc)
             {
-              octave_idx_type lim = (col +inc < nc ? col + inc : nc);
+              octave_idx_type lim = (col + inc < nc ? col + inc : nc);
 
               for (octave_idx_type j = col; j < lim; j++)
                 {
@@ -1895,7 +1895,6 @@
 
           // kluge.  Get the true width of a number.
           int zero_fw;
-
           {
             std::ostringstream tmp_oss;
             pr_float (tmp_oss, 0.0, fw, scale);
@@ -1904,7 +1903,7 @@
 
           for (octave_idx_type col = 0; col < nc; col += inc)
             {
-              octave_idx_type lim = (col +inc < nc ? col + inc : nc);
+              octave_idx_type lim = (col + inc < nc ? col + inc : nc);
 
               pr_col_num_header (os, total_width, max_width, lim, col,
                                  extra_indent);
@@ -2144,7 +2143,7 @@
               octave_idx_type col = 0;
               while (col < nc)
                 {
-                  octave_idx_type lim = (col +inc < nc ? col + inc : nc);
+                  octave_idx_type lim = (col + inc < nc ? col + inc : nc);
 
                   for (octave_idx_type j = col; j < lim; j++)
                     {
@@ -2185,7 +2184,7 @@
 
           for (octave_idx_type col = 0; col < nc; col += inc)
             {
-              octave_idx_type lim = (col +inc < nc ? col + inc : nc);
+              octave_idx_type lim = (col + inc < nc ? col + inc : nc);
 
               pr_col_num_header (os, total_width, max_width, lim, col,
                                  extra_indent);
@@ -2282,7 +2281,7 @@
           octave_idx_type col = 0;
           while (col < nc)
             {
-              octave_idx_type lim = (col +inc < nc ? col + inc : nc);
+              octave_idx_type lim = (col + inc < nc ? col + inc : nc);
 
               for (octave_idx_type j = col; j < lim; j++)
                 {
@@ -2322,7 +2321,6 @@
 
           // kluge.  Get the true width of a number.
           int zero_fw;
-
           {
             std::ostringstream tmp_oss;
             pr_complex (tmp_oss, Complex (0.0), r_fw, i_fw, scale);
@@ -2331,7 +2329,7 @@
 
           for (octave_idx_type col = 0; col < nc; col += inc)
             {
-              octave_idx_type lim = (col +inc < nc ? col + inc : nc);
+              octave_idx_type lim = (col + inc < nc ? col + inc : nc);
 
               pr_col_num_header (os, total_width, max_width, lim, col,
                                  extra_indent);
@@ -2430,7 +2428,7 @@
           octave_idx_type col = 0;
           while (col < nc)
             {
-              octave_idx_type lim = (col +inc < nc ? col + inc : nc);
+              octave_idx_type lim = (col + inc < nc ? col + inc : nc);
 
               for (octave_idx_type j = col; j < lim; j++)
                 {
@@ -2468,7 +2466,7 @@
 
           for (octave_idx_type col = 0; col < nc; col += inc)
             {
-              octave_idx_type lim = (col +inc < nc ? col + inc : nc);
+              octave_idx_type lim = (col + inc < nc ? col + inc : nc);
 
               pr_col_num_header (os, total_width, max_width, lim, col,
                                  extra_indent);
@@ -2658,7 +2656,7 @@
           octave_idx_type col = 0;
           while (col < num_elem)
             {
-              octave_idx_type lim = (col +inc < num_elem ? col + inc : num_elem);
+              octave_idx_type lim = (col + inc < num_elem ? col + inc : num_elem);
 
               pr_col_num_header (os, total_width, max_width, lim, col,
                                  extra_indent);
@@ -3266,8 +3264,8 @@
 
               for (octave_idx_type col = 0; col < n_cols; col += inc)
                 {
-                  octave_idx_type lim = (col +inc < n_cols ? col + inc
-                                                           : n_cols);
+                  octave_idx_type lim = (col + inc < n_cols ? col + inc
+                                                            : n_cols);
 
                   pr_col_num_header (os, total_width, max_width, lim, col,
                                      extra_indent);