aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-09-16 15:08:31 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-09-16 15:08:31 +0000
commit29c6eeca7257e2e5a09c15ae2622377632f25681 (patch)
tree6580a31b5ef272273c94b170fb7cbec6ae607161
parent374dd658a605a794b307642e87295f468d29d56a (diff)
downloadmandoc-29c6eeca7257e2e5a09c15ae2622377632f25681.tar.gz
mandoc-29c6eeca7257e2e5a09c15ae2622377632f25681.tar.zst
mandoc-29c6eeca7257e2e5a09c15ae2622377632f25681.zip
Put closedelim and opendelim right in term_word() (unnecessary extra function).
-rw-r--r--term.c106
1 files changed, 41 insertions, 65 deletions
diff --git a/term.c b/term.c
index 56d8a887..6bfd373d 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.99 2009/09/16 09:41:24 kristaps Exp $ */
+/* $Id: term.c,v 1.100 2009/09/16 15:08:31 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 *
@@ -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,9 +484,33 @@ 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, ' ');
@@ -552,14 +518,24 @@ term_word(struct termp *p, const char *word)
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;
+ }
}