=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.155 retrieving revision 1.162 diff -u -p -r1.155 -r1.162 --- mandoc/term.c 2010/06/30 12:27:55 1.155 +++ mandoc/term.c 2010/07/17 12:01:43 1.162 @@ -1,6 +1,7 @@ -/* $Id: term.c,v 1.155 2010/06/30 12:27:55 kristaps Exp $ */ +/* $Id: term.c,v 1.162 2010/07/17 12:01:43 kristaps Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons + * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons + * Copyright (c) 2010 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -364,7 +365,7 @@ spec(struct termp *p, const char *word, size_t len) const char *rhs; size_t sz; - rhs = chars_a2ascii(p->symtab, word, len, &sz); + rhs = chars_spec2str(p->symtab, word, len, &sz); if (rhs) encode(p, rhs, sz); } @@ -376,7 +377,7 @@ res(struct termp *p, const char *word, size_t len) const char *rhs; size_t sz; - rhs = chars_a2res(p->symtab, word, len, &sz); + rhs = chars_res2str(p->symtab, word, len, &sz); if (rhs) encode(p, rhs, sz); } @@ -502,14 +503,13 @@ term_word(struct termp *p, const char *word) p->flags &= ~TERMP_SENTENCE; - /* FIXME: use strcspn. */ - while (*word) { - if ('\\' != *word) { - encode(p, word, 1); - word++; + if ((ssz = strcspn(word, "\\")) > 0) + encode(p, word, ssz); + + word += ssz; + if ('\\' != *word) continue; - } seq = ++word; sz = a2roffdeco(&deco, &seq, &ssz); @@ -546,7 +546,7 @@ term_word(struct termp *p, const char *word) * Note that we don't process the pipe: the parser sees it as * punctuation, but we don't in terms of typography. */ - if (sv[0] && 0 == sv[1]) + if (sv[0] && '\0' == sv[1]) switch (sv[0]) { case('('): /* FALLTHROUGH */ @@ -653,6 +653,7 @@ term_strlen(const struct termp *p, const char *cp) } +/* ARGSUSED */ size_t term_vspan(const struct termp *p, const struct roffsu *su) { @@ -692,6 +693,11 @@ term_vspan(const struct termp *p, const struct roffsu size_t term_hspan(const struct termp *p, const struct roffsu *su) { + double v; - return((*p->hspan)(p, su)); + v = ((*p->hspan)(p, su)); + if (v < 0.0) + v = 0.0; + return((size_t) /* LINTED */ + v); }