-/* $Id: man_validate.c,v 1.71 2011/07/24 18:15:14 kristaps Exp $ */
+/* $Id: man_validate.c,v 1.72 2011/07/26 14:09:01 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
}
static void
-check_text(CHKARGS)
+check_text(CHKARGS)
{
- char *p, *pp, *cpp;
- int pos;
- size_t sz;
+ char *cp, *p;
- p = n->string;
- pos = n->pos + 1;
-
- while ('\0' != *p) {
- sz = strcspn(p, "\t\\");
-
- p += (int)sz;
- pos += (int)sz;
-
- if ('\t' == *p) {
- if ( ! (MAN_LITERAL & m->flags))
- man_pmsg(m, n->line, pos, MANDOCERR_BADTAB);
- p++;
- pos++;
+ cp = p = n->string;
+ for (cp = p; NULL != (p = strchr(p, '\t')); p++) {
+ if (MAN_LITERAL & m->flags)
continue;
- } else if ('\0' == *p)
- break;
-
- pos++;
- pp = ++p;
-
- if (ESCAPE_ERROR == mandoc_escape
- ((const char **)&pp, NULL, NULL)) {
- man_pmsg(m, n->line, pos, MANDOCERR_BADESCAPE);
- break;
- }
-
- cpp = p;
- while (NULL != (cpp = memchr(cpp, ASCII_HYPH, pp - cpp)))
- *cpp = '-';
-
- pos += pp - p;
- p = pp;
+ man_pmsg(m, n->line, (int)(p - cp), MANDOCERR_BADTAB);
}
}
-/* $Id: mdoc_validate.c,v 1.171 2011/07/24 18:15:14 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.172 2011/07/26 14:09:01 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
static void
check_text(struct mdoc *m, int ln, int pos, char *p)
{
- char *cpp, *pp;
- size_t sz;
-
- while ('\0' != *p) {
- sz = strcspn(p, "\t\\");
-
- p += (int)sz;
- pos += (int)sz;
+ char *cp;
- if ('\t' == *p) {
- if ( ! (MDOC_LITERAL & m->flags))
- mdoc_pmsg(m, ln, pos, MANDOCERR_BADTAB);
- p++;
- pos++;
+ cp = p;
+ for (cp = p; NULL != (p = strchr(p, '\t')); p++) {
+ if (MDOC_LITERAL & m->flags)
continue;
- } else if ('\0' == *p)
- break;
-
- pos++;
- pp = ++p;
-
- if (ESCAPE_ERROR == mandoc_escape
- ((const char **)&pp, NULL, NULL)) {
- mdoc_pmsg(m, ln, pos, MANDOCERR_BADESCAPE);
- break;
- }
-
- cpp = p;
- while (NULL != (cpp = memchr(cpp, ASCII_HYPH, pp - cpp)))
- *cpp = '-';
-
- pos += pp - p;
- p = pp;
+ mdoc_pmsg(m, ln, (int)(p - cp), MANDOCERR_BADTAB);
}
}
-/* $Id: roff.c,v 1.151 2011/07/25 15:37:00 kristaps Exp $ */
+/* $Id: roff.c,v 1.152 2011/07/26 14:09:01 kristaps Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
static int
roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos)
{
+ enum mandoc_esc esc;
const char *stesc; /* start of an escape sequence ('\\') */
const char *stnam; /* start of the name, after "[(*" */
const char *cp; /* end of the name, e.g. before ']' */
if ('\0' == *cp)
return(1);
- if ('*' != *cp++)
+
+ if ('*' != *cp) {
+ res = cp;
+ esc = mandoc_escape(&cp, NULL, NULL);
+ if (ESCAPE_ERROR != esc)
+ continue;
+ mandoc_msg(MANDOCERR_BADESCAPE,
+ r->parse, ln, pos, NULL);
+ cp = res;
continue;
+ }
+
+ cp++;
/*
* The third character decides the length