X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/1aea6f050761f70bdfd8647816b23774b971050c..dc0bf00a26ef3d7cd4b3df5bc0cb9f7c55e02479:/man_validate.c?ds=sidebyside

diff --git a/man_validate.c b/man_validate.c
index 8d04e2ea..b6883ff8 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -1,6 +1,6 @@
-/*	$Id: man_validate.c,v 1.43 2010/06/09 19:22:56 kristaps Exp $ */
+/*	$Id: man_validate.c,v 1.48 2010/07/31 23:52:58 schwarze Exp $ */
 /*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
+ * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -26,6 +26,7 @@
 #include <limits.h>
 #include <stdarg.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "mandoc.h"
 #include "libman.h"
@@ -82,9 +83,9 @@ static	const struct man_valid man_valids[MAN_MAX] = {
 	{ NULL, NULL }, /* I */
 	{ NULL, NULL }, /* IR */
 	{ NULL, NULL }, /* RI */
-	{ NULL, posts_eq0 }, /* na */
+	{ NULL, posts_eq0 }, /* na */ /* FIXME: should warn only. */
 	{ NULL, NULL }, /* i */
-	{ NULL, posts_le1 }, /* sp */
+	{ NULL, posts_le1 }, /* sp */ /* FIXME: should warn only. */
 	{ pres_bline, posts_eq0 }, /* nf */
 	{ pres_bline, posts_eq0 }, /* fi */
 	{ NULL, NULL }, /* r */
@@ -93,10 +94,11 @@ static	const struct man_valid man_valids[MAN_MAX] = {
 	{ NULL, NULL }, /* DT */
 	{ NULL, NULL }, /* UC */
 	{ NULL, NULL }, /* PD */
-	{ NULL, posts_le1 }, /* Sp */
-	{ pres_bline, posts_le1 }, /* Vb */
+	{ NULL, posts_le1 }, /* Sp */ /* FIXME: should warn only. */
+	{ pres_bline, posts_le1 }, /* Vb */ /* FIXME: should warn only. */
 	{ pres_bline, posts_eq0 }, /* Ve */
 	{ NULL, NULL }, /* AT */
+	{ NULL, NULL }, /* in */
 };
 
 
@@ -206,27 +208,37 @@ check_text(CHKARGS)
 {
 	char		*p;
 	int		 pos, c;
-
-	assert(n->string);
+	size_t		 sz;
 
 	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;
+
+		if ('\0' == *p)
+			break;
+
+		pos += (int)sz;
 
-			c = man_pmsg(m, n->line, pos, MANDOCERR_BADESCAPE);
-			if ( ! (MAN_IGN_ESCAPE & m->pflags) && ! c)
-				return(c);
+		if ('\t' == *p) {
+			if (MAN_LITERAL & m->flags)
+				continue;
+			if (man_pmsg(m, n->line, pos, MANDOCERR_BADTAB))
+				continue;
+			return(0);
 		}
 
-		if ('\t' == *p || isprint((u_char)*p) || ASCII_HYPH == *p) 
+		/* Check the special character. */
+
+		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);