a fourth focussed bust of the C/C++ code freeze: centered table diagnostics

"G. Branden Robinson" <[email protected]>
Newsgroups gmane.comp.printing.groff.general
Message-ID <20260207092425.me445owerbphdnkw@illithid>
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.
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEh3PWHWjjDgcrENwa0Z6cfXEmbc4FAmmHBMEACgkQ0Z6cfXEm
bc4PHg//VCOysyR4bourGZ7q7DPR2pX9dz1YDp9wzoI7zXB4eNZTPK63ya/u7kfd
/URFolQ8XDbOn9bFBAndiYc06K1z4KHhNI4iFkdybv3TP6vXwkkY8j7KIgGo1jLz
bU0CO7haA+uWoC77KGH+E688QSP/z0qTjJ2XKTYE0vo2OKMZA55qUIpNC2bCiucl
CQ2guJ92NCNhvhVjbh7INPN/yhGkTyDThs5sXfanZ+ubS/i5UjTK1haUlSxRx/dJ
eDnjUUXYduVMDXgYJkRroYt9DJjEEPsOK//cjd2QUpsPaZWe04Dd1YUAYaUkzkBj
aAiHw10Bk6fhELI39o8a7BiPZrXw9SSgx0rBAnvGbH6G19Dn/1RSqANjQN8LrAPI
myRiaXGjrXCIzDBkUUe76fgFAsyA5ehXU5bhiA6M/0qSqddLIiEW3FKZf/RSMWIc
g3zDX7zmNPCnLwg1/KJCpGX7nk68NvVXDPjQ9pNkNSqVifGRTGQhb0GGHMN84VF/
TskYs1Njtos0QCmcBUZT774XKo7aiaPIjVkj+kHfL2W8XROI2t5aynzSeyVqVPT8
H9E3l6XkRzzVSy2ZTSZ4D/EYH8rH0icI8L83IVjkjdI7Xy74C0hX/IKRT4CIYo7q
Pv+5uRO0xd1MHtBNHmG05M03G2LLIXvfK6WvhtywFJHbkEUoa4o=
=9aVy
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.