=================================================================== RCS file: /cvs/mandoc/man_validate.c,v retrieving revision 1.45 retrieving revision 1.46 diff -u -p -r1.45 -r1.46 --- mandoc/man_validate.c 2010/06/28 14:39:17 1.45 +++ mandoc/man_validate.c 2010/07/20 14:56:42 1.46 @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.45 2010/06/28 14:39:17 kristaps Exp $ */ +/* $Id: man_validate.c,v 1.46 2010/07/20 14:56:42 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -26,6 +26,7 @@ #include #include #include +#include #include "mandoc.h" #include "libman.h" @@ -206,32 +207,37 @@ check_text(CHKARGS) { char *p; int pos, c; + size_t sz; - assert(n->string); - for (p = n->string, pos = n->pos + 1; *p; p++, pos++) { - if ('\\' == *p) { - c = mandoc_special(p); - if (c) { - p += c - 1; - pos += c - 1; - continue; - } + sz = strcspn(p, "\t\\"); + p += (int)sz; - c = man_pmsg(m, n->line, pos, MANDOCERR_BADESCAPE); - if ( ! (MAN_IGN_ESCAPE & m->pflags) && ! c) - return(c); + if ('\0' == *p) + break; + + pos += (int)sz; + + if ('\t' == *p) { + if (MAN_LITERAL & m->flags) + continue; + if (man_pmsg(m, n->line, pos, MANDOCERR_BADTAB)) + continue; + return(0); } - /* - * FIXME: we absolutely cannot let \b get through or it - * will destroy some assumptions in terms of format. - */ + /* Check the special character. */ - if ('\t' == *p || isprint((u_char)*p) || ASCII_HYPH == *p) + c = mandoc_special(p); + if (c) { + p += c - 1; + pos += c - 1; continue; - if ( ! man_pmsg(m, n->line, pos, MANDOCERR_BADCHAR)) - return(0); + } + + c = man_pmsg(m, n->line, pos, MANDOCERR_BADESCAPE); + if ( ! (MAN_IGN_ESCAPE & m->pflags) && ! c) + return(c); } return(1);