aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-08-07 20:33:55 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-08-07 20:33:55 +0000
commitcc281721217973092f10a3c7a71ce0004c65dbb8 (patch)
tree4bc0ba49cf2ef824acdd56ef07f0c386c24c3316 /mdoc.c
parenta3bf359d21ba2222789a2852bc6d1bbebbc0dbd2 (diff)
downloadmandoc-cc281721217973092f10a3c7a71ce0004c65dbb8.tar.gz
mandoc-cc281721217973092f10a3c7a71ce0004c65dbb8.tar.zst
mandoc-cc281721217973092f10a3c7a71ce0004c65dbb8.zip
"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.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/mdoc.c b/mdoc.c
index bcc6e4ca..168e4cea 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.159 2010/07/18 17:00:26 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.160 2010/08/07 20:33:55 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -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++;