summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc_validate.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2011-05-29 21:22:18 +0000
committerschwarze <schwarze@openbsd.org>2011-05-29 21:22:18 +0000
commita5e11ede034e8133d7802104ea335f923b261e35 (patch)
treec64a494ff0cba438ca7061b4f7b03d453349de14 /usr.bin/mandoc/mdoc_validate.c
parentregen (diff)
downloadwireguard-openbsd-a5e11ede034e8133d7802104ea335f923b261e35.tar.xz
wireguard-openbsd-a5e11ede034e8133d7802104ea335f923b261e35.zip
Merge release 1.11.3, almost all code by kristaps@:
* Unicode output support (no Unicode input yet, though). * Refactoring: completely handle predefined strings in roff.c. - New function mandoc_escape() replaces a2roffdeco() and mandoc_special(). - Start using mandoc_getarg() in mdoc_argv.c. - Clean up parsing of delimiters in mdoc(7). * And many minor fixes and lots of cleanup.
Diffstat (limited to 'usr.bin/mandoc/mdoc_validate.c')
-rw-r--r--usr.bin/mandoc/mdoc_validate.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index b915a49b24a..1c08e614a80 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.92 2011/04/24 16:22:02 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.93 2011/05/29 21:22:18 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -176,7 +176,7 @@ static v_pre pres_sh[] = { pre_sh, NULL };
static v_pre pres_ss[] = { pre_ss, NULL };
static v_pre pres_std[] = { pre_std, NULL };
-static const struct valids mdoc_valids[MDOC_MAX] = {
+static const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Ap */
{ pres_dd, posts_dd }, /* Dd */
{ pres_dt, posts_dt }, /* Dt */
@@ -541,31 +541,39 @@ check_argv(struct mdoc *m, struct mdoc_node *n, struct mdoc_argv *v)
static void
check_text(struct mdoc *m, int ln, int pos, char *p)
{
- int c;
+ char *cpp, *pp;
size_t sz;
- for ( ; *p; p++, pos++) {
+ while ('\0' != *p) {
sz = strcspn(p, "\t\\");
- p += (int)sz;
-
- if ('\0' == *p)
- break;
+ p += (int)sz;
pos += (int)sz;
if ('\t' == *p) {
if ( ! (MDOC_LITERAL & m->flags))
mdoc_pmsg(m, ln, pos, MANDOCERR_BADTAB);
+ p++;
+ pos++;
continue;
- }
+ } else if ('\0' == *p)
+ break;
+
+ pos++;
+ pp = ++p;
- if (0 == (c = mandoc_special(p))) {
+ if (ESCAPE_ERROR == mandoc_escape
+ ((const char **)&pp, NULL, NULL)) {
mdoc_pmsg(m, ln, pos, MANDOCERR_BADESCAPE);
- continue;
+ break;
}
- p += c - 1;
- pos += c - 1;
+ cpp = p;
+ while (NULL != (cpp = memchr(cpp, ASCII_HYPH, pp - cpp)))
+ *cpp = '-';
+
+ pos += pp - p;
+ p = pp;
}
}
@@ -1523,7 +1531,7 @@ post_bl_head(POST_ARGS)
assert(0 == np->args->argv[j].sz);
/*
- * Accomodate for new-style groff column syntax. Shuffle the
+ * Accommodate for new-style groff column syntax. Shuffle the
* child nodes, all of which must be TEXT, as arguments for the
* column field. Then, delete the head children.
*/