bugGNU roff - Bugs: bug #65469, [man] poor choice of escape...

 
 

bug #65469: [man] poor choice of escape character in `an*scan-string-for-backslash`

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Sun 17 Mar 2024 01:25:03 AM UTC
   
 
Category:  Macro man Severity:  2 - Minor
Item Group:  Warning/Suspicious behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.24.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 17 Mar 2024 10:00:37 PM UTC, comment #1: 


commit 63d3e6e0e1ea25b94d23cde3188ff0f1be18c0bf
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sat Mar 16 20:35:24 2024 -0500

    [man]: Fix Savannah #65469.

    Given a second chance, try to avoid Walter Donovan's fate.

    * tmac/an.tmac (an*scan-string-for-backslash): Choose an escape
      character that is much less likely than the at sign to be specified in
      a man(7) document's page footer.

    Fixes <https://savannah.gnu.org/bugs/?65469>.  Thanks to Thomas Dickey
    for the report.

commit 6ffa91c24fa37ceaec2c9ae4ee14a7d515907342
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sat Mar 16 20:31:58 2024 -0500

    [tmac]: Regression-test Savannah #65469.

    * tmac/tests/an_inner-footer-abbreviation-works.sh: Add regression test
      case for Savannah #65469.

    Test fails at this commit.


G. Branden Robinson <gbranden>
Group administrator
Sun 17 Mar 2024 01:25:03 AM UTC, original submission:  

Noted by Thomas Dickey on the bug-ncurses@gnu list.


$ sed -n 31p ./man/tic.1m
.TH @TIC@ 1M 2023-12-30 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
$ ~/groff-stable/bin/nroff -ww -mandoc ./man/tic.1m | tail -n 1
troff:./man/tic.1m:31: warning: missing closing delimiter in output comparison operator (got a newline)
troff:./man/tic.1m:31: warning: missing closing delimiter in output comparison operator (got a newline)
troff:./man/tic.1m:31: warning: missing closing delimiter in output comparison operator (got a newline)
troff:./man/tic.1m:31: warning: missing closing delimiter in output comparison operator (got a newline)
ncurses @NCURSES_MAJOR@.@NCURS... 2023‐12‐30                         @TIC@(1M)


The good news is that the macro and its parent (`an*abbreviate-inner-footer`) still work as intended, at least for this input.  I haven't reasoned out carefully if they will for any input containing `@` characters.

The unfortunate bit is of course the spurious diagnostic messages.  They aren't the user's fault and we shouldn't be throwing them.

My choice of `@` for the alternate escape character was poor.

Until we get a string iterator (bug #62264), and then can write things like index(3) or strchr(3) in *roff, I don't think there is a good solution for this.  Any character that is valid in a man page footer is a valid escape character.  (In fact, the latter is a subset of the former.)

But, in the meantime, I can pick a valid escape character that is unlikely to be used by any sane person for sed(1) substitutions in man page text.

...the delete character, U+007F.  I've tested this and it works.


diff --git a/tmac/an.tmac b/tmac/an.tmac
index fab6fdd64..3cfdc2a84 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -537,9 +537,9 @@ .de an*scan-string-for-backslash
 .  while (\\n[an*index] < \\n[an*max-index]) \{\
 .    ds an*char \\$*
 .    substring an*char \\n[an*index] \\n[an*index]
-.    ec @
+.    ec ^?
 .    \" Use a weird delimiter to reduce lexical colorizer confusion.
-.    if _@*[an*char]_\\_ .nr an*string-contains-backslash 1
+.    if _^?*[an*char]_\\_ .nr an*string-contains-backslash 1
 .    ec
 .    if \\n[an*string-contains-backslash] .break
 .    nr an*index +1
$ ./build/test-groff -ww -mandoc -Tutf8 ../ncurses-snapshots/man/tic.1m | tail -n 1
ncurses @NCURSES_MAJOR@.@NCURSE... 2023‐12‐30                          @TIC@(1M)


So that's what I'll do.

G. Branden Robinson <gbranden>
Group administrator

 

(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 (Submitted the item)
  • -email is unavailable- added by gbranden (original reporter)
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-03-17 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.24.0
    2024-03-17 gbranden Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code