diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-01-24 01:58:33 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-01-24 01:58:33 +0000 |
commit | 991c1bddc9c3575802d343811e28c260b842dc84 (patch) | |
tree | 5aa08b22b4a4ceb0455bb8a67cfc91a2e0a1cfb9 /man_macro.c | |
parent | 4d5758c224d49c1ba03a52b3d534ecba57dab18d (diff) | |
download | mandoc-991c1bddc9c3575802d343811e28c260b842dc84.tar.gz |
Support .RE with an argument; needed for audio/pms(1).
Diffstat (limited to 'man_macro.c')
-rw-r--r-- | man_macro.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/man_macro.c b/man_macro.c index 2bec95bf..51d93692 100644 --- a/man_macro.c +++ b/man_macro.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * 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 @@ -279,10 +279,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; @@ -293,7 +313,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) { |