aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2019-04-21 23:51:21 +0000
committerIngo Schwarze <schwarze@openbsd.org>2019-04-21 23:51:21 +0000
commit4ea4dffa7b5f9edcd44a043e69c061f748aae2d5 (patch)
tree4fddd7bfdd0559b10820cda436679277eb0efd72 /roff.c
parent521832262338c85e83c79d44a533328fff010240 (diff)
downloadmandoc-4ea4dffa7b5f9edcd44a043e69c061f748aae2d5.tar.gz
mandoc-4ea4dffa7b5f9edcd44a043e69c061f748aae2d5.tar.zst
mandoc-4ea4dffa7b5f9edcd44a043e69c061f748aae2d5.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 'roff.c')
-rw-r--r--roff.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/roff.c b/roff.c
index dbf260a0..a1d4fca3 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.364 2019/04/21 22:48:58 schwarze Exp $ */
+/* $Id: roff.c,v 1.365 2019/04/21 23:51:21 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org>
@@ -3841,6 +3841,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) {
@@ -3888,7 +3893,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;
}