Log Message: ----------- 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. Modified Files: -------------- mandoc: roff.c mandoc/regress/roff/de: Makefile Added Files: ----------- mandoc/regress/roff/de: empty.in empty.out_ascii Revision Data ------------- Index: roff.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff.c,v retrieving revision 1.364 retrieving revision 1.365 diff -Lroff.c -Lroff.c -u -p -r1.364 -r1.365 --- roff.c +++ roff.c @@ -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; } Index: Makefile =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/roff/de/Makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -Lregress/roff/de/Makefile -Lregress/roff/de/Makefile -u -p -r1.4 -r1.5 --- regress/roff/de/Makefile +++ regress/roff/de/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.12 2019/02/06 20:54:28 schwarze Exp $ +# $OpenBSD: Makefile,v 1.13 2019/04/21 23:45:50 schwarze Exp $ -REGRESS_TARGETS = append cond escname factorial indir infinite startde tab -REGRESS_TARGETS += TH Dd +REGRESS_TARGETS = append cond empty escname factorial +REGRESS_TARGETS += indir infinite startde tab TH Dd LINT_TARGETS = escname indir infinite # groff-1.22.4 defect: --- /dev/null +++ regress/roff/de/empty.in @@ -0,0 +1,18 @@ +.\" $OpenBSD: empty.in,v 1.1 2019/04/21 23:45:50 schwarze Exp $ +.Dd $Mdocdate: April 21 2019 $ +.Dt DE-EMPTY 1 +.Os +.Sh NAME +.Nm de-empty +.Nd empty user-defined macro with arguments +.Sh DESCRIPTION +initial text +.de empty +.. +.de real +arg=\\$1 +.empty wrong +arg=\\$1 +.. +.real right +final text --- /dev/null +++ regress/roff/de/empty.out_ascii @@ -0,0 +1,9 @@ +DE-EMPTY(1) General Commands Manual DE-EMPTY(1) + +N\bNA\bAM\bME\bE + d\bde\be-\b-e\bem\bmp\bpt\bty\by - empty user-defined macro with arguments + +D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN + initial text arg=right arg=right final text + +OpenBSD April 21, 2019 OpenBSD -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv