diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-26 14:09:01 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-26 14:09:01 +0000 |
commit | 68af4dca6a1390f9087264cfbd5cbf49bfc12963 (patch) | |
tree | 9ed50d91fb43c9a70832dcca86f93242f852d197 /man_validate.c | |
parent | 499b7cc2df175e8f1cd3a0a7db00455e691d03de (diff) | |
download | mandoc-68af4dca6a1390f9087264cfbd5cbf49bfc12963.tar.gz mandoc-68af4dca6a1390f9087264cfbd5cbf49bfc12963.tar.zst mandoc-68af4dca6a1390f9087264cfbd5cbf49bfc12963.zip |
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.
Diffstat (limited to 'man_validate.c')
-rw-r--r-- | man_validate.c | 44 |
1 files changed, 7 insertions, 37 deletions
diff --git a/man_validate.c b/man_validate.c index 1aeb703d..7f0581c5 100644 --- a/man_validate.c +++ b/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.71 2011/07/24 18:15:14 kristaps Exp $ */ +/* $Id: man_validate.c,v 1.72 2011/07/26 14:09:01 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -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); } } |