bugGNU roff - Bugs: bug #59622, grog: incorrectly infers man pages...

 
 

bug #59622: grog: incorrectly infers man pages produced by pod2man

Submitter:  Bjarni Ingi Gislason <bjarniig>
Submitted:  Fri 04 Dec 2020 06:33:28 PM UTC
   
 
Category:  Utilities Severity:  3 - Normal
Item Group:  Incorrect behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.23.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 30 Jun 2021 09:49:41 AM UTC, comment #4: 


commit b0de53c923bfd77191157f6caacff984e8ca5e82
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Wed Jun 30 19:30:00 2021 +1000

    [grog]: Refactor input parsing.

    * src/utils/grog/grog.pl:
      - Add scalar `use_compatibility_mode` (see below).
      - Add list `request` to store the names of all requests recognized by
        groff so that they aren't confused with macro names.
      - Add scalars `have_seen_first_macro_call` (replaces
        `before_first_command`, but at global scope), `is_continued_line`
        and `logical_line`.  The latter two enable us to handle *roff input
        line continuation correctly.

      (process_arguments): Set `use_compatibility_mode` if `-C` option
      specified.

      (process_input): Refactor to greatly simplify, to not attempt to read
      the first line of an input file as a special case, and to avoid
      sending `do_line` an undefined argument (when EOF is reached).

      (do_first_line): Delete.

      (do_line): Rewrite the early stages of input parsing.
      - Concatenate continued input lines, setting `is_continued_line` and
        returning early as each one is seen, storing the accumulating input
        in `logical_line`.
      - Check the input line for the form of comment deposited by Perl's
        Pod::Man, which uses a highly accented dialect of man(7); if it's
        present, inflate `man_score` to compensate for the page-private `IX`
        macro it defines but which duplicates the name and function of a
        4.2BSD-era ms(7) extension that would otherwise deceives our scoring
        mechanism, because Pod::Man produces `IX` calls to metastatic
        excess.  (An alternative to this kludge is documented in comments:
        if a "standard" macro is redefined, we could delete it from the
        relevant lists and hashes.)
      - Strip *roff comments from input.
      - Normalize control lines; convert the no-break control character to
        the regular one and remove unnecessary white space.
      - Remove brace escapes.
      - Recognize two-character macro calls when not followed by white space
        in compatibility mode.
      - Drop logic that erroneously attempted to infer soelim(1) use from
        macro calls and request invocations.  The grog(1) and soelim(1) man
        pages now both explain why such an effort was misguided.
      - Recognize macro definitions created by .am and .am1 requests (not
        just .de and .de1).
      - Ignore all other *roff requests.
      - What remains must be a ("standard") macro call, so set
        `have_seen_first_macro_call`.

    * src/utils/grog/grog.1.man (Limitations): Document a further
      restriction: don't change the escape character, either.

    * src/utils/grog/tests/smoke-test.sh: Comment out pic-detection test on
      soelim(1).  The pic macro calls are guarded by roff control structures
      and only worked previously by accident because grog did not recognize
      *roff input line continuation, now it does and the illusion is
      dispelled.  (A reliable way to fool grog before and after my
      refactoring is now documented in its man page.)

    Fixes <https://savannah.gnu.org/bugs/?59622>.


G. Branden Robinson <gbranden>
Group administrator
Wed 30 Jun 2021 05:40:59 AM UTC, comment #3: 

I have a fix for this.

G. Branden Robinson <gbranden>
Group administrator
Tue 29 Jun 2021 03:10:04 AM UTC, comment #2: 

The supplied patch is inappropriate since it is not conditional on the input document being a man page.  It's hard to know that so early in the input stream.  Relying upon the form of the filename was not reliable and that code is now removed anyway.

We need a better way to avoid being misled by all of the non-man(7) noise that pod2man injects into man pages.  I'm thinking about the problem.

G. Branden Robinson <gbranden>
Group administrator
Mon 07 Jun 2021 09:49:36 PM UTC, comment #1: 

Categorizing grog bugs as Utilities, per discussion.

Dave <barx>
Group Member
Fri 04 Dec 2020 06:33:28 PM UTC, original submission:  

From 69de136e8f07ba85d4251f8a171d9c9274d159f3 Mon Sep 17 00:00:00 2001
From: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Date: Fri, 4 Dec 2020 18:19:58 +0000
Subject: [PATCH] grog/subs.pl: Ignore lines added in front of ".TH" by
 "pod2man"

  groff/src/roff/grog/subs.pl: Ignore lines added in front of ".TH" by
the perl module "Pod::Man" (pod2man)

  Fixes wrong results for manuals, that are made with the current
"pod2man" command.

  See bug #55302 for the initial report.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 src/roff/grog/subs.pl | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/roff/grog/subs.pl b/src/roff/grog/subs.pl
index 65108e38..65e55e78 100644
--- a/src/roff/grog/subs.pl
+++ b/src/roff/grog/subs.pl
@@ -567,6 +567,11 @@ sub do_line {
   return if ( $line =~ /^\.$/ );        # ignore .
   return if ( $line =~ /^\.\.$/ );        # ignore ..

+  # Ignore "Standard preamble" from the perl module "Pod::Man" (pod2man)
+  return if ( $line =~ /^\.[[:lower:]]/ );
+  return if ( $line =~ /^\.\s*\\}/ );
+  return if ( $line =~ /^\.IX / );
+
   if ( $before_first_command ) { # so far without 1st command
     if ( $line =~ /^\.TH/ ) {
       # check if .TH is 1st command for man
--
2.29.2


Bjarni Ingi Gislason <bjarniig>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Posted a comment)
  • -email is unavailable- added by bjarniig (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-06-30 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.23.0
    2021-06-30 gbranden StatusConfirmed In Progress
    2021-06-29 gbranden StatusNone Confirmed
        Assigned toNone gbranden
        Summary[PATCH] grog/subs.pl: Ignore lines added in front of &quot;.TH&quot; by &quot;pod2man&quot; grog: incorrectly infers man pages produced by pod2man
    2021-06-07 barx Carbon-CopyRemoved 93119 -
    2021-06-07 barx CategoryCore Utilities

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code