bugGNU roff - Bugs: bug #42675, \} considered as macro argument...


bug #42675: \} considered as macro argument regarding register .$

Submitter:  None
Submitted:  Thu 03 Jul 2014 09:35:26 PM UTC
Category:  Core Severity:  2 - Minor
Item Group:  Incorrect behaviour Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)

Tue 15 Feb 2022 11:29:35 PM UTC, comment #5: 

  This is not a bug, as the results of the test cases are according to
the description of how macros work, CSTR #54, chapter 7.3.  Arguments.

Bjarni Ingi Gislason <bjarniig>
Tue 01 Dec 2020 06:49:00 PM UTC, comment #4: 

  The examples do not show a bug in the software.

  They can serve as an exercise in understanding, to give people an
opportunity to test their "solving" skills, understanding of concepts.

  So nobody should "publish" a solution, as that deprives the readers
to tackle the exercise on their own.

  Otherwise their "brain software" does not grow to be better.

  Maybe this could be put in a file called "EXERCISES".

  This issue shows (me at least), that the examples are

1) too simple in one aspect

2) too complicated in another aspect.

  And people should start (to teach themselves) to ask themselves
questions to help themselves solve "mysteries".

Bjarni Ingi Gislason <bjarniig>
Fri 19 Sep 2014 07:49:47 PM UTC, comment #3: 

Although this bug seems to be in any existing *roff implementation, it should be fixed.  At the moment the \n(.$ register can't be used in a macro that may be invoked by other users because it has a random value, which depends on if the user writes

.A \}



To make \n(.$ meaningful again and make it fit it's documentation this bug should be fixed.  This breaks "compatibility" with traditional *roff but only in cases where the input relies on side effects of this bug.  Because of it's random nature such cases are unlikely.

Carsten Kunze <carstenkunze>
Project Member
Tue 29 Jul 2014 11:18:22 AM UTC, comment #2: 
Tue 29 Jul 2014 11:16:02 AM UTC, comment #1: 
Thu 03 Jul 2014 09:35:26 PM UTC, original submission:  

(Attention: This may or may not be a bug! It could have been intentionally be introduced to groff to implement traditional nroff behavior perfectly. In this case it should be added to the documentation only.)

If a macro is used as the last statement of a conditional statement block (a block enclosed in \{ and \}), the closing \} is on the same line as the macro call and there is white space before \} the register .$ is increased by 1.

How to reproduce (thanks to Ingo Schwarze):

Minimal input file:
.de count_args
.if n \{.count_args\}
.if n \{.count_args \}
.if n \{.count_args foo\}
.if n \{.count_args foo \}

Run this through:
groff -Wall -Tascii

Output with groff-1.22.2 on OpenBSD:

  1. 1 1 2


(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 bjarniig (Posted a comment)
  • -email is unavailable- added by bgarrigues (Updated the item)
  • -email is unavailable- added by carstenkunze (Posted a comment)

    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 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.11