=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.125 retrieving revision 1.129 diff -u -p -r1.125 -r1.129 --- mandoc/term.c 2009/11/12 05:50:12 1.125 +++ mandoc/term.c 2010/03/23 12:42:22 1.129 @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.125 2009/11/12 05:50:12 kristaps Exp $ */ +/* $Id: term.c,v 1.129 2010/03/23 12:42:22 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -14,6 +14,12 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + #include #include #include @@ -77,7 +83,6 @@ term_alloc(enum termenc enc) perror(NULL); exit(EXIT_FAILURE); } - p->maxrmargin = 78; p->enc = enc; return(p); } @@ -130,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. @@ -141,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; @@ -209,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(' '); @@ -236,7 +240,7 @@ term_flushln(struct termp *p) } p->col = 0; - overstep = 0; + p->overstep = 0; if ( ! (TERMP_NOBREAK & p->flags)) { putchar('\n'); @@ -245,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; /* @@ -258,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; @@ -485,7 +489,10 @@ term_word(struct termp *p, const char *word) default: break; } + word += sz; + if (DECO_NOSPACE == deco && '\0' == *word) + p->flags |= TERMP_NOSPACE; } if (sv[0] && 0 == sv[1]) @@ -527,7 +534,7 @@ buffera(struct termp *p, const char *word, size_t sz) if (p->col + sz >= p->maxcols) adjbuf(p, p->col + sz); - memcpy(&p->buf[p->col], word, sz); + memcpy(&p->buf[(int)p->col], word, sz); p->col += sz; } @@ -539,7 +546,7 @@ bufferc(struct termp *p, char c) if (p->col + 1 >= p->maxcols) adjbuf(p, p->col + 1); - p->buf[p->col++] = c; + p->buf[(int)p->col++] = c; }