On Friday, 1 May 2026 01:28:19 BST Sebastien Peterson-Boudreau wrote:
> Working with the ms macros, I'm getting a weird error whenever I try to
> rename or alias the NH macro. Here is a minimal example:
> 
>       $ groff -ms >/dev/null <<EOF
>       .rn NH FOO
>       .FOO
>       foo
>       EOF
>       troff:<standard input>:2: fatal error: input stack limit of 1000 
levels
>       exceeded (probable infinite loop)
> 
>       $ groff -ms >/dev/null <<EOF
>       .als FOO NH 
>       .FOO
>       foo
>       EOF
>       troff:<standard input>:2: fatal error: input stack limit of 1000 
levels
>       exceeded (probable infinite loop)
> 
> Any experts know why this happens? Is it expected, or a bug?

Hi Sebastian,

The ms.ps document says:-

1.1. Basic information
Prepare an ms document with your preferred text editor. Call an ms macro early 
in the document to initialize the package. A macro is a formatting instruction 
to ms. Put a macro call on a line by itself with a dot before its name. Use PP 
if you want your paragraph’s first line indented, or LP if you don’t. Then 
type text normally. 

If you put .LP at the start of your document the error is resolved. Now for 
the technical reason why you get an infinite loop!

When ms starts up most of its macros are aliased to LP, (to prevent using them 
before the first real LP). So your aliasing/renaming actually points FOO to 
LP. The first call to LP eventually results in NH being aliased to @NH (the 
real guts of what NH does) and LP being aliased to @LP, but your alias occurs 
before that has happened. This confuses ms as much as it confuses me! But the 
result is that a loop is formed with FOO/LP calling itself.

The moral of the story is to always use one of the macros initially aliased to 
LP (or LP itself) first (after using the macros for the cover - if any).

Cheers

Deri




  • ... Sebastien Peterson-Boudreau
    • ... Deri via discussion of the GNU roff typesetting system and related software
      • ... Sebastien Peterson-Boudreau
        • ... Deri via discussion of the GNU roff typesetting system and related software

Reply via email to