=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.158 retrieving revision 1.163 diff -u -p -r1.158 -r1.163 --- mandoc/term.c 2010/07/03 16:02:12 1.158 +++ mandoc/term.c 2010/07/21 20:35:03 1.163 @@ -1,6 +1,7 @@ -/* $Id: term.c,v 1.158 2010/07/03 16:02:12 schwarze Exp $ */ +/* $Id: term.c,v 1.163 2010/07/21 20:35:03 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 @@ -30,11 +31,11 @@ #include "mandoc.h" #include "chars.h" #include "out.h" -#include "regs.h" #include "term.h" #include "main.h" -static void spec(struct termp *, const char *, size_t); +static void spec(struct termp *, enum roffdeco, + const char *, size_t); static void res(struct termp *, const char *, size_t); static void buffera(struct termp *, const char *, size_t); static void bufferc(struct termp *, char); @@ -360,14 +361,16 @@ term_vspace(struct termp *p) static void -spec(struct termp *p, const char *word, size_t len) +spec(struct termp *p, enum roffdeco d, 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); + else if (DECO_SSPECIAL == d) + encode(p, word, len); } @@ -377,12 +380,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); - if (NULL == rhs) { - rhs = roff_getstrn(word, len); - if (rhs) - sz = strlen(rhs); - } + rhs = chars_res2str(p->symtab, word, len, &sz); if (rhs) encode(p, rhs, sz); } @@ -508,14 +506,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); @@ -525,7 +522,9 @@ term_word(struct termp *p, const char *word) res(p, seq, ssz); break; case (DECO_SPECIAL): - spec(p, seq, ssz); + /* FALLTHROUGH */ + case (DECO_SSPECIAL): + spec(p, deco, seq, ssz); break; case (DECO_BOLD): term_fontrepl(p, TERMFONT_BOLD); @@ -552,7 +551,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 */