bugGNU roff - Bugs: bug #66526, [troff] interprets conditional...

 
 

bug #66526: [troff] interprets conditional expressions starting with `|` differently from AT&T troff

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Wed 04 Dec 2024 09:22:40 AM UTC
   
 
Category:  Core Severity:  3 - Normal
Item Group:  Incorrect behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.24.0
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

Thu 06 Nov 2025 12:06:33 PM UTC, comment #4: 


commit 85d248e5e5c3a105769a465d8884ba351294c798
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Tue Nov 4 10:19:03 2025 -0600

    [troff]: Fix spurious "delim" warning.

    * src/roff/troff/input.cpp (token::is_usable_as_delimter): Fix spurious
      warning in category "delim" when using a tab character as an escape
      sequence as a delimiter.  AT&T troff allows that, and so has GNU troff
      historically.

    Continues commit 39c1176bfa, 25 January.  See Savannah #66686 and
    Savannah #66526.

    $ for v in 1.22.3 1.22.4 1.23.0 HEAD; do printf '\\o\tabc\tdef' \
      | ~/groff-$v/bin/nroff -wdelim; done | sed '/^$/d'
    cdef
    cdef
    cdef
    troff:<standard input>:1: warning: interpreting a tab character as an escape sequence delimiter; it is ambiguous because it can also begin a numeric expression
    cdef


G. Branden Robinson <gbranden>
Group administrator
Tue 28 Jan 2025 08:38:00 AM UTC, comment #3: 


