diff options
author | 2019-04-21 23:45:50 +0000 | |
---|---|---|
committer | 2019-04-21 23:45:50 +0000 | |
commit | 61dc507989caf10ce7bb398527eb0af337459a47 (patch) | |
tree | af6b31a56daff6745cadcb8b5e315d099762cd67 /usr.bin/mandoc/roff.c | |
parent | Implement the roff .break request (break out of a .while loop). (diff) | |
download | wireguard-openbsd-61dc507989caf10ce7bb398527eb0af337459a47.tar.xz wireguard-openbsd-61dc507989caf10ce7bb398527eb0af337459a47.zip |
When calling an empty macro, do not clobber existing arguments.
Fixing a bug found with the groffer(1) version 1.19 manual page
following a report from Jan Stary.
Diffstat (limited to 'usr.bin/mandoc/roff.c')
-rw-r--r-- | usr.bin/mandoc/roff.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 27ef98143f5..cfa591d16e7 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.236 2019/04/21 22:43:00 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.237 2019/04/21 23:45:50 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org> @@ -3839,6 +3839,11 @@ roff_userdef(ROFF_ARGS) char *arg, *ap, *dst, *src; size_t sz; + /* If the macro is empty, ignore it altogether. */ + + if (*r->current_string == '\0') + return ROFF_IGN; + /* Initialize a new macro stack context. */ if (++r->mstackpos == r->mstacksz) { @@ -3886,7 +3891,7 @@ roff_userdef(ROFF_ARGS) buf->sz = strlen(buf->buf) + 1; *offs = 0; - return buf->sz > 1 && buf->buf[buf->sz - 2] == '\n' ? + return buf->buf[buf->sz - 2] == '\n' ? ROFF_REPARSE | ROFF_USERCALL : ROFF_IGN | ROFF_APPEND; } |