summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-03-23 12:42:22 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-03-23 12:42:22 +0000
commit6adf409de7c4eda9b16c15d90820919fcd5150c2 (patch)
tree08bad15d230798bc76393f462b61e09c6e399597
parent27be359286baae838840a62e6c36dac6b91cd810 (diff)
downloadmandoc-6adf409de7c4eda9b16c15d90820919fcd5150c2.tar.gz
mandoc-6adf409de7c4eda9b16c15d90820919fcd5150c2.tar.zst
mandoc-6adf409de7c4eda9b16c15d90820919fcd5150c2.zip
Fixed two very subtle bugs in retaining overstep and maxrmargin widths between parse sequences.
-rw-r--r--man_term.c7
-rw-r--r--mdoc_term.c5
-rw-r--r--term.c30
-rw-r--r--term.h3
4 files changed, 25 insertions, 20 deletions
diff --git a/man_term.c b/man_term.c
index c15354c3..2e7397e0 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.57 2010/03/23 11:30:48 kristaps Exp $ */
+/* $Id: man_term.c,v 1.58 2010/03/23 12:42:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -156,10 +156,12 @@ terminal_man(void *arg, const struct man *man)
p = (struct termp *)arg;
+ p->overstep = 0;
+ p->maxrmargin = 65;
+
if (NULL == p->symtab)
switch (p->enc) {
case (TERMENC_ASCII):
- p->maxrmargin = 65;
p->symtab = chars_init(CHARS_ASCII);
break;
default:
@@ -883,6 +885,7 @@ print_man_head(struct termp *p, const struct man_meta *m)
size_t buflen, titlen;
p->rmargin = p->maxrmargin;
+
p->offset = 0;
buf[0] = title[0] = '\0';
diff --git a/mdoc_term.c b/mdoc_term.c
index 09dbb0b7..699d5c00 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.110 2010/01/30 08:42:21 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.111 2010/03/23 12:42:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -270,6 +270,9 @@ terminal_mdoc(void *arg, const struct mdoc *mdoc)
p = (struct termp *)arg;
+ p->overstep = 0;
+ p->maxrmargin = 78;
+
if (NULL == p->symtab)
switch (p->enc) {
case (TERMENC_ASCII):
diff --git a/term.c b/term.c
index ff265457..1421843f 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.128 2010/01/01 17:14:30 kristaps Exp $ */
+/* $Id: term.c,v 1.129 2010/03/23 12:42:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -83,7 +83,6 @@ term_alloc(enum termenc enc)
perror(NULL);
exit(EXIT_FAILURE);
}
- p->maxrmargin = 78;
p->enc = enc;
return(p);
}
@@ -136,7 +135,6 @@ term_flushln(struct termp *p)
size_t bp; /* visual right border position */
int j; /* temporary loop index */
size_t maxvis, mmax;
- static int overstep = 0;
/*
* First, establish the maximum columns of "visible" content.
@@ -147,12 +145,12 @@ term_flushln(struct termp *p)
assert(p->offset < p->rmargin);
- maxvis = (int)(p->rmargin - p->offset) - overstep < 0 ?
+ maxvis = (int)(p->rmargin - p->offset) - p->overstep < 0 ?
/* LINTED */
- 0 : p->rmargin - p->offset - overstep;
- mmax = (int)(p->maxrmargin - p->offset) - overstep < 0 ?
+ 0 : p->rmargin - p->offset - p->overstep;
+ mmax = (int)(p->maxrmargin - p->offset) - p->overstep < 0 ?
/* LINTED */
- 0 : p->maxrmargin - p->offset - overstep;
+ 0 : p->maxrmargin - p->offset - p->overstep;
bp = TERMP_NOBREAK & p->flags ? mmax : maxvis;
@@ -215,10 +213,10 @@ term_flushln(struct termp *p)
putchar(' ');
vis = 0;
}
- /* Remove the overstep width. */
+ /* Remove the p->overstep width. */
bp += (int)/* LINTED */
- overstep;
- overstep = 0;
+ p->overstep;
+ p->overstep = 0;
} else {
for (j = 0; j < (int)vbl; j++)
putchar(' ');
@@ -242,7 +240,7 @@ term_flushln(struct termp *p)
}
p->col = 0;
- overstep = 0;
+ p->overstep = 0;
if ( ! (TERMP_NOBREAK & p->flags)) {
putchar('\n');
@@ -251,7 +249,7 @@ term_flushln(struct termp *p)
if (TERMP_HANG & p->flags) {
/* We need one blank after the tag. */
- overstep = /* LINTED */
+ p->overstep = /* LINTED */
vis - maxvis + 1;
/*
@@ -264,12 +262,12 @@ term_flushln(struct termp *p)
* move it one step LEFT and flag the rest of the line
* to be longer.
*/
- if (overstep >= -1) {
- assert((int)maxvis + overstep >= 0);
+ if (p->overstep >= -1) {
+ assert((int)maxvis + p->overstep >= 0);
/* LINTED */
- maxvis += overstep;
+ maxvis += p->overstep;
} else
- overstep = 0;
+ p->overstep = 0;
} else if (TERMP_DANGLE & p->flags)
return;
diff --git a/term.h b/term.h
index 134c83de..4a1ed902 100644
--- a/term.h
+++ b/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.51 2009/11/12 05:50:13 kristaps Exp $ */
+/* $Id: term.h,v 1.52 2010/03/23 12:42:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -35,6 +35,7 @@ struct termp {
size_t maxcols; /* Max size of buf. */
size_t offset; /* Margin offest. */
size_t col; /* Bytes in buf. */
+ int overstep; /* See termp_flushln(). */
int flags;
#define TERMP_NOSPACE (1 << 2) /* No space before words. */
#define TERMP_NOLPAD (1 << 3) /* See term_flushln(). */