-/* $Id: roff.c,v 1.381 2022/04/13 13:19:34 schwarze Exp $ */
+/* $Id: roff.c,v 1.383 2022/04/24 17:40:22 schwarze Exp $ */
/*
* Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
}
}
} else if (t != TOKEN_NONE &&
- (rr || roffs[t].flags & ROFFMAC_STRUCT))
+ (rr || roffs[t].flags & ROFFMAC_STRUCT)) {
irc |= (*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs);
- else
+ if (irc & ROFF_WHILE)
+ irc &= ~(ROFF_LOOPCONT | ROFF_LOOPEXIT);
+ } else
irc |= rr ? ROFF_CONT : ROFF_IGN;
return irc;
}
roff_shift(ROFF_ARGS)
{
struct mctx *ctx;
- int levels, i;
+ int argpos, levels, i;
+ argpos = pos;
levels = 1;
if (buf->buf[pos] != '\0' &&
roff_evalnum(r, ln, buf->buf, &pos, &levels, 0) == 0) {
ctx = r->mstack + r->mstackpos;
if (levels > ctx->argc) {
mandoc_msg(MANDOCERR_SHIFT,
- ln, pos, "%d, but max is %d", levels, ctx->argc);
+ ln, argpos, "%d, but max is %d", levels, ctx->argc);
levels = ctx->argc;
}
+ if (levels < 0) {
+ mandoc_msg(MANDOCERR_ARG_NEG, ln, argpos, "shift %d", levels);
+ levels = 0;
+ }
if (levels == 0)
return ROFF_IGN;
for (i = 0; i < levels; i++)