groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [mdoc]: Emit diagnostic if .Mt given no arguments.


From: Ingo Schwarze
Subject: Re: [mdoc]: Emit diagnostic if .Mt given no arguments.
Date: Sun, 20 Dec 2020 16:38:05 +0100

Hi Branden,

G. Branden Robinson wrote on Sun, Dec 20, 2020 at 03:38:56AM -0500:

> gbranden pushed a commit to branch master
> in repository groff.
> 
> commit 854fec5025af62c6ba6b72f9075bc71317d83a60
> Author: G. Branden Robinson <g.branden.robinson@gmail.com>
> AuthorDate: Sun Dec 20 18:57:05 2020 +1100
> 
>     [mdoc]: Emit diagnostic if .Mt given no arguments.
>     
>     * tmac/doc.tmac-u (Mt): Emit a usage diagnostic and return if called
>       with no arguments.  This introduces an incompatiblility with
>       mandoc(1),

That's not a serious problem, mandoc(1) is easy to adjust in this case
after the behaviour of groff is improved.

>       but the existing behavior (print an italicized tilde,
>       because Mt is implemented as a wrapper around Pa, which prints
>       pathnames) made no sense.

I do not object to that opinion.

>       mandoc(1) prints a _non_-italicized tilde in this scenario.

You are mistaken, mandoc(1) is fully compatible with groff(1) in this
respect.  The output is byte-by-byte identical, and in fact mandoc(1)
was made bug-compatible with groff(1) in this respect, on purpose:

   $ echo .Mt | mandoc -mdoc | hexdump -C
  [...]
  00000050  5f 08 7e 0a 0a 0a        |_.~...|

That _is_ underscore - backspace - tilde, i.e., an italicized tilde,
exactly like in groff.

[...]
> diff --git a/tmac/doc.tmac-u b/tmac/doc.tmac-u
> index a5fd82d..eab0c27 100644
> --- a/tmac/doc.tmac-u
> +++ b/tmac/doc.tmac-u
> @@ -6444,8 +6444,10 @@
>  .\" NS   mailto (for conversion to HTML)
>  .
>  .de Mt
> -.  \" XXX: error handling missing
> -.  Pa \$@
> +.  ie !\n[.$] \
> +.    tm mdoc usage error: .Mt email-address (#\n[.c])
> +.  el \
> +.    Pa \$@
>  ..

I do not object to your general ideas of requiring an argument
nor of emitting a warning if the argument is missing.
Maybe even your decision of not printing anything if the argument
is missing is acceptable.

But unfortunately, your implementation is incorrect.
The following still prints the tilde:

  .Mt .

The reason is that many mdoc(7) macros implement generic handling for
trailing punctuation, which you apparently failed to consider.
So even the multiple-argument macro

  .Mt . , : ; ) ] ? ! ) \. ) ) \*(Ba ) )

still needs to be regarded as empty.  Implementing that correctly
is no doubt possible.  On first sight, i'm not sure how difficult
that might be and whether it's worth doing.

Either way, i don't think your commit can remain as it is.

Yours,
  Ingo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]