diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-08-07 20:33:55 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-08-07 20:33:55 +0000 |
commit | 75b5b6f467d4105ac3e51ff98ad5284835968682 (patch) | |
tree | 67abf628984b8b72be00cb8e6f16b75905dccb92 /mdoc.c | |
parent | be16f6e949236650f6313d3a187c8367327c4ac2 (diff) | |
download | mandoc-75b5b6f467d4105ac3e51ff98ad5284835968682.tar.gz |
"Groff allows the initial macro on a line to be delimited by a space of
by a tab; so allow the tab in mandoc, too." Original problem noted by
schwarze@. Sync with OpenBSD.
Diffstat (limited to 'mdoc.c')
-rw-r--r-- | mdoc.c | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -764,11 +764,11 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) i = offs; - /* Accept whitespace after the initial control char. */ + /* Accept tabs/whitespace after the initial control char. */ - if (' ' == buf[i]) { + if (' ' == buf[i] || '\t' == buf[i]) { i++; - while (buf[i] && ' ' == buf[i]) + while (buf[i] && (' ' == buf[i] || '\t' == buf[i])) i++; if ('\0' == buf[i]) return(1); @@ -776,15 +776,19 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) sv = i; - /* Copy the first word into a nil-terminated buffer. */ + /* + * Copy the first word into a nil-terminated buffer. Stop + * copying when a tab, space, or eoln is encountered. + */ for (j = 0; j < 4; j++, i++) { if ('\0' == (mac[j] = buf[i])) break; - else if (' ' == buf[i]) + else if (' ' == buf[i] || '\t' == buf[i]) break; /* Check for invalid characters. */ + /* TODO: remove me, already done in main.c. */ if (isgraph((u_char)buf[i])) continue; @@ -807,7 +811,12 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) return(1); } - /* The macro is sane. Jump to the next word. */ + /* Disregard the first trailing tab, if applicable. */ + + if ('\t' == buf[i]) + i++; + + /* Jump to the next non-whitespace word. */ while (buf[i] && ' ' == buf[i]) i++; |