Dear Everyone, Brian Kernighan's paper "A TROFF Tutorial" goes into detail about how these things were parsed back in the day and why. This is perhaps the "accident of history"?
jen. ________________________________________ From: groff [groff-bounces+jennifer.sayers=sydney.edu...@gnu.org] on behalf of G. Branden Robinson [g.branden.robin...@gmail.com] Sent: Tuesday, 31 March 2020 12:32 PM To: Doug McIlroy Cc: groff@gnu.org Subject: Re: weird \s At 2020-03-30T19:16:56-0400, Doug McIlroy wrote: > Does anyone else see the following behavior? > Version 1.22.4 handles \s correctly up to \s39, but > truncates a size of 40 or greater to its first > digit. Here are two screen shots, with ^D edited in > to show where input ends and output begins. Hi Doug! This appears to be for backward compatibility. The 1992 revision of CSTR #54 says in §2.3: "Note that through an accident of history, a construction like \s39 is parsed as size 39, and thus converted to size 36 (given the sizes above), while \s40 is parsed as size 4 followed by 0. The syntax \s(nn and \s±(nn permits specification of sizes that would otherwise be ambiguous." As Robert Thorsby noted, this is documented in the groff Texinfo manual; however, it is not noted in the groff(7) man page, something I'm inclined to fix in the near term. To the broader group, I would furthermore suggest that, being GNU roff, it might behoove us to preserve the above "accident of history" only in compatibility mode, and have the \sn form accept only a single-digit argument for consistency with other escape forms. Doug still would have gotten into trouble, but it would have been a more easily understood trouble. What do folks think? Regards, Branden