diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-11-19 03:08:17 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-11-19 03:08:17 +0000 |
commit | ccbf554d2b7a5d479480e7fc4cd19af77a60b272 (patch) | |
tree | ad2f5a1e94fdd2628813a46b8ca9f51955f7ab4d /mdoc.c | |
parent | 41b8a4db179c8440f8e1d020c3ce6ce6685cbf05 (diff) | |
download | mandoc-ccbf554d2b7a5d479480e7fc4cd19af77a60b272.tar.gz |
Escape sequences terminate high-level macro names, and when doing so,
they are ignored, just in the same way as for request names
and for low-level macro names.
This also cures a warning in the pod2man(1) preamble.
Diffstat (limited to 'mdoc.c')
-rw-r--r-- | mdoc.c | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -734,37 +734,47 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs) static int mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs) { + struct mdoc_node *n; + const char *cp; enum mdoct tok; int i, sv; char mac[5]; - struct mdoc_node *n; sv = offs; /* * Copy the first word into a nil-terminated buffer. - * Stop copying when a tab, space, or eoln is encountered. + * Stop when a space, tab, escape, or eoln is encountered. */ i = 0; - while (i < 4 && '\0' != buf[offs] && ' ' != buf[offs] && - '\t' != buf[offs]) + while (i < 4 && strchr(" \t\\", buf[offs]) == NULL) mac[i++] = buf[offs++]; mac[i] = '\0'; tok = (i > 1 && i < 4) ? mdoc_hash_find(mac) : MDOC_MAX; - if (MDOC_MAX == tok) { + if (tok == MDOC_MAX) { mandoc_msg(MANDOCERR_MACRO, mdoc->parse, ln, sv, buf + sv - 1); return(1); } - /* Disregard the first trailing tab, if applicable. */ + /* Skip a leading escape sequence or tab. */ - if ('\t' == buf[offs]) + switch (buf[offs]) { + case '\\': + cp = buf + offs + 1; + mandoc_escape(&cp, NULL, NULL); + offs = cp - buf; + break; + case '\t': offs++; + break; + default: + break; + } /* Jump to the next non-whitespace word. */ |