Bugfix: When the invocation of a user-defined macro follows a roff
authorschwarze <schwarze@openbsd.org>
Wed, 7 Jan 2015 12:19:17 +0000 (12:19 +0000)
committerschwarze <schwarze@openbsd.org>
Wed, 7 Jan 2015 12:19:17 +0000 (12:19 +0000)
conditional request on the same input line, don't skip the first few
bytes of its content.

regress/usr.bin/mandoc/roff/de/Makefile
regress/usr.bin/mandoc/roff/de/cond.in [new file with mode: 0644]
regress/usr.bin/mandoc/roff/de/cond.out_ascii [new file with mode: 0644]
usr.bin/mandoc/roff.c

index 9e48a3b..82a43f7 100644 (file)
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.7 2015/01/01 09:06:39 schwarze Exp $
+# $OpenBSD: Makefile,v 1.8 2015/01/07 12:19:17 schwarze Exp $
 
-REGRESS_TARGETS = append escname factorial indir startde TH Dd
+REGRESS_TARGETS = append cond escname factorial indir startde TH Dd
 LINT_TARGETS   = escname indir
 
 .include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/roff/de/cond.in b/regress/usr.bin/mandoc/roff/de/cond.in
new file mode 100644 (file)
index 0000000..057ad3a
--- /dev/null
@@ -0,0 +1,13 @@
+.Dd January 7, 2015
+.Dt DE-COND 1
+.Os OpenBSD
+.Sh NAME
+.Nm de-cond
+.Nd conditional execution of a user-defined macro
+.Sh DESCRIPTION
+.de mym
+This is the text printed by the macro.
+..
+preceding text
+.if n .mym
+following text
diff --git a/regress/usr.bin/mandoc/roff/de/cond.out_ascii b/regress/usr.bin/mandoc/roff/de/cond.out_ascii
new file mode 100644 (file)
index 0000000..2f94640
--- /dev/null
@@ -0,0 +1,9 @@
+DE-COND(1)                  General Commands Manual                 DE-COND(1)
+
+N\bNA\bAM\bME\bE
+     d\bde\be-\b-c\bco\bon\bnd\bd - conditional execution of a user-defined macro
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+     preceding text This is the text printed by the macro.  following text
+
+OpenBSD                         January 7, 2015                        OpenBSD
index d7d1ff6..356326e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: roff.c,v 1.119 2015/01/01 19:28:29 schwarze Exp $ */
+/*     $OpenBSD: roff.c,v 1.120 2015/01/07 12:19:17 schwarze Exp $ */
 /*
  * Copyright (c) 2010, 2011, 2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -2167,6 +2167,7 @@ roff_userdef(ROFF_ARGS)
        buf->buf = n1;
        if (buf->sz == 0)
                buf->sz = strlen(buf->buf) + 1;
+       *offs = 0;
 
        return(buf->sz > 1 && buf->buf[buf->sz - 2] == '\n' ?
           ROFF_REPARSE : ROFF_APPEND);