From: Kristaps Dzonsons <kristaps@bsd.lv>
To: tech@mdocml.bsd.lv
Cc: Ingo Schwarze <schwarze@usta.de>
Subject: Re: sync results
Date: Thu, 07 Jul 2011 12:27:27 +0200 [thread overview]
Message-ID: <4E158A0F.3060608@bsd.lv> (raw)
In-Reply-To: <20110706060332.GB29041@iris.usta.de>
[-- Attachment #1: Type: text/plain, Size: 2853 bytes --]
On 06/07/2011 08:03, Ingo Schwarze wrote:
> Hi Kristaps,
>
> Kristaps Dzonsons wrote on Tue, Jul 05, 2011 at 02:43:38PM +0200:
>> Ingo Schwarze wrote:
>
>> I'm not able to reproduce some of these.
>
>>> i'm currently syncing from bsd.lv to openbsd.org.
>>> The code looks good, and in the output, i see many improvements,
>>> so i will now commit the sync.
>>>
>>>
>>> However, there are also a three tiny regressions:
>>>
>>> cvs(1) contains this code:
>>>
>>> .TP 1i
>>> \fB?\fP \fIfile\fP
>>> \fIfile\fP is in your working directory, but does not correspond to
>>> anything in the source repository, and is not in the list of files
>>> for \fBcvs\fP to ignore (see the description of the \fB\-I\fP option).
>>> .PP
>>> .RS .5i
>>> .sp
>>> Use the
>>> .B \-A
>>> option to reset any sticky tags, dates, or
>>> .B \-k
>>> options. (If you get a working copy of a file by using one of the
>>>
>>> Now doubtless, .PP .RS .sp in a row is horrible.
>>> However, with groff and old mandoc, that gave one blank line.
>>> Now there are two.
>
>> This is not the case with my machine (groff 1.19.2).
>>
>> The following:
>>
>> .TH FOO 1
>> .SH NAME
>> foo - bar
>> .SH DESCRIPTION
>> hi.
>> .PP
>> .RS .5i
>> .sp
>> Use the
>>
>> Has two spaces between the "hi" and "Use the" with both groff and
>> mandoc (using nroff -mandoc and groff -Tascii -mandoc).
>
> That looks like a bug in groff-1.19 that has been fixed in 1.21.
> With groff-1.21 and your test code, i get one blank line between
> "hi" and "Use the", which makes more sense given the general
> tendency of roff to compress multiple blank lines to one.
>
>>> lynx(1) contains this code:
>>>
>>> .TP
>>> .B \-cookie_file\fR=\fIFILENAME
>>> specifies a file to use to read cookies.
>>>
>>> In groff and old mandoc, the indent of "specifies" relative to "-cookie"
>>> was 7, now it is 5.
>
>> Are you sure? I just ran this code and had both mandoc and groff
>> align "specifies" under the underscore, i.e., 7 spaces.
>
> Yes, with both OpenBSD and bsd.lv mandoc, i get the "specifies"
> aligned under the "i" in "-cookie_file". I'm just noticing
> that the change in alignment happens about two dozen lines above,
> below "-cmd_script". The "comment beginning with..." is still
> aligned at 7 (below the 'r'), the "exit" is aligned at 5 (below
> the 's').
Ingo, this was a bit tricky.
It seems I've neglected that `RS' saves the current default-left-margin,
restoring it on output. The enclosed patch introduces a stack of `RS'
default-left-margins. The stack overflows neatly: if there are too many
nested `RS' scopes, it stops nesting but keeps track of what the stack
would be. When the stack drops below overflow, nesting is reenabled. I
set the current max stack to 64.
This should clean up output a great deal when the `RS' is used with
embedded paragraphs.
Thoughts?
Kristaps
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 4415 bytes --]
Index: man_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_term.c,v
retrieving revision 1.113
diff -u -r1.113 man_term.c
--- man_term.c 3 Jul 2011 22:57:32 -0000 1.113
+++ man_term.c 7 Jul 2011 10:27:14 -0000
@@ -33,29 +33,19 @@
#include "term.h"
#include "main.h"
-#define INDENT 7
-#define HALFINDENT 3
+#define INDENT 7 /* fixed-width char full-indent */
+#define HALFINDENT 3 /* fixed-width char half-indent */
+#define MAXMARGINS 64 /* maximum number of indented scopes */
/* FIXME: have PD set the default vspace width. */
struct mtermp {
int fl;
#define MANT_LITERAL (1 << 0)
- /*
- * Default amount to indent the left margin after leading text
- * has been printed (e.g., `HP' left-indent, `TP' and `IP' body
- * indent). This needs to be saved because `HP' and so on, if
- * not having a specified value, must default.
- *
- * Note that this is the indentation AFTER the left offset, so
- * the total offset is usually offset + lmargin.
- */
- size_t lmargin;
- /*
- * The default offset, i.e., the amount between any text and the
- * page boundary.
- */
- size_t offset;
+ size_t lmargin[MAXMARGINS]; /* margins (incl. visible page) */
+ int lmargincur; /* index of current margin */
+ int lmarginsz; /* actual number of nested margins */
+ size_t offset; /* default offset to visible page */
};
#define DECL_ARGS struct termp *p, \
@@ -164,8 +154,9 @@
term_begin(p, print_man_head, print_man_foot, m);
p->flags |= TERMP_NOSPACE;
- mt.fl = 0;
- mt.lmargin = term_len(p, INDENT);
+ memset(&mt, 0, sizeof(struct mtermp));
+
+ mt.lmargin[mt.lmargincur] = term_len(p, INDENT);
mt.offset = term_len(p, INDENT);
if (n->child)
@@ -456,7 +447,7 @@
return(0);
}
- len = mt->lmargin;
+ len = mt->lmargin[mt->lmargincur];
ival = -1;
/* Calculate offset. */
@@ -472,7 +463,7 @@
p->rmargin = mt->offset + len;
if (ival >= 0)
- mt->lmargin = (size_t)ival;
+ mt->lmargin[mt->lmargincur] = (size_t)ival;
return(1);
}
@@ -507,7 +498,7 @@
switch (n->type) {
case (MAN_BLOCK):
- mt->lmargin = term_len(p, INDENT);
+ mt->lmargin[mt->lmargincur] = term_len(p, INDENT);
print_bvspace(p, n);
break;
default:
@@ -542,7 +533,7 @@
return(1);
}
- len = mt->lmargin;
+ len = mt->lmargin[mt->lmargincur];
ival = -1;
/* Calculate the offset from the optional second argument. */
@@ -563,7 +554,7 @@
break;
/* Set the saved left-margin. */
- mt->lmargin = (size_t)ival;
+ mt->lmargin[mt->lmargincur] = (size_t)ival;
savelit = MANT_LITERAL & mt->fl;
mt->fl &= ~MANT_LITERAL;
@@ -631,18 +622,15 @@
return(1);
}
- len = (size_t)mt->lmargin;
+ len = (size_t)mt->lmargin[mt->lmargincur];
ival = -1;
/* Calculate offset. */
- if (NULL != (nn = n->parent->head->child)) {
- while (nn && MAN_TEXT != nn->type)
- nn = nn->next;
- if (nn && nn->next)
+ if (NULL != (nn = n->parent->head->child))
+ if (nn->parent->line == nn->line)
if ((ival = a2width(p, nn->string)) >= 0)
len = (size_t)ival;
- }
switch (n->type) {
case (MAN_HEAD):
@@ -663,9 +651,8 @@
if (savelit)
mt->fl |= MANT_LITERAL;
-
if (ival >= 0)
- mt->lmargin = (size_t)ival;
+ mt->lmargin[mt->lmargincur] = (size_t)ival;
return(0);
case (MAN_BODY):
@@ -710,7 +697,7 @@
switch (n->type) {
case (MAN_BLOCK):
mt->fl &= ~MANT_LITERAL;
- mt->lmargin = term_len(p, INDENT);
+ mt->lmargin[mt->lmargincur] = term_len(p, INDENT);
mt->offset = term_len(p, INDENT);
/* If following a prior empty `SS', no vspace. */
if (n->prev && MAN_SS == n->prev->tok)
@@ -761,7 +748,7 @@
switch (n->type) {
case (MAN_BLOCK):
mt->fl &= ~MANT_LITERAL;
- mt->lmargin = term_len(p, INDENT);
+ mt->lmargin[mt->lmargincur] = term_len(p, INDENT);
mt->offset = term_len(p, INDENT);
/* If following a prior empty `SH', no vspace. */
if (n->prev && MAN_SH == n->prev->tok)
@@ -830,6 +817,10 @@
mt->offset += sz;
p->offset = mt->offset;
+ if (++mt->lmarginsz < MAXMARGINS)
+ mt->lmargincur = mt->lmarginsz;
+
+ mt->lmargin[mt->lmargincur] = mt->lmargin[mt->lmargincur - 1];
return(1);
}
@@ -858,6 +849,9 @@
mt->offset = mt->offset < sz ? 0 : mt->offset - sz;
p->offset = mt->offset;
+
+ if (--mt->lmarginsz < MAXMARGINS)
+ mt->lmargincur = mt->lmarginsz;
}
static void
next prev parent reply other threads:[~2011-07-07 10:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-04 22:45 Ingo Schwarze
2011-07-05 12:43 ` Kristaps Dzonsons
2011-07-05 14:06 ` Kristaps Dzonsons
2011-07-07 4:13 ` Ingo Schwarze
2011-07-06 6:03 ` Ingo Schwarze
2011-07-07 10:27 ` Kristaps Dzonsons [this message]
2011-07-07 21:11 ` Ingo Schwarze
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=4E158A0F.3060608@bsd.lv \
--to=kristaps@bsd.lv \
--cc=schwarze@usta.de \
--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).