diff options
author | 2011-07-26 14:09:01 +0000 | |
---|---|---|
committer | 2011-07-26 14:09:01 +0000 | |
commit | 68af4dca6a1390f9087264cfbd5cbf49bfc12963 (patch) | |
tree | 9ed50d91fb43c9a70832dcca86f93242f852d197 /roff.c | |
parent | 499b7cc2df175e8f1cd3a0a7db00455e691d03de (diff) | |
download | mandoc-68af4dca6a1390f9087264cfbd5cbf49bfc12963.tar.gz mandoc-68af4dca6a1390f9087264cfbd5cbf49bfc12963.tar.zst mandoc-68af4dca6a1390f9087264cfbd5cbf49bfc12963.zip |
Move checking of escapes into roff.c, where we're already stepping
through looking for user-defined escapes. This clears up a nice bit of
validation code.
Diffstat (limited to 'roff.c')
-rw-r--r-- | roff.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -1,4 +1,4 @@ -/* $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> @@ -404,6 +404,7 @@ roff_alloc(struct mparse *parse) 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 ']' */ @@ -426,8 +427,19 @@ roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos) 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 |