commit 39c1176bfa9ba84d519b015b1453f316e013d1de
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Mon Jan 27 18:52:39 2025 -0600

    [troff]: Fix Savannah #66686 (`\w|foo|` blues).

    * src/roff/troff/input.cpp (is_char_usable_as_delimiter): Restore `|`
      character as an invalid delimiter when not in compatibility mode.
      This would regress the fix for Savannah #66481, but...

      (do_overstrike, do_bracket, do_name_test, do_zero_width_output)
      (read_size, do_register, do_width, do_device_extension)
      (read_drawing_command): Throw warning in "delimiter" category and
      explain ambiguity of delimiter instead of emitting error and refusing
      further interpretation of the escape sequence being parsed.  Leave
      behind "#if"ed code for restoration of former stricter behavior in a
      future groff release (which would fix Savannah #66009).

      (is_conditional_expression_true): Stop special-casing an exception for
      `|` that permitted it to be used as a formatted output comparison
      operator.  Savannah #66481 complained only about groff's rejection of
      `|` to delimit the argument to the `\w` (width measurement) escape
      sequence, not in general, and was seen in some man pages.  The usage
      Paul Eggert reported remains accepted, albeit warned about, per
      `do_width()` above.

    * src/roff/groff/tests/check-delimiter-validity.sh: Update test
      expectations.  We now expect `|` to be invalid once again to delimit a
      line-drawing escape sequence.

    Fixes <https://savannah.gnu.org/bugs/?66686>.  Thanks to Dave Kemper for
    the report.  Savannah #66526 is implicated.

    The uses of `\w|whatever|` cited by Eggert appear to be a chunk of
    boilerplate passed around by some man page authors for GNU man pages.
    Eggert's "tz" package doesn't itself use `|` as a delimiter, but I did
    verify their use in gawk, grep, and rcs.

    gawk:
    .if !\n(.g \{\
    .       if !\w|\*(lq| \{\
    .               ds lq ``
    .               if \w'\(lq' .ds lq "\(lq
    .       \}
    .       if !\w|\*(rq| \{\
    .               ds rq ''
    .               if \w'\(rq' .ds rq "\(rq
    .       \}
    .\}

    grep:
    .if !\w|\*(lq| \{\
    .\" groff an-old.tmac does not seem to be in use, so define lq and rq.
    .       ie \n(.g \{\
    .               ds lq \(lq\"
    .               ds rq \(rq\"
    .       \}
    .       el \{\
    .               ds lq ``
    .               ds rq ''
    .       \}
    .\}

    rcs:
    .if !\n(.g \{\
    .       if !\w|\*(lq| \{\
    .               ds lq ``
    .               if \w'\(lq' .ds lq "\(lq
    .       \}
    .       if !\w|\*(rq| \{\
    .               ds rq ''
    .               if \w'\(rq' .ds rq "\(rq
    .       \}
    .\}

    One observes that only grep(1) doesn't feature-gate its use of `\w|foo|`
    behind a test of the `.g` register (groff-compatible formatter) for
    falsity.  It is therefore the only one of these three that would have
    provoked a warning.  (What the foregoing do is reimplement the `lq` and
    `rq` quotation strings, an extension from 4BSD (1980)--my guess is to
    compensate for System V-based troffs missing them).

    The rcs man pages otherwise use `\w` pretty extensively (which can be
    its own portability worry), but in every other case with the unambiguous
    `'` delimiter.

commit 1eed3cceaaa38e095e2b265cda846842853525e4
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Tue Jan 28 00:57:03 2025 -0600

    [doc,man]: Report new delimiter warning scenario.


G. Branden Robinson <gbranden>
Group administrator
Thu 05 Dec 2024 02:12:03 AM UTC, comment #2: 

Thanks, Dave.  Who knows, maybe some day that Platonic dialogue will get a Norton Critical Edition.


commit ea1e00de47b376560267b9e1390ee2613fdedccf
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Wed Dec 4 04:31:34 2024 -0600

    [troff]: Fix Savannah #66526 (`|` handling).

    * src/roff/troff/input.cpp (is_conditional_expression_true): Stop
      treating `|` as a delimiter, but instead as beginning a numeric
      expression, _only_ as the predicate of a control structure request.
      Improves compatibility with AT&T troff, including DWB 3.3 and Heirloom
      Doctools.  Problem appears to date back to groff 1.02.

      GNU troff has long thrown diagnostics in this context, of increasing
      detail in recent years.  For example:

      troff:mm/0.MT:271: warning: missing closing delimiter in output
        comparison operator; expected character '|', got a newline

      However, this was easily overlooked in our automated tests because it
      didn't break formatting, except on Solaris 10 (or if you ran the
      post-1.23.0 test "contrib/mm/tests/memoranda-format-correctly.sh"
      with an older groff release).

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


There's a minor factual error in the penultimate paragraph ("However"); I'll push a fix to the ChangeLog.  The formatting wasn't broken at all (though there are scenarios where it could have been, heretofore never complained about AFAIK).  The problem was Solaris cksum(1) not behaving like everyone else's.

G. Branden Robinson <gbranden>
Group administrator
Wed 04 Dec 2024 10:28:44 PM UTC, comment #1: 


$ groff --version | head -1
GNU groff version 1.19.2
$ printf '.ie |1i>0 .tm yes\n.el .tm no\n' | groff -ww
<standard input>:1: warning: missing closing delimiter
no


Dave <barx>
Group Member
Wed 04 Dec 2024 09:22:40 AM UTC, original submission:  

-- A Platonic semi-dialogue --

Is one inch greater than zero?


$ printf '.ie |1i>0 .tm yes\n.el .tm no\n' | ./build/test-groff -ww
troff:<standard input>:1: warning: missing closing delimiter in output comparison operator; expected character '|', got a newline
no


Damn it, Branden, your naïve and ill-considered so-called reforms to groff break everything everywhere all the time and I'm sick of it.  You should resign as maintainer.


$ printf '.ie |1i>0 .tm yes\n.el .tm no\n' | ~/groff-1.23.0/bin/groff -ww
troff:<standard input>:1: warning: missing closing delimiter in output comparison operator (got a newline)
no


I've had it up to here!  Just sick of your nonsense.  Seven years of long emails, obscure jokes, and detestable politics.  When Trump's hillbilly MAGA squads beat you to a pulp, I'll laugh.


$ printf '.ie |1i>0 .tm yes\n.el .tm no\n' | ~/groff-1.22.4/bin/groff -ww
troff: <standard input>:1: warning: missing closing delimiter
no


Wait--hang on...


$ printf '.ie |1i>0 .tm yes\n.el .tm no\n' | ~/groff-1.22.3/bin/groff -ww
<standard input>:1: warning: missing closing delimiter
no


STOP!  Yeah, well, I never liked groff anyway.


$ printf '.ie |1i>0 .tm yes\n.el .tm no\n' | ~/heirloom/bin/nroff
yes
$ printf '.ie |1i>0 .tm yes\n.el .tm no\n' | DWBHOME=~/dwb ~/dwb/bin/nroff
yes
$ pdp11 ./boot.simh

PDP-11 simulator V3.8-1
Disabling XQ
@boot
New Boot, known devices are hp ht rk rl rp tm vt
: rl(0,0)rl2unix
mem = 177856
# Restricted rights: Use, duplication, or disclosure
is subject to restrictions stated in your contract with
Western Electric Company, Inc.
Thu Sep 22 23:16:01 EDT 1988

login: dmr
$ nroff <<EOF
> .ie |1i>0 .tm yes
> .el .tm no
> EOF
yes
$
login:
Simulation stopped, PC: 002306 (MOV (SP)+,177776)
sim> quit
Goodbye


See?!  Other troffs are better and always have been.  I haven't typeset anything in 20 years, or maybe ever, but one day I will, and my links won't be pointing anywhere you have anything to do with!

I'd rather be using Seventh Edition anyway than any of this kopyleft krap!  I know who the thought leaders are and I'll be following them.  Brogrammer strong!

--end of semi-dialogue--

So, melodramatis personae aside, this goes way back.  And apparently has seldom or never been noticed or remarked upon.  I think it constitutes further evidence that GNU troff should retire support for "weird" delimiters, except in AT&T compatibility mode.  See bug #66009.

G. Branden Robinson <gbranden>
Group administrator

 

Attached Files

This item currently has no attached files.

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

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

    Votes

    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.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

    History

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-05-10 gbranden SummaryGNU troff misinterprets conditional expressions starting with `|` [troff] interprets conditional expressions starting with `|` differently from AT&T troff
    2024-12-05 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.24.0
    2024-12-04 gbranden StatusNone In Progress
        Assigned toNone gbranden

    Back to the top

    Powered by Savane 3.16-598c.
    Corresponding source code