From 860d4862be0dcf8d5e32e84e8ff985a8f9588aa2 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Tue, 26 Jul 2011 14:09:01 +0000 Subject: Move checking of escapes into roff.c, where we're already stepping through looking for user-defined escapes. This clears up a nice bit of validation code. --- man_validate.c | 42 ++++++------------------------------------ 1 file changed, 6 insertions(+), 36 deletions(-) (limited to 'man_validate.c') diff --git a/man_validate.c b/man_validate.c index 257bb6de..8d61d303 100644 --- a/man_validate.c +++ b/man_validate.c @@ -207,45 +207,15 @@ check_root(CHKARGS) } static void -check_text(CHKARGS) +check_text(CHKARGS) { - char *p, *pp, *cpp; - int pos; - size_t sz; + char *cp, *p; - p = n->string; - pos = n->pos + 1; - - while ('\0' != *p) { - sz = strcspn(p, "\t\\"); - - p += (int)sz; - pos += (int)sz; - - if ('\t' == *p) { - if ( ! (MAN_LITERAL & m->flags)) - man_pmsg(m, n->line, pos, MANDOCERR_BADTAB); - p++; - pos++; + cp = p = n->string; + for (cp = p; NULL != (p = strchr(p, '\t')); p++) { + if (MAN_LITERAL & m->flags) continue; - } else if ('\0' == *p) - break; - - pos++; - pp = ++p; - - if (ESCAPE_ERROR == mandoc_escape - ((const char **)&pp, NULL, NULL)) { - man_pmsg(m, n->line, pos, MANDOCERR_BADESCAPE); - break; - } - - cpp = p; - while (NULL != (cpp = memchr(cpp, ASCII_HYPH, pp - cpp))) - *cpp = '-'; - - pos += pp - p; - p = pp; + man_pmsg(m, n->line, (int)(p - cp), MANDOCERR_BADTAB); } } -- cgit