bugGNU troff - Bugs: bug #44714, compatibility mode: .do request...


bug #44714: compatibility mode: .do request and macro expansion via \* collide

Submitted by:  Werner LEMBERG <wl>
Submitted on:  Fri 03 Apr 2015 02:03:22 PM UTC  
Category:  Core Severity:  2 - Minor
Item Group:  Incorrect behaviour Status:  Confirmed
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Fri 03 Apr 2015 02:03:22 PM UTC, original submission:  

Consider the following snippet.

.de1 aa
.  tm compatibility mode = '\\n(.C'
.cp 1
.do tm

The expected output is

compatibility mode = '0'

since macro `.aa` is defined with `.de1`.  However, due to a bug in troff you get

compatibility mode = '1'


Reason of the problem is a clash between the `.do` request and the immediately following macro expansion via `\*`.

  1. In `src/roff/troff/input.cpp`, function `do_request` resets `compatible_flag` after calling `interpolate_macro` (which handles the argument of `.do`).
  2. `interpolate_macro` calls `token::next` to get the next input token, and this function expands `\*(aa` and processes tokens until it gets a 'real' one. 
  3. Since `aa` is defined with the `de1` request, it starts internally with a `PUSH_GROFF_MODE` pseudo-character that makes troff save the compatibility flag and switch off compatibility mode.  Unfortunately, this happens too early, and `do_request` overrides this.

An easy work-around is to insert a no-op line.

.do tm

Alas, fixing this bug is not trivial, as far as I can see; it's probably necessary to redesign the compatibility mode handling.

Werner LEMBERG <wl>
Project Administrator


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

Attach Files:

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 bgarrigues (Updated the item)
  • -email is unavailable- added by wl (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-11-26 bgarrigues CategoryNone => Core
        Severity3 - Normal => 2 - Minor
        Item GroupNone => Incorrect behaviour

    Back to the top

    Powered by Savane 3.6