diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-06-22 12:04:05 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-06-22 12:04:05 +0000 |
commit | 5ff3d11b2e760657dd7adae6fb66cdc78ebd34ad (patch) | |
tree | 83cbd924ee999aea6b128ebb6553fb4a04fdba0d /term.c | |
parent | 39df69a9d68b05fb09136083471adee4d2817687 (diff) | |
download | mandoc-5ff3d11b2e760657dd7adae6fb66cdc78ebd34ad.tar.gz |
Added "Spacing" part of "Punctuation and Spacing" in mandoc.1 manual.
Fixed `Ds' meta-macro default width.
Fixed -width and -offset "indent", "indent-two", and "left" widths.
Fixed -width and -offset literal-word and numeric widths.
Fixed off-by-one errors in whitespace output (schwarze@openbsd.org).
Diffstat (limited to 'term.c')
-rw-r--r-- | term.c | 46 |
1 files changed, 24 insertions, 22 deletions
@@ -205,7 +205,7 @@ void term_flushln(struct termp *p) { int i, j; - size_t vsz, vis, maxvis, mmax, bp; + size_t vbl, vsz, vis, maxvis, mmax, bp; /* * First, establish the maximum columns of "visible" content. @@ -250,35 +250,37 @@ term_flushln(struct termp *p) } /* - * Do line-breaking. If we're greater than our - * break-point and already in-line, break to the next - * line and start writing. If we're at the line start, - * then write out the word (TODO: hyphenate) and break - * in a subsequent loop invocation. + * Choose the number of blanks to prepend: no blank at the + * beginning of a line, one between words -- but do not + * actually write them yet. */ + vbl = (size_t)(0 == vis ? 0 : 1); - if ( ! (TERMP_NOBREAK & p->flags)) { - if (vis && vis + vsz > bp) { - putchar('\n'); + /* + * Find out whether we would exceed the right margin. + * If so, break to the next line. (TODO: hyphenate) + * Otherwise, write the chosen number of blanks now. + */ + if (vis && vis + vbl + vsz > bp) { + putchar('\n'); + if (TERMP_NOBREAK & p->flags) { + for (j = 0; j < (int)p->rmargin; j++) + putchar(' '); + vis = p->rmargin - p->offset; + } else { for (j = 0; j < (int)p->offset; j++) putchar(' '); vis = 0; - } - } else if (vis && vis + vsz > bp) { - putchar('\n'); - for (j = 0; j < (int)p->rmargin; j++) + } + } else { + for (j = 0; j < (int)vbl; j++) putchar(' '); - vis = p->rmargin - p->offset; + vis += vbl; } /* - * Prepend a space if we're not already at the beginning - * of the line, then the word. + * Finally, write out the word. */ - - if (0 < vis++) - putchar(' '); - for ( ; i < (int)p->col; i++) { if (' ' == p->buf[i]) break; @@ -292,7 +294,7 @@ term_flushln(struct termp *p) * cause a newline and offset at the right margin. */ - if ((TERMP_NOBREAK & p->flags) && vis > maxvis) { + if ((TERMP_NOBREAK & p->flags) && vis >= maxvis) { if ( ! (TERMP_NONOBREAK & p->flags)) { putchar('\n'); for (i = 0; i < (int)p->rmargin; i++) @@ -309,7 +311,7 @@ term_flushln(struct termp *p) if (p->flags & TERMP_NOBREAK) { if ( ! (TERMP_NONOBREAK & p->flags)) - for ( ; vis <= maxvis; vis++) + for ( ; vis < maxvis; vis++) putchar(' '); } else putchar('\n'); |