summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/man.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-11-19 03:07:43 +0000
committerschwarze <schwarze@openbsd.org>2014-11-19 03:07:43 +0000
commit5bb18d706b8af508f39dacfb2e077fa4d2900b0d (patch)
tree9df601e83b9b55fe7ccce161adf0577fb64c4f10 /usr.bin/mandoc/man.c
parentBring in a change present in binutils 2.17 to allow sahf/lahf (diff)
downloadwireguard-openbsd-5bb18d706b8af508f39dacfb2e077fa4d2900b0d.tar.xz
wireguard-openbsd-5bb18d706b8af508f39dacfb2e077fa4d2900b0d.zip
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 'usr.bin/mandoc/man.c')
-rw-r--r--usr.bin/mandoc/man.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index e9ca83f030c..0b0acdc4380 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man.c,v 1.90 2014/11/03 23:17:21 schwarze Exp $ */
+/* $OpenBSD: man.c,v 1.91 2014/11/19 03:07:43 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -481,35 +481,50 @@ man_ptext(struct man *man, int line, char *buf, int offs)
static int
man_pmacro(struct man *man, int ln, char *buf, int offs)
{
- char mac[5];
struct man_node *n;
+ const char *cp;
enum mant tok;
int i, ppos;
int bline;
+ char mac[5];
ppos = 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 > 0 && i < 4) ? man_hash_find(mac) : MAN_MAX;
- if (MAN_MAX == tok) {
+ if (tok == MAN_MAX) {
mandoc_msg(MANDOCERR_MACRO, man->parse,
ln, ppos, buf + ppos - 1);
return(1);
}
- /* The macro is sane. Jump to the next word. */
+ /* Skip a leading escape sequence or tab. */
+
+ 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. */
while (buf[offs] && ' ' == buf[offs])
offs++;