=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.72 retrieving revision 1.78 diff -u -p -r1.72 -r1.78 --- mandoc/term.c 2009/04/03 11:08:39 1.72 +++ mandoc/term.c 2009/06/11 10:34:32 1.78 @@ -1,20 +1,18 @@ -/* $Id: term.c,v 1.72 2009/04/03 11:08:39 kristaps Exp $ */ +/* $Id: term.c,v 1.78 2009/06/11 10:34:32 kristaps Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons + * Copyright (c) 2008, 2009 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the - * above copyright notice and this permission notice appear in all - * copies. + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE - * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include @@ -59,7 +57,6 @@ terminal_man(void *arg, const struct man *man) struct termp *p; p = (struct termp *)arg; - if (NULL == p->symtab) p->symtab = term_ascii2htab(); @@ -73,7 +70,6 @@ terminal_mdoc(void *arg, const struct mdoc *mdoc) struct termp *p; p = (struct termp *)arg; - if (NULL == p->symtab) p->symtab = term_ascii2htab(); @@ -110,7 +106,7 @@ term_alloc(enum termenc enc) if (NULL == (p = malloc(sizeof(struct termp)))) err(1, "malloc"); bzero(p, sizeof(struct termp)); - p->maxrmargin = 78; + p->maxrmargin = 80; p->enc = enc; return(p); } @@ -276,22 +272,20 @@ term_flushln(struct termp *p) vis = p->rmargin - p->offset; } - /* - * Write out the word and a trailing space. Omit the - * space if we're the last word in the line or beyond - * our breakpoint. + /* + * Prepend a space if we're not already at the beginning + * of the line, then the word. */ + if (0 < vis++) + putchar(' '); + for ( ; i < (int)p->col; i++) { if (' ' == p->buf[i]) break; putchar(p->buf[i]); } vis += vsz; - if (i < (int)p->col && vis <= bp) { - putchar(' '); - vis++; - } } /* @@ -299,7 +293,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++) @@ -316,7 +310,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');