version 1.379, 2021/10/04 10:12:27 |
version 1.384, 2022/04/28 16:21:10 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2010-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
Line 227 static int roff_line_ignore(ROFF_ARGS); |
|
Line 227 static int roff_line_ignore(ROFF_ARGS); |
|
static void roff_man_alloc1(struct roff_man *); |
static void roff_man_alloc1(struct roff_man *); |
static void roff_man_free1(struct roff_man *); |
static void roff_man_free1(struct roff_man *); |
static int roff_manyarg(ROFF_ARGS); |
static int roff_manyarg(ROFF_ARGS); |
|
static int roff_mc(ROFF_ARGS); |
static int roff_noarg(ROFF_ARGS); |
static int roff_noarg(ROFF_ARGS); |
static int roff_nop(ROFF_ARGS); |
static int roff_nop(ROFF_ARGS); |
static int roff_nr(ROFF_ARGS); |
static int roff_nr(ROFF_ARGS); |
Line 379 static struct roffmac roffs[TOKEN_NONE] = { |
|
Line 380 static struct roffmac roffs[TOKEN_NONE] = { |
|
{ roff_noarg, NULL, NULL, 0 }, /* fi */ |
{ roff_noarg, NULL, NULL, 0 }, /* fi */ |
{ roff_onearg, NULL, NULL, 0 }, /* ft */ |
{ roff_onearg, NULL, NULL, 0 }, /* ft */ |
{ roff_onearg, NULL, NULL, 0 }, /* ll */ |
{ roff_onearg, NULL, NULL, 0 }, /* ll */ |
{ roff_onearg, NULL, NULL, 0 }, /* mc */ |
{ roff_mc, NULL, NULL, 0 }, /* mc */ |
{ roff_noarg, NULL, NULL, 0 }, /* nf */ |
{ roff_noarg, NULL, NULL, 0 }, /* nf */ |
{ roff_onearg, NULL, NULL, 0 }, /* po */ |
{ roff_onearg, NULL, NULL, 0 }, /* po */ |
{ roff_onearg, NULL, NULL, 0 }, /* rj */ |
{ roff_onearg, NULL, NULL, 0 }, /* rj */ |
|
|
roff_man_free(struct roff_man *man) |
roff_man_free(struct roff_man *man) |
{ |
{ |
roff_man_free1(man); |
roff_man_free1(man); |
|
free(man->os_r); |
free(man); |
free(man); |
} |
} |
|
|
Line 1400 roff_expand(struct roff *r, struct buf *buf, int ln, i |
|
Line 1402 roff_expand(struct roff *r, struct buf *buf, int ln, i |
|
|
|
term = '\0'; |
term = '\0'; |
cp = stesc + 1; |
cp = stesc + 1; |
if (*cp == 'E') |
while (*cp == 'E') |
cp++; |
cp++; |
esct = cp; |
esct = cp; |
switch (*esct) { |
switch (*esct) { |
Line 2432 roff_cond_sub(ROFF_ARGS) |
|
Line 2434 roff_cond_sub(ROFF_ARGS) |
|
} |
} |
} |
} |
} else if (t != TOKEN_NONE && |
} 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); |
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; |
irc |= rr ? ROFF_CONT : ROFF_IGN; |
return irc; |
return irc; |
} |
} |
Line 3729 roff_eo(ROFF_ARGS) |
|
Line 3733 roff_eo(ROFF_ARGS) |
|
} |
} |
|
|
static int |
static int |
|
roff_mc(ROFF_ARGS) |
|
{ |
|
struct roff_node *n; |
|
char *cp; |
|
|
|
/* Parse the first argument. */ |
|
|
|
cp = buf->buf + pos; |
|
if (*cp != '\0') |
|
cp++; |
|
if (buf->buf[pos] == '\\') { |
|
switch (mandoc_escape((const char **)&cp, NULL, NULL)) { |
|
case ESCAPE_SPECIAL: |
|
case ESCAPE_UNICODE: |
|
case ESCAPE_NUMBERED: |
|
break; |
|
default: |
|
*cp = '\0'; |
|
mandoc_msg(MANDOCERR_MC_ESC, ln, pos, |
|
"mc %s", buf->buf + pos); |
|
buf->buf[pos] = '\0'; |
|
break; |
|
} |
|
} |
|
|
|
/* Ignore additional arguments. */ |
|
|
|
while (*cp == ' ') |
|
*cp++ = '\0'; |
|
if (*cp != '\0') { |
|
mandoc_msg(MANDOCERR_MC_DIST, ln, (int)(cp - buf->buf), |
|
"mc ... %s", cp); |
|
*cp = '\0'; |
|
} |
|
|
|
/* Create the .mc node. */ |
|
|
|
roff_elem_alloc(r->man, ln, ppos, tok); |
|
n = r->man->last; |
|
if (buf->buf[pos] != '\0') |
|
roff_word_alloc(r->man, ln, pos, buf->buf + pos); |
|
n->flags |= NODE_LINE | NODE_VALID | NODE_ENDED; |
|
r->man->last = n; |
|
r->man->next = ROFF_NEXT_SIBLING; |
|
return ROFF_IGN; |
|
} |
|
|
|
static int |
roff_nop(ROFF_ARGS) |
roff_nop(ROFF_ARGS) |
{ |
{ |
while (buf->buf[pos] == ' ') |
while (buf->buf[pos] == ' ') |
|
|
roff_shift(ROFF_ARGS) |
roff_shift(ROFF_ARGS) |
{ |
{ |
struct mctx *ctx; |
struct mctx *ctx; |
int levels, i; |
int argpos, levels, i; |
|
|
|
argpos = pos; |
levels = 1; |
levels = 1; |
if (buf->buf[pos] != '\0' && |
if (buf->buf[pos] != '\0' && |
roff_evalnum(r, ln, buf->buf, &pos, &levels, 0) == 0) { |
roff_evalnum(r, ln, buf->buf, &pos, &levels, 0) == 0) { |
Line 3885 roff_shift(ROFF_ARGS) |
|
Line 3938 roff_shift(ROFF_ARGS) |
|
ctx = r->mstack + r->mstackpos; |
ctx = r->mstack + r->mstackpos; |
if (levels > ctx->argc) { |
if (levels > ctx->argc) { |
mandoc_msg(MANDOCERR_SHIFT, |
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; |
levels = ctx->argc; |
|
} |
|
if (levels < 0) { |
|
mandoc_msg(MANDOCERR_ARG_NEG, ln, argpos, "shift %d", levels); |
|
levels = 0; |
} |
} |
if (levels == 0) |
if (levels == 0) |
return ROFF_IGN; |
return ROFF_IGN; |