* Re: if/ie d condition always true
2023-08-05 13:37 if/ie d condition always true наб
@ 2023-08-08 18:05 ` Ingo Schwarze
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Schwarze @ 2023-08-08 18:05 UTC (permalink / raw)
To: nabijaczleweli; +Cc: tech
Hello Nab,
Nab wrote on Sat, Aug 05, 2023 at 03:37:43PM +0200:
> Happens on 1.14.6-1+b1 and some CVS HEAD version I have
> dated "Oct 26 2022":
> $ printf '%s\n' '.ie dABCD "\*[ABCD]".' '.el noabcd' | mandoc
[...]
> "".
Confirmed on OpenBSD-current, thanks for the report.
Testing with groff proves that mandoc ought to print
noabcd
instead. And indead, the following input file produces the correct
output with mandoc:
.ie dABCD \{
\*[ABCD] \}
.el noabcd
The bug in mandoc is caused by the order of evaluation.
When mandoc processes the line
.ie dABCD "\*[ABCD]".
it first calls roff_expand(), where it expands the string
using roff_getstrn(), which calls roff_setstrn() because expanding
an undefined string is required to define that string to empty.
Unfortunately, stuff like this also needs to work:
.ds c x
.ie d\*c\*c \*(\*c\*c
.el not yet;
.ds \*c\*c bingo
.ie d\*c\*c \*(\*c\*c
.el oops
This is supposed to print "not yet; bingo".
Consequently, part of the substitutions have to be done
before parsing the request (namely, in the request identifier
and in the first request argument), whereas the rest of the
substitutions, namely those in the further request arguments,
have to be done after interpreting the request - and only
if the request ends up with a true value.
This totally breaks the parsing paradigm in mandoc(1), which
always does all substitutions first, before parsing any requests
or macros. I'm sorry i so far failed to find any idea for
a quick fix.
Consequently, i'll add this to the TODO file for now.
Yours,
Ingo
--
To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread