From 9e21548672490d99d4a59ab449c80b3721689818 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Sat, 4 Jul 2009 09:01:55 +0000 Subject: Moved escape validation into libmandoc.h/mandoc.c (common between libman/libmdoc1). libman supports MAN_IGN_ESCAPE (like MDOC_IGN_ESCAPE). All popular escapes now handled consistently. --- man_validate.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'man_validate.c') diff --git a/man_validate.c b/man_validate.c index 7a573b76..28701ae9 100644 --- a/man_validate.c +++ b/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.14 2009/06/22 13:09:17 kristaps Exp $ */ +/* $Id: man_validate.c,v 1.15 2009/07/04 09:01:55 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -22,6 +22,7 @@ #include #include "libman.h" +#include "libmandoc.h" #define POSTARGS struct man *m, const struct man_node *n @@ -118,12 +119,26 @@ static int check_text(POSTARGS) { const char *p; - int pos; + int pos, c; assert(n->string); for (p = n->string, pos = n->pos + 1; *p; p++, pos++) { - if ('\t' == *p || isprint((u_char)*p)) + if ('\\' == *p) { + c = mandoc_special(p); + if (c) { + p += c - 1; + pos += c - 1; + continue; + } + if ( ! (MAN_IGN_ESCAPE & m->pflags)) + return(man_perr(m, n->line, pos, WESCAPE)); + if ( ! man_pwarn(m, n->line, pos, WESCAPE)) + return(0); + continue; + } + + if ('\t' == *p || isprint((u_char)*p)) continue; if (MAN_IGN_CHARS & m->pflags) -- cgit v1.2.3