=================================================================== RCS file: /cvs/texi2mdoc/util.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -p -r1.17 -r1.18 --- texi2mdoc/util.c 2015/02/28 00:03:20 1.17 +++ texi2mdoc/util.c 2015/02/28 08:41:59 1.18 @@ -1,4 +1,4 @@ -/* $Id: util.c,v 1.17 2015/02/28 00:03:20 kristaps Exp $ */ +/* $Id: util.c,v 1.18 2015/02/28 08:41:59 kristaps Exp $ */ /* * Copyright (c) 2015 Kristaps Dzonsons * @@ -719,9 +719,9 @@ parsearg(struct texi *p, size_t *pos, size_t num) * This will stop in the event of EOF or if we're not at a bracket. */ void -parsebracket(struct texi *p, size_t *pos) +parsebracket(struct texi *p, size_t *pos, int dostack) { - size_t end, sv; + size_t end, sv, stack; enum texicmd cmd; struct teximacro *macro; @@ -732,12 +732,25 @@ parsebracket(struct texi *p, size_t *pos) return; advance(p, pos); + stack = 0; while ((*pos = advancenext(p, pos)) < BUFSZ(p)) { switch (BUF(p)[*pos]) { case ('}'): + if (stack > 0) { + stack--; + advance(p, pos); + texiputchar(p, '}'); + continue; + } advance(p, pos); return; case ('{'): + if (dostack) { + stack++; + advance(p, pos); + texiputchar(p, '{'); + continue; + } if (0 == p->ign) texiwarn(p, "unexpected \"{\""); advance(p, pos); @@ -874,7 +887,7 @@ parselinearg(struct texi *p, size_t *pos) } if (*pos < BUFSZ(p) && '{' == BUF(p)[*pos]) - parsebracket(p, pos); + parsebracket(p, pos, 0); else if (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos]) parsesingle(p, pos); else