=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.98 retrieving revision 1.100 diff -u -p -r1.98 -r1.100 --- mandoc/term.c 2009/09/15 08:16:20 1.98 +++ mandoc/term.c 2009/09/16 15:08:31 1.100 @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.98 2009/09/15 08:16:20 kristaps Exp $ */ +/* $Id: term.c,v 1.100 2009/09/16 15:08:31 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -24,9 +24,9 @@ #include "man.h" #include "mdoc.h" -extern int man_run(struct termp *, +extern void man_run(struct termp *, const struct man *); -extern int mdoc_run(struct termp *, +extern void mdoc_run(struct termp *, const struct mdoc *); static struct termp *term_alloc(enum termenc); @@ -39,8 +39,6 @@ static void do_reserved(struct termp *, const char *, size_t); static void buffer(struct termp *, char); static void encode(struct termp *, char); -static int isopendelim(const char *); -static int isclosedelim(const char *); void * @@ -51,7 +49,7 @@ ascii_alloc(void) } -int +void terminal_man(void *arg, const struct man *man) { struct termp *p; @@ -60,11 +58,11 @@ terminal_man(void *arg, const struct man *man) if (NULL == p->symtab) p->symtab = term_ascii2htab(); - return(man_run(p, man)); + man_run(p, man); } -int +void terminal_mdoc(void *arg, const struct mdoc *mdoc) { struct termp *p; @@ -73,7 +71,7 @@ terminal_mdoc(void *arg, const struct mdoc *mdoc) if (NULL == p->symtab) p->symtab = term_ascii2htab(); - return(mdoc_run(p, mdoc)); + mdoc_run(p, mdoc); } @@ -112,62 +110,6 @@ term_alloc(enum termenc enc) } -static int -isclosedelim(const char *p) -{ - - if ( ! (*p && 0 == *(p + 1))) - return(0); - - switch (*p) { - case('.'): - /* FALLTHROUGH */ - case(','): - /* FALLTHROUGH */ - case(';'): - /* FALLTHROUGH */ - case(':'): - /* FALLTHROUGH */ - case('?'): - /* FALLTHROUGH */ - case('!'): - /* FALLTHROUGH */ - case(')'): - /* FALLTHROUGH */ - case(']'): - /* FALLTHROUGH */ - case('}'): - return(1); - default: - break; - } - - return(0); -} - - -static int -isopendelim(const char *p) -{ - - if ( ! (*p && 0 == *(p + 1))) - return(0); - - switch (*p) { - case('('): - /* FALLTHROUGH */ - case('['): - /* FALLTHROUGH */ - case('{'): - return(1); - default: - break; - } - - return(0); -} - - /* * Flush a line of text. A "line" is loosely defined as being something * that should be followed by a newline, regardless of whether it's @@ -542,24 +484,58 @@ term_word(struct termp *p, const char *word) { const char *sv; - if (isclosedelim(word)) - if ( ! (TERMP_IGNDELIM & p->flags)) - p->flags |= TERMP_NOSPACE; + sv = word; + if (word[0] && 0 == word[1]) + switch (word[0]) { + case('.'): + /* FALLTHROUGH */ + case(','): + /* FALLTHROUGH */ + case(';'): + /* FALLTHROUGH */ + case(':'): + /* FALLTHROUGH */ + case('?'): + /* FALLTHROUGH */ + case('!'): + /* FALLTHROUGH */ + case(')'): + /* FALLTHROUGH */ + case(']'): + /* FALLTHROUGH */ + case('}'): + if ( ! (TERMP_IGNDELIM & p->flags)) + p->flags |= TERMP_NOSPACE; + break; + default: + break; + } + if ( ! (TERMP_NOSPACE & p->flags)) buffer(p, ' '); if ( ! (p->flags & TERMP_NONOSPACE)) p->flags &= ~TERMP_NOSPACE; - for (sv = word; *word; word++) + for ( ; *word; word++) if ('\\' != *word) encode(p, *word); else do_escaped(p, &word); - if (isopendelim(sv)) - p->flags |= TERMP_NOSPACE; + if (sv[0] && 0 == sv[1]) + switch (sv[0]) { + case('('): + /* FALLTHROUGH */ + case('['): + /* FALLTHROUGH */ + case('{'): + p->flags |= TERMP_NOSPACE; + break; + default: + break; + } }