tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: nabijaczleweli@nabijaczleweli.xyz
Cc: tech@mandoc.bsd.lv
Subject: Re: if/ie d condition always true
Date: Tue, 8 Aug 2023 20:05:32 +0200	[thread overview]
Message-ID: <ZNKD7IGXiRa4Q6w2@asta-kit.de> (raw)
In-Reply-To: <gzydmrf7b2gh3jyearlg4gla2nz4jipg5zxkzce3ogcqhtet2n@volord55pew6>

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


      reply	other threads:[~2023-08-08 18:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-05 13:37 наб
2023-08-08 18:05 ` Ingo Schwarze [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZNKD7IGXiRa4Q6w2@asta-kit.de \
    --to=schwarze@usta.de \
    --cc=nabijaczleweli@nabijaczleweli.xyz \
    --cc=tech@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).