* Re: genassym.sh(8) SYNOPSIS oops
2010-09-22 13:50 genassym.sh(8) SYNOPSIS oops Jason McIntyre
@ 2010-09-22 20:38 ` Ingo Schwarze
2010-09-23 13:48 ` Jason McIntyre
0 siblings, 1 reply; 3+ messages in thread
From: Ingo Schwarze @ 2010-09-22 20:38 UTC (permalink / raw)
To: discuss
Hi Jason,
Jason McIntyre wrote on Wed, Sep 22, 2010 at 02:49:56PM +0059:
> source:
>
> .Sh SYNOPSIS
> .Nm sh genassym.sh
> .Op Fl c
> .Ar C compiler invocation
>
> groff:
>
> SYNOPSIS
> sh genassym.sh [-c] C compiler invocation
Gah. When .Nm has more than one head argument in block mode,
groff uses only one of the arguments to calculate the indentation,
then uses -hang mode indeed to accomodate the fact that the head
is actually wider than the chosen indentation.
Old groff 1.15 uses the width of the *last* argument as the
indentation, which usually looks ugly. New groff 1.20.1
uses the width of the *first* argument instead, which clearly
looks better, because the second, indented line aligns with the
second word of the .Nm.
I suggest to follow groff 1.20.1 behaviour, so we need -hang
mode if and only if the .Nm block head has more than one child.
See below for an updated patch.
The test(1) and vi(1) pages still look fine as well.
> mandoc:
>
> sh genassym.sh
> [-c] C compiler invocation
>
> this is with ingo's last patch (the one that made vi work).
> some regression?
Indeed, good catch, thanks!
Yours,
Ingo
Index: mdoc_term.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mdoc_term.c,v
retrieving revision 1.104
diff -u -p -r1.104 mdoc_term.c
--- mdoc_term.c 20 Sep 2010 20:02:27 -0000 1.104
+++ mdoc_term.c 22 Sep 2010 20:33:26 -0000
@@ -1027,12 +1027,18 @@ termp_nm_pre(DECL_ARGS)
synopsis_pre(p, n->parent);
if (MDOC_HEAD == n->type && n->next->child) {
- p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_HANG;
- p->rmargin = p->offset + term_len(p, 1) +
- (NULL == n->child ? term_strlen(p, m->name) :
- MDOC_TEXT == n->child->type ?
- term_strlen(p, n->child->string) :
- term_len(p, 5));
+ p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
+ p->rmargin = p->offset + term_len(p, 1);
+ if (NULL == n->child) {
+ p->rmargin += term_strlen(p, m->name);
+ } else if (MDOC_TEXT == n->child->type) {
+ p->rmargin += term_strlen(p, n->child->string);
+ if (n->child->next)
+ p->flags |= TERMP_HANG;
+ } else {
+ p->rmargin += term_len(p, 5);
+ p->flags |= TERMP_HANG;
+ }
}
term_fontpush(p, TERMFONT_BOLD);
Index: term.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/term.c,v
retrieving revision 1.50
diff -u -p -r1.50 term.c
--- term.c 21 Sep 2010 22:33:41 -0000 1.50
+++ term.c 22 Sep 2010 20:33:28 -0000
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.50 2010/09/21 22:33:41 schwarze Exp $ */
+/* $Id: term.c,v 1.49 2010/08/20 23:34:00 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -130,6 +130,7 @@ term_flushln(struct termp *p)
size_t vbl; /* number of blanks to prepend to output */
size_t vend; /* end of word visual position on output */
size_t bp; /* visual right border position */
+ size_t dv; /* temporary for visual pos calculations */
int j; /* temporary loop index for p->buf */
int jhy; /* last hyph before overflow w/r/t j */
size_t maxvis; /* output position of visible boundary */
@@ -233,7 +234,9 @@ term_flushln(struct termp *p)
j = i;
while (' ' == p->buf[i])
i++;
- vbl += (i - j) * (*p->width)(p, ' ');
+ dv = (i - j) * (*p->width)(p, ' ');
+ vbl += dv;
+ vend += dv;
break;
}
if (ASCII_NBRSP == p->buf[i]) {
@@ -260,7 +263,6 @@ term_flushln(struct termp *p)
p->viscol += (*p->width)(p, p->buf[i]);
}
}
- vend += vbl;
vis = vend;
}
--
To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 3+ messages in thread