-/* $Id: mdoc_validate.c,v 1.3 2009/04/02 16:37:40 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.7 2009/06/10 20:18:43 kristaps Exp $ */
/*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
+ * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
* Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all
- * copies.
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
- * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
};
enum mwarn {
+ WPRINT,
WESCAPE,
WWRONGMSEC,
WSECOOO,
static int err_child_eq(struct mdoc *, const char *, int);
static int warn_child_eq(struct mdoc *, const char *, int);
static int count_child(struct mdoc *);
+static int warn_print(struct mdoc *, int, int);
static int warn_count(struct mdoc *, const char *,
int, const char *, int);
static int err_count(struct mdoc *, const char *,
p = "prologue macros out-of-order";
c = WARN_COMPAT;
break;
+ case (WPRINT):
+ p = "invalid character";
+ break;
case (WESCAPE):
p = "invalid escape sequence";
break;
}
+static int
+warn_print(struct mdoc *m, int ln, int pos)
+{
+ if (MDOC_IGN_CHARS & m->pflags)
+ return(pwarn(m, ln, pos, WPRINT));
+ return(perr(m, ln, pos, EPRINT));
+}
+
static inline int
warn_count(struct mdoc *m, const char *k,
for ( ; *p; p++) {
if ('\t' == *p) {
if ( ! (MDOC_LITERAL & mdoc->flags))
- return(perr(mdoc, line, pos, EPRINT));
+ if ( ! warn_print(mdoc, line, pos))
+ return(0);
} else if ( ! isprint((u_char)*p))
- return(perr(mdoc, line, pos, EPRINT));
+ if ( ! warn_print(mdoc, line, pos))
+ return(0);
if ('\\' != *p)
continue;
pre_er(PRE_ARGS)
{
- return(check_msec(mdoc, n, 2, 0));
+ return(check_msec(mdoc, n, 2, 3, 9, 0));
}