This exception to my self-imposed C/C++ code freeze is not to fix a
regression or to change anything about formatting, but simply to improve
the experience of tbl(1) users.

Perhaps it explains itself.  Here's the diff.

diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index 57bbf05f5..fdceaa5b4 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -2304,8 +2304,10 @@ void table::compute_overall_width()
           ".EN\n"
           ".  .\n");
     entry_list->set_location();
-    prints(".  tmc \\n[.F]:\\n[.c]: warning:\n"
-          ".  tm1 \" table wider than line length minus indentation"
+    prints(".  tmc \\n[.F]:\\n[.c]: warning:\n");
+    if (flags & CENTER)
+      prints(".  tmc \" centered\n");
+    prints(".  tm1 \" table wider than line length minus indentation"
           "\n");
     prints(".  ig\n"
           ".EQ\n"
diff --git a/src/preproc/tbl/tbl.1.man b/src/preproc/tbl/tbl.1.man
index 5d94642a2..48427b7ac 100644
--- a/src/preproc/tbl/tbl.1.man
+++ b/src/preproc/tbl/tbl.1.man
@@ -275,8 +275,10 @@ .SS "Region options"
 .
 .TP
 .B center
-Center the table region with respect to the current indentation and line
-length;
+Center the table region with respect to the line length,
+reducing the indentation if necessary
+(with a warning at formatting time)
+to make the table region fit;
 the default is to left-align it.
 .
 GNU
@@ -399,7 +401,9 @@ .SS "Region options"
 .TP
 .B nowarn
 Suppress diagnostic messages produced at document formatting time when
-the line or page lengths are inadequate to contain a table row.
+the line length and indentation
+or page length
+is inadequate to contain a table row.
 .
 .
 This is a GNU extension.
 .

As can be seen, most of this is a change to documentation.  I notice
that Lesk's January 1979 paper presenting tbl does not document that the
"center" region option nibbles away at the configured indentation if
necessary to make the table fit.  But every tbl implementation I have
ready to hand does this,[1] and GNU tbl behaves compatibly.

Observe.

$ cat ATTIC/unindenting-a-centered-table.roff
.ll 30n
.in 10n
Sed ut perspiciatis, unde omnis iste natus error sit voluptatem
accusantium doloremque laudantium
.sp
Let's have an un-centered table.
.sp
.TS
L L.
1234567890 1234567890
.TE
.sp
Now let's have a centered table.
.sp
.TS
center;
L L.
1234567890 1234567890
.TE
.sp
.in 0
123456789012345678901234567890
.pl \n(nlu
$ dwb tbl ATTIC/unindenting-a-centered-table.roff | dwb nroff
          Sed ut perspiciatis,
          unde    omnis   iste
          natus   error    sit
          voluptatem
          accusantium
          doloremque
          laudantium

          Let's  have  an  un-
          centered table.

          1234567890 1234567890

          Now  let's  have   a
          centered table.

        1234567890 1234567890

123456789012345678901234567890
$ 9 tbl ATTIC/unindenting-a-centered-table.roff | 9 nroff
          Sed ut perspiciatis,
          unde    omnis   iste
          natus   error    sit
          voluptatem
          accusantium
          doloremque
          laudantium

          Let's  have  an  un-
          centered table.

          1234567890 1234567890

          Now  let's  have   a
          centered table.

        1234567890 1234567890

123456789012345678901234567890
$ heirloom tbl ATTIC/unindenting-a-centered-table.roff | heirloom nroff
          Sed ut perspiciatis,
          unde    omnis   iste
          natus   error    sit
          voluptatem  accusan-
          tium doloremque lau-
          dantium

          Let's  have  an  un-
          centered table.

          1234567890 1234567890

          Now  let's  have   a
          centered table.

        1234567890 1234567890

123456789012345678901234567890
$ nroff -t ATTIC/unindenting-a-centered-table.roff
ATTIC/unindenting-a-centered-table.roff:10: warning: table wider than line 
length minus indentation
ATTIC/unindenting-a-centered-table.roff:18: warning: centered table wider than 
line length minus indentation
          Sed ut perspiciatis,
          unde  omnis iste na‐
          tus error sit volup‐
          tatem    accusantium
          doloremque   laudan‐
          tium

          Let’s  have  an  un‐
          centered table.

          1234567890 1234567890

          Now   let’s  have  a
          centered table.

       1234567890 1234567890

123456789012345678901234567890

The last instance, using groff, further motivates this change.  I have
become accustomed, probably like most GNU tbl users who paid any
attention at all, to the diagnostic...

warning: table wider than line length minus indentation

...advising that a line has been overset (on the right).

However we can see here that this isn't what has happened with the
centered table.  The table isn't overset on the right, but it does
override the configured indentation, which can be ugly in a different
way.

I therefore think it prudent to warn in both situations, but in a way
that can the user can _differentiate_ them by the message's wording.

Doing _that_ requires a patch to GNU tbl's C++ code, adding a
conditional upon the "center" region option configured by the user.

To get a clearer picture of this, notice how older version of groff
_don't_ distingush these scenarios.

$ ~/groff-1.23.0/bin/nroff -t ATTIC/unindenting-a-centered-table.roff
ATTIC/unindenting-a-centered-table.roff:10: warning: table wider than line 
length minus indentation
ATTIC/unindenting-a-centered-table.roff:18: warning: table wider than line 
length minus indentation
          Sed ut perspiciatis,
          unde  omnis iste na‐
          tus error sit volup‐
          tatem    accusantium
          doloremque   laudan‐
          tium

          Let’s  have  an  un‐
          centered table.

          1234567890 1234567890

          Now   let’s  have  a
          centered table.

        1234567890 1234567890

123456789012345678901234567890
$ ~/groff-1.22.4/bin/nroff -t ATTIC/unindenting-a-centered-table.roff
warning: file 'ATTIC/unindenting-a-centered-table.roff', around line 15:
  table wider than line width
warning: file 'ATTIC/unindenting-a-centered-table.roff', around line 23:
  table wider than line width
          Sed ut perspiciatis,
          unde omnis iste  na‐
          tus error sit volup‐
          tatem    accusantium
          doloremque   laudan‐
          tium

          Let’s  have  an  un‐
          centered table.

          1234567890 1234567890

          Now   let’s  have  a
          centered table.

        1234567890 1234567890

123456789012345678901234567890

(groff 1.22.3 looks the same as groff 1.22.4.)

Please advise of any objections.

Regards,
Branden

[1] I didn't bother firing up SIMH to inspect Seventh Edition Unix for
    this one.

Attachment: signature.asc
Description: PGP signature

Reply via email to