diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2015-01-24 01:59:41 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2015-01-24 01:59:41 +0000 |
commit | d0cea2e71f8752aa97dae610e4eb8b34cdf6e45c (patch) | |
tree | 00a5d89aa3f7e3219195de98ac01bca20caf863c /usr.bin/mandoc | |
parent | 2fda989bf1d6710a0aaa1f603209734760d23bd5 (diff) |
Support .RE with an argument; needed for audio/pms(1).
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r-- | usr.bin/mandoc/man_macro.c | 26 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/read.c | 3 |
3 files changed, 27 insertions, 5 deletions
diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c index cb5430a52a2..ebf620a162d 100644 --- a/usr.bin/mandoc/man_macro.c +++ b/usr.bin/mandoc/man_macro.c @@ -1,7 +1,7 @@ -/* $OpenBSD: man_macro.c,v 1.54 2014/12/16 17:24:58 schwarze Exp $ */ +/* $OpenBSD: man_macro.c,v 1.55 2015/01/24 01:59:40 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2012, 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de> * * Permission to use, copy, modify, and distribute this software for any @@ -277,10 +277,30 @@ blk_close(MACRO_PROT_ARGS) { enum mant ntok; const struct man_node *nn; + char *p; + int nrew, target; + nrew = 1; switch (tok) { case MAN_RE: ntok = MAN_RS; + if ( ! man_args(man, line, pos, buf, &p)) + break; + for (nn = man->last->parent; nn; nn = nn->parent) + if (nn->tok == ntok && nn->type == MAN_BLOCK) + nrew++; + target = strtol(p, &p, 10); + if (*p != '\0') + mandoc_vmsg(MANDOCERR_ARG_EXCESS, man->parse, + line, p - buf, "RE ... %s", p); + if (target == 0) + target = 1; + nrew -= target; + if (nrew < 1) { + mandoc_vmsg(MANDOCERR_RE_NOTOPEN, man->parse, + line, ppos, "RE %d", target); + return; + } break; case MAN_UE: ntok = MAN_UR; @@ -291,7 +311,7 @@ blk_close(MACRO_PROT_ARGS) } for (nn = man->last->parent; nn; nn = nn->parent) - if (nn->tok == ntok && nn->type == MAN_BLOCK) + if (nn->tok == ntok && nn->type == MAN_BLOCK && ! --nrew) break; if (nn == NULL) { diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index ec68dc5356c..91696fdd60a 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.127 2015/01/22 21:36:44 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.128 2015/01/24 01:59:40 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -151,6 +151,7 @@ enum mandocerr { MANDOCERR_IT_STRAY, /* skipping item outside list: It ... */ MANDOCERR_TA_STRAY, /* skipping column outside column list: Ta */ MANDOCERR_BLK_NOTOPEN, /* skipping end of block that is not open */ + MANDOCERR_RE_NOTOPEN, /* fewer RS blocks open, skipping: RE arg */ MANDOCERR_BLK_BROKEN, /* inserting missing end of block: macro ... */ MANDOCERR_BLK_NOEND, /* appending missing end of block: macro */ diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 79762f42e9e..7f8c4c62b0a 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.89 2015/01/22 21:36:44 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.90 2015/01/24 01:59:40 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -190,6 +190,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "skipping item outside list", "skipping column outside column list", "skipping end of block that is not open", + "fewer RS blocks open, skipping", "inserting missing end of block", "appending missing end of block", |