diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-26 14:09:01 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-26 14:09:01 +0000 |
commit | 860d4862be0dcf8d5e32e84e8ff985a8f9588aa2 (patch) | |
tree | a8189ad0df55799d4087ce84e9569f39f5ac5293 /roff.c | |
parent | 50079d4076610ce94c315c3ead86fa3dd19dc673 (diff) | |
download | mandoc-860d4862be0dcf8d5e32e84e8ff985a8f9588aa2.tar.gz |
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 | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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 |