diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-07-17 12:01:43 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-07-17 12:01:43 +0000 |
commit | 7f134e093fe20357e6698e21ebaf05ef85a51f7a (patch) | |
tree | 731128310a4de0ea08de92862c4dca9a5489ce05 | |
parent | 783d095f30c97a02fda548fcfc9bddc37fda9a36 (diff) | |
download | mandoc-7f134e093fe20357e6698e21ebaf05ef85a51f7a.tar.gz |
Avoid letter-by-letter encoding by using strcspn() in term_word().
-rw-r--r-- | term.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -503,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); @@ -547,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 */ |