gbranden pushed a commit to branch master
in repository groff.

commit dbda7e0f69b83ec70bdbeb0e0f6fded40dddca68
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Nov 11 04:53:49 2026 -0600

    src/preproc/tbl/main.cpp: Bail earlier on error.
    
    * src/preproc/tbl/main.cpp (process_data): Give up on a table region
      earlier if a table continuation (`.T&`) occurs immediately after a
      table description; that is, a description with no corresponding data.
      Interpreting a continued table description after `.T&` is unnecessary
      in that situation, as we already know the table region to be invalid.
    
    Before:
    
    $ printf '.TS\nL.\n.T&\n=.\n.TE\n' | ./build/tbl > /dev/null
    ./build/tbl:<standard input>:5: error: final row definition in table 
description cannot contain only horizontal rules ('-', '_', '=')
    ./build/tbl:<standard input>:5: error: giving up on this table region
    
    After:
    
    $ printf '.TS\nL.\n.T&\n=.\n.TE\n' | ./build/tbl > /dev/null
    ./build/tbl:<standard input>:4: error: no data in table
    ./build/tbl:<standard input>:4: error: giving up on this table region
---
 ChangeLog                |  9 +++++++++
 src/preproc/tbl/main.cpp | 14 ++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d582b95be..4872ab71d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-11-11  G. Branden Robinson <[email protected]>
+
+       * src/preproc/tbl/main.cpp (process_data): Give up on a table
+       region earlier if a table continuation (`.T&`) occurs
+       immediately after a table description; that is, a description
+       with no corresponding data.  Interpreting a continued table
+       description after `.T&` is unnecessary in that situation, as we
+       already know the table region to be invalid.
+
 2026-11-11  G. Branden Robinson <[email protected]>
 
        * src/preproc/tbl/main.cpp (process_data): Fix code style nits.
diff --git a/src/preproc/tbl/main.cpp b/src/preproc/tbl/main.cpp
index 1edef78e0..8e0b28529 100644
--- a/src/preproc/tbl/main.cpp
+++ b/src/preproc/tbl/main.cpp
@@ -1618,11 +1618,17 @@ static table *process_data(table_input &in, format *f, 
options *opt)
        tbl->add_text_line(current_row, line, current_filename, ln);
        if (line.length() >= 4
            && line[0] == '.' && line[1] == 'T' && line[2] == '&') {
-         format *newf = process_format(in, opt, f);
-         if (0 /* nullptr */ == newf)
+         if (!give_up && (0 == current_row)) {
+           error("no data in table");
            give_up = true;
-         else
-           f = newf;
+         }
+         else {
+           format *newf = process_format(in, opt, f);
+           if (0 /* nullptr */ == newf)
+             give_up = true;
+           else
+             f = newf;
+         }
        }
        if (line.length() >= 3
            && line[0] == '.' && line[1] == 'l' && line[2] == 'f') {

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to