From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 30599 invoked from network); 8 Aug 2023 18:05:37 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 8 Aug 2023 18:05:37 -0000 Received: from bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 916dfae6 for ; Tue, 8 Aug 2023 18:05:35 +0000 (UTC) Received: from scc-mailout-kit-01.scc.kit.edu (scc-mailout-kit-01.scc.kit.edu [129.13.231.81]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id a049027a for ; Tue, 8 Aug 2023 18:05:35 +0000 (UTC) Received: from hekate.asta.kit.edu ([2a00:1398:5:f401::77]) by scc-mailout-kit-01.scc.kit.edu with esmtps (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (envelope-from ) id 1qTR5J-001wcB-2q; Tue, 08 Aug 2023 20:05:34 +0200 Received: from login-1.asta.kit.edu ([2a00:1398:5:f400::72]) by hekate.asta.kit.edu with esmtp (Exim 4.94.2) (envelope-from ) id 1qTR5I-000GCZ-5X; Tue, 08 Aug 2023 20:05:32 +0200 Received: from schwarze by login-1.asta.kit.edu with local (Exim 4.94.2) (envelope-from ) id 1qTR5I-007h3C-5A; Tue, 08 Aug 2023 20:05:32 +0200 Date: Tue, 8 Aug 2023 20:05:32 +0200 From: Ingo Schwarze To: nabijaczleweli@nabijaczleweli.xyz Cc: tech@mandoc.bsd.lv Subject: Re: if/ie d condition always true Message-ID: References: X-Mailinglist: mandoc-tech Reply-To: tech@mandoc.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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