From 4ea4dffa7b5f9edcd44a043e69c061f748aae2d5 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 21 Apr 2019 23:51:21 +0000 Subject: 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. --- roff.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'roff.c') 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 * Copyright (c) 2010-2015, 2017-2019 Ingo Schwarze @@ -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; } -- cgit v1.2.3