diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2015-06-27 13:25:31 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2015-06-27 13:25:31 +0000 |
commit | 077a1eb1eb781836e597cdb21a412504402045af (patch) | |
tree | d61177fe1fc31f55168d9e4ea64b2175e4b7efed | |
parent | f82f3b63e24b04d6f086c68f96343983c4ee1b73 (diff) |
Ignore blank characters at the beginning of a conditional block,
that is, after "\{".
Issue found by Markus <Waldeck at gmx dot de> in bash(1).
-rw-r--r-- | regress/usr.bin/mandoc/roff/cond/if.in | 5 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/roff/cond/if.out_ascii | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/roff.c | 4 |
3 files changed, 9 insertions, 3 deletions
diff --git a/regress/usr.bin/mandoc/roff/cond/if.in b/regress/usr.bin/mandoc/roff/cond/if.in index 68ae4f7ee4e..f243fbdf0d7 100644 --- a/regress/usr.bin/mandoc/roff/cond/if.in +++ b/regress/usr.bin/mandoc/roff/cond/if.in @@ -1,4 +1,4 @@ -.TH IF 1 "May 30, 2012" OpenBSD +.TH IF 1 "June 27, 2015" OpenBSD .SH NAME if \- the roff conditional instruction .SH DESCRIPTION @@ -17,6 +17,9 @@ True condition with whitespace: .if n \{One-line true cond\}ition with block. .if t \{One-line false cond\}ition with block. .br +.if n \{ One-line true cond\}ition with block with leading blanks. +.if t \{ One-line false cond\}ition with block with leading blanks. +.br .if n \{Two-line true condition without cont\}inuation and macros. .if t \{Two-line false condition diff --git a/regress/usr.bin/mandoc/roff/cond/if.out_ascii b/regress/usr.bin/mandoc/roff/cond/if.out_ascii index 19caa56bbd2..7fb9eecc5bf 100644 --- a/regress/usr.bin/mandoc/roff/cond/if.out_ascii +++ b/regress/usr.bin/mandoc/roff/cond/if.out_ascii @@ -13,6 +13,7 @@ DDEESSCCRRIIPPTTIIOONN True condition with whitespace: One-line true condition with block. + One-line true condition with block with leading blanks. Two-line true condition without continuation and macros. Two-line true condition wwiitthhoouutt ccoonnttiinnuuaattiioonn bbuutt wwiitthh mmaaccrrooss.. Two-line true condition with continuation and macros. @@ -30,4 +31,4 @@ DDEESSCCRRIIPPTTIIOONN -OpenBSD May 30, 2012 IF(1) +OpenBSD June 27, 2015 IF(1) diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 62f524f3976..1005fff77a9 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.143 2015/05/31 23:12:16 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.144 2015/06/27 13:25:30 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -2263,6 +2263,8 @@ roff_cond(ROFF_ARGS) if (buf->buf[pos] == '\\' && buf->buf[pos + 1] == '{') { r->last->endspan = -1; pos += 2; + while (buf->buf[pos] == ' ') + pos++; goto out; } |