groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 41/45: [tbl]: Trivially refactor.


From: G. Branden Robinson
Subject: [groff] 41/45: [tbl]: Trivially refactor.
Date: Thu, 20 Jan 2022 10:17:57 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 7111d3378f0c2ceab891d66ae815d393ff87dae5
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Jan 20 16:31:00 2022 +1100

    [tbl]: Trivially refactor.
    
    * src/preproc/tbl/table.cpp (table::compute_expand_width): Declare and
      initialize variables closer to use.  Also, the width computed is
      compared to the line length and indentation, so use these
      well-established *roff terms in the diagnostic message.
---
 ChangeLog                 |  9 +++++++++
 src/preproc/tbl/table.cpp | 14 +++++++-------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 36d73203..2389a11b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-01-21  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [tbl]: Trivially refactor.
+
+       * src/preproc/tbl/table.cpp (table::compute_expand_width):
+       Declare and initialize variables closer to use.  Also, the width
+       computed is compared to the line length and indentation, so use
+       these well-established *roff terms in the diagnostic message.
+
 2022-01-20  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [tbl]: Fix Savannah #61854.
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index c1b66c2f..f86c53ba 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -2158,12 +2158,10 @@ void table::build_span_list()
 
 void table::compute_expand_width()
 {
-  int i;
-  int colcount = count_expand_columns();
   // First, compute the unexpanded table width, measuring every column
   // (including those eligible for expansion) and warn if it's too wide.
   prints(".nr " EXPAND_REG " \\n[.l]-\\n[.i]");
-  for (i = 0; i < ncolumns; i++)
+  for (int i = 0; i < ncolumns; i++)
     printfs("-\\n[%1]", span_width_reg(i, i));
   if (total_separation)
     printfs("-%1n", as_string(total_separation));
@@ -2179,7 +2177,7 @@ void table::compute_expand_width()
           ".EN\n"
           "..\n");
     prints(".tmc \\n[.F]: around line \\n[.c]: warning:\n"
-          ".tm1 \" table wider than line width\n");
+          ".tm1 \" table wider than line length minus indentation\n");
     prints(".ig\n"
           ".EQ\n"
           "delim on\n"
@@ -2191,18 +2189,20 @@ void table::compute_expand_width()
   // Now, iterate through the columns again, spreading any excess line
   // width among the expanded columns.
   prints(".nr " EXPAND_REG " \\n[.l]-\\n[.i]");
-  for (i = 0; i < ncolumns; i++)
+  for (int i = 0; i < ncolumns; i++)
     if (!expand[i])
       printfs("-\\n[%1]", span_width_reg(i, i));
   if (total_separation)
     printfs("-%1n", as_string(total_separation));
   prints("\n");
+  int colcount = count_expand_columns();
   if (colcount > 1)
     printfs(".nr " EXPAND_REG " \\n[" EXPAND_REG "]/%1\n",
            as_string(colcount));
-  for (i = 0; i < ncolumns; i++)
+  for (int i = 0; i < ncolumns; i++)
     if (expand[i])
-      printfs(".nr %1 \\n[%1]>?\\n[" EXPAND_REG "]\n", span_width_reg(i, i));
+      printfs(".nr %1 \\n[%1]>?\\n[" EXPAND_REG "]\n",
+             span_width_reg(i, i));
 }
 
 void table::compute_total_separation()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]