tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Kristaps Dzonsons <kristaps@bsd.lv>
To: tech@mdocml.bsd.lv
Subject: Re: TERMP_NOLPAD r.i.p.
Date: Mon, 19 Sep 2011 23:58:39 +0200	[thread overview]
Message-ID: <4E77BB0F.4060602@bsd.lv> (raw)
In-Reply-To: <20110919213939.GA19736@iris.usta.de>

> Kristaps drew my attention to the fact that the popt(3) manual
> is badly broken:
>
>> .HP
>> .nf
>> .BI "int poptReadDefaultConfig(poptContext " con ", int " flags ");"
>> .fi
>>
>> This looks fine in `ul', but on the raw screen it prints out lots of
>> blank space due to the flush.  Of course, it's because rmargin is
>> set to TERM_MAXMARGIN and the TERMP_NOBREAK goes nuts (in
>> print_man_node()). This can be hacked around by NOT setting rmargin
>> and only setting maxrmargin, but it still looks crappy.  Any
>> thoughts?
>
> Yes, i have come up with the following diff which might be one of the
> most beautiful i have written for mandoc so far:  I suggest to
> enhance functionality and squash bugs - by removing a flag!
>
> Specifically, as long as we have TERMP_NOLPAD, the problem at hand
> is very hard to solve, in particular in the following variant:
>
>    .nf
>    .HP 12n
>    This is a very long tag.
>    .fi
>    This is the indented text; it is of considerable length as well.
>
> With TERMP_NOLPAD, while rendering the first line of the .HP,
> term_flushln() - yes, once again my favourite function -
> overruns the column, breaks the line, and pads to the indent.
> After that, the .fi breaks the already padded line - ouch.
>
> To improve this, we should not pad until we know that we want
> to write actual content to a line, but let the next call to
> term_flushln() do the padding instead; which means that we don't
> need TERMP_NOLPAD any longer.
>
> Some of the chunks are non-obvious:
>
>   * term.c chunk @@ -130,9 +126,10 @@:
>     Always calculate the padding before starting a new line.
>     No more TERMP_NOLPAD.
>   * term.c chunk @@ -232,10 +229,14 @@:
>     An independent bugfix.  Backspace has negative length.
>     Without this, indentation does not get right.
>   * term.c chunk @@ -244,7 +245,8 @@:
>     Handle the edge case of an empty input string:
>     In that case, vis is still zero, and there is no need to go back.
>     This occurs e.g. in man(7) page headers and footers.
>   * term.c chunk @@ -269,25 +271,18 @@:
>     This is the main point.
>     No more padding at the end of term_flushln().
>   * Most other chunks just drop the obsolete flag.
>   * man_term.c chunk @@ -241,6 +241,18 @@:
>     That's the main fix for .HP indentation containing .fi/.nf,
>     and the only ugly chunk in this diff.
>     See the comment in the code what it does.
>   * man_term.c chunk @@ -452,8 +464,11 @@:
>     This adjusts the indentation width to what groff does.
>   * man_term.c chunk @@ -878,7 +889,7 @@:
>     The right margin must not be unlimited in literal mode
>     when TERMP_NOBREAK is in effect.  That avoids the long string
>     of blank characters.
>
> This patch is -65 +50 :).
>
> It reduces groff/mandoc differences in base by nearly 20%,
> from 89k to 72k lines of diffs.
>
> I see no regressions.

Ingo, wow, that's a beautiful patch!  Check it in as soon as you can. 
Tomorrow morning I'll run my own regression tests to see if I can trip 
it up and look at the code itself more carefully (I assume you did the 
usual super-long lines and so on).  But a quick lookover tonight didn't 
show anything that would concern---on the contrary, the code is much 
more readable now.  (Why didn't we do this earlier?  Meh!)

Side note: can you quickly verify that -Tps and/or -Tpdf look froody 
with the change?  They're sensitive to spacing violations.

Thanks again!

Kristaps
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

  reply	other threads:[~2011-09-19 21:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20110918161317.GE29692@iris.usta.de>
     [not found] ` <4E765AFE.9070302@bsd.lv>
2011-09-19 21:39   ` Ingo Schwarze
2011-09-19 21:58     ` Kristaps Dzonsons [this message]
2011-09-20 11:12       ` Kristaps Dzonsons
2011-09-20 11:14         ` Kristaps Dzonsons
2011-09-20 12:14         ` Ingo Schwarze
2011-09-20 12:26           ` Kristaps Dzonsons
2011-09-20 13:34             ` Ingo Schwarze
2011-09-20 14:05               ` Kristaps Dzonsons

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=4E77BB0F.4060602@bsd.lv \
    --to=kristaps@bsd.lv \
    --cc=tech@mdocml.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).