[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #66006] [grog] Identifies .TS .TH .TE as a -man document
From: |
G. Branden Robinson |
Subject: |
[bug #66006] [grog] Identifies .TS .TH .TE as a -man document |
Date: |
Sat, 20 Jul 2024 15:21:43 -0400 (EDT) |
Follow-up Comment #3, bug #66006 (group groff):
Morten [https://lists.gnu.org/archive/html/bug-groff/2024-07/msg00205.html
wrote to the bug-groff list]:
> [ I couldn't submit this via Savannah's clunky interface, it was rejected ..
]
> Just a shot from the hip: In a shell, I believe the following
> idea basically solves the problem:
> grep -E -n "\.TH|\.TS|\.TE" groff-tbl.troff | head -1
> This would return
> 3:.TS H
> from the table file that demonstrated the problem. Since it is
> a ".TS" macro, the document is not a -man document. In other
> words, one can just check if the first macro returned is a
> ".TH" macro and then it is a -man document, otherwise not. If
> you could apply the finishing touches and convert to perl,
> wouldn't that be a good solution?
I already have a solution I prefer.
diff --git a/ChangeLog b/ChangeLog
index 406813345..421bbe9dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-07-20 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/utils/grog/grog.pl (interpret_line): Fix logic error; set
+ Boolean scalar `have_seen_first_macro_call` _after_ testing it,
+ not before, avoiding its tautological truth.
+ (infer_man_or_ms_package): Drop `TH` from list of "unique"
+ man(7) macro names. It isn't; most full-service macro packages
+ use it to manage tbl(1) headings, and we already have special
+ logic for handling it as the first call in a page anyway (where
+ it is overwhelmingly idiomatic of a man(7) document).
+
+ Fixes <https://savannah.gnu.org/bugs/?66006>. Thanks to Morten
+ Bo Johansen for the report.
+
2024-07-20 G. Branden Robinson <g.branden.robinson@gmail.com>
Regression-test Savannah #66006.
diff --git a/src/utils/grog/grog.pl b/src/utils/grog/grog.pl
index 417c1389f..9a102883e 100644
--- a/src/utils/grog/grog.pl
+++ b/src/utils/grog/grog.pl
@@ -3,7 +3,7 @@
# Inspired by doctype script in Kernighan & Pike, Unix Programming
# Environment, pp 306-8.
-# Copyright (C) 1993-2021 Free Software Foundation, Inc.
+# Copyright (C) 1993-2024 Free Software Foundation, Inc.
# Written by James Clark.
# Rewritten in Perl by Bernd Warken <groff-bernd.warken-72@web.de>.
# Hacked up by G. Branden Robinson, 2021.
@@ -346,7 +346,6 @@ sub interpret_line {
# What remains must be a macro name.
my $macro = $command;
- $have_seen_first_macro_call = 1;
$score{$macro}++;
@@ -363,6 +362,9 @@ sub interpret_line {
$man_score += 100;
}
+ # Set this here because we start returning early from here on.
+ $have_seen_first_macro_call = 1;
+
##########
# mdoc
if ($macro =~ /^Dd$/) {
@@ -506,13 +508,14 @@ sub infer_man_or_ms_package {
'XS', 'XE', 'XA', 'TC', 'PX',
'IX', 'SG');
- my @macro_man = ('BR', 'IB', 'IR', 'RB', 'RI', 'P', 'TH', 'TP', 'SS',
+ my @macro_man = ('BR', 'IB', 'IR', 'RB', 'RI', 'P', 'TP', 'SS',
'HP', 'PD',
'AT', 'UC',
'SB',
'EE', 'EX',
'OP',
'ME', 'SY', 'YS', 'TQ', 'UR', 'UE', 'MR');
+ # TH can be used by ms, mm, me, mdoc, and mom.
# MT is also used by mm.
my @macro_man_or_ms = ('B', 'I', 'BI',
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?66006>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature