summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-07-17 12:01:43 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-07-17 12:01:43 +0000
commit3aa5db30bfa69a5c4fefdb3ec5699b47d8b1a70a (patch)
tree870b5e0ff9ae7323069c628b4810878d75ec0647
parenta5c49f24b16e6351ce3bc6e801ec3c0fed98839a (diff)
downloadmandoc-3aa5db30bfa69a5c4fefdb3ec5699b47d8b1a70a.tar.gz
mandoc-3aa5db30bfa69a5c4fefdb3ec5699b47d8b1a70a.tar.zst
mandoc-3aa5db30bfa69a5c4fefdb3ec5699b47d8b1a70a.zip
Avoid letter-by-letter encoding by using strcspn() in term_word().
-rw-r--r--term.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/term.c b/term.c
index b4cd5b97..de8c3380 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.161 2010/07/16 22:33:30 kristaps Exp $ */
+/* $Id: term.c,v 1.162 2010/07/17 12:01:43 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 */