version 1.176, 2017/06/04 22:43:50 |
version 1.177, 2017/06/06 15:00:56 |
|
|
static enum rofferr roff_onearg(ROFF_ARGS); |
static enum rofferr roff_onearg(ROFF_ARGS); |
static enum roff_tok roff_parse(struct roff *, char *, int *, |
static enum roff_tok roff_parse(struct roff *, char *, int *, |
int, int); |
int, int); |
static enum rofferr roff_parsetext(struct buf *, int, int *); |
static enum rofferr roff_parsetext(struct roff *, struct buf *, |
|
int, int *); |
static enum rofferr roff_res(struct roff *, struct buf *, int, int); |
static enum rofferr roff_res(struct roff *, struct buf *, int, int); |
static enum rofferr roff_rm(ROFF_ARGS); |
static enum rofferr roff_rm(ROFF_ARGS); |
static enum rofferr roff_rr(ROFF_ARGS); |
static enum rofferr roff_rr(ROFF_ARGS); |
|
|
#define ROFFNUM_WHITE (1 << 1) /* Skip whitespace in roff_evalnum(). */ |
#define ROFFNUM_WHITE (1 << 1) /* Skip whitespace in roff_evalnum(). */ |
|
|
const char *__roff_name[MAN_MAX + 1] = { |
const char *__roff_name[MAN_MAX + 1] = { |
"br", "ft", "ll", "mc", |
"br", "ce", "ft", "ll", |
"sp", "ta", "ti", NULL, |
"mc", "sp", "ta", "ti", |
|
NULL, |
"ab", "ad", "af", "aln", |
"ab", "ad", "af", "aln", |
"als", "am", "am1", "ami", |
"als", "am", "am1", "ami", |
"ami1", "as", "as1", "asciify", |
"ami1", "as", "as1", "asciify", |
"backtrace", "bd", "bleedat", "blm", |
"backtrace", "bd", "bleedat", "blm", |
"box", "boxa", "bp", "BP", |
"box", "boxa", "bp", "BP", |
"break", "breakchar", "brnl", "brp", |
"break", "breakchar", "brnl", "brp", |
"brpnl", "c2", "cc", "ce", |
"brpnl", "c2", "cc", |
"cf", "cflags", "ch", "char", |
"cf", "cflags", "ch", "char", |
"chop", "class", "close", "CL", |
"chop", "class", "close", "CL", |
"color", "composite", "continue", "cp", |
"color", "composite", "continue", "cp", |
|
|
|
|
static struct roffmac roffs[TOKEN_NONE] = { |
static struct roffmac roffs[TOKEN_NONE] = { |
{ roff_br, NULL, NULL, 0 }, /* br */ |
{ roff_br, NULL, NULL, 0 }, /* br */ |
|
{ roff_onearg, NULL, NULL, 0 }, /* ce */ |
{ 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_onearg, NULL, NULL, 0 }, /* mc */ |
|
|
{ roff_line_ignore, NULL, NULL, 0 }, /* brpnl */ |
{ roff_line_ignore, NULL, NULL, 0 }, /* brpnl */ |
{ roff_unsupp, NULL, NULL, 0 }, /* c2 */ |
{ roff_unsupp, NULL, NULL, 0 }, /* c2 */ |
{ roff_cc, NULL, NULL, 0 }, /* cc */ |
{ roff_cc, NULL, NULL, 0 }, /* cc */ |
{ roff_line_ignore, NULL, NULL, 0 }, /* ce */ |
|
{ roff_insec, NULL, NULL, 0 }, /* cf */ |
{ roff_insec, NULL, NULL, 0 }, /* cf */ |
{ roff_line_ignore, NULL, NULL, 0 }, /* cflags */ |
{ roff_line_ignore, NULL, NULL, 0 }, /* cflags */ |
{ roff_line_ignore, NULL, NULL, 0 }, /* ch */ |
{ roff_line_ignore, NULL, NULL, 0 }, /* ch */ |
|
|
#include "predefs.in" |
#include "predefs.in" |
}; |
}; |
|
|
|
static int roffce_lines; /* number of input lines to center */ |
|
static struct roff_node *roffce_node; /* active request */ |
static int roffit_lines; /* number of lines to delay */ |
static int roffit_lines; /* number of lines to delay */ |
static char *roffit_macro; /* nil-terminated macro line */ |
static char *roffit_macro; /* nil-terminated macro line */ |
|
|
|
|
* Process text streams. |
* Process text streams. |
*/ |
*/ |
static enum rofferr |
static enum rofferr |
roff_parsetext(struct buf *buf, int pos, int *offs) |
roff_parsetext(struct roff *r, struct buf *buf, int pos, int *offs) |
{ |
{ |
size_t sz; |
size_t sz; |
const char *start; |
const char *start; |
|
|
} else if (roffit_lines > 1) |
} else if (roffit_lines > 1) |
--roffit_lines; |
--roffit_lines; |
|
|
|
if (roffce_node != NULL && buf->buf[pos] != '\0') { |
|
if (roffce_lines < 1) { |
|
r->man->last = roffce_node; |
|
r->man->next = ROFF_NEXT_SIBLING; |
|
roffce_lines = 0; |
|
roffce_node = NULL; |
|
} else |
|
roffce_lines--; |
|
} |
|
|
/* Convert all breakable hyphens into ASCII_HYPH. */ |
/* Convert all breakable hyphens into ASCII_HYPH. */ |
|
|
start = p = buf->buf + pos; |
start = p = buf->buf + pos; |
|
|
if (r->tbl != NULL && ( ! ctl || buf->buf[pos] == '\0')) |
if (r->tbl != NULL && ( ! ctl || buf->buf[pos] == '\0')) |
return tbl_read(r->tbl, ln, buf->buf, ppos); |
return tbl_read(r->tbl, ln, buf->buf, ppos); |
if ( ! ctl) |
if ( ! ctl) |
return roff_parsetext(buf, pos, offs); |
return roff_parsetext(r, buf, pos, offs); |
|
|
/* Skip empty request lines. */ |
/* Skip empty request lines. */ |
|
|
|
|
return tbl_read(r->tbl, ln, buf->buf, pos); |
return tbl_read(r->tbl, ln, buf->buf, pos); |
} |
} |
|
|
|
/* For now, let high level macros abort .ce mode. */ |
|
|
|
if (ctl && roffce_node != NULL && |
|
(t == TOKEN_NONE || t == ROFF_EQ || t == ROFF_TS)) { |
|
r->man->last = roffce_node; |
|
r->man->next = ROFF_NEXT_SIBLING; |
|
roffce_lines = 0; |
|
roffce_node = NULL; |
|
} |
|
|
/* |
/* |
* This is neither a roff request nor a user-defined macro. |
* This is neither a roff request nor a user-defined macro. |
* Let the standard macro set parsers handle it. |
* Let the standard macro set parsers handle it. |
|
|
{ |
{ |
struct roff_node *n; |
struct roff_node *n; |
char *cp; |
char *cp; |
|
int npos; |
|
|
if (r->man->flags & (MAN_BLINE | MAN_ELINE) && |
if (r->man->flags & (MAN_BLINE | MAN_ELINE) && |
(tok == ROFF_sp || tok == ROFF_ti)) |
(tok == ROFF_sp || tok == ROFF_ti)) |
man_breakscope(r->man, tok); |
man_breakscope(r->man, tok); |
|
|
|
if (tok == ROFF_ce && roffce_node != NULL) { |
|
r->man->last = roffce_node; |
|
r->man->next = ROFF_NEXT_SIBLING; |
|
} |
|
|
roff_elem_alloc(r->man, ln, ppos, tok); |
roff_elem_alloc(r->man, ln, ppos, tok); |
n = r->man->last; |
n = r->man->last; |
|
|
|
|
roff_word_alloc(r->man, ln, pos, buf->buf + pos); |
roff_word_alloc(r->man, ln, pos, buf->buf + pos); |
} |
} |
|
|
n->flags |= NODE_LINE | NODE_VALID | NODE_ENDED; |
if (tok == ROFF_ce) { |
r->man->last = n; |
if (r->man->last->tok == ROFF_ce) { |
|
roff_word_alloc(r->man, ln, pos, "1"); |
|
r->man->last->flags |= NODE_NOSRC; |
|
} |
|
npos = 0; |
|
if (roff_evalnum(r, ln, r->man->last->string, &npos, |
|
&roffce_lines, 0) == 0) { |
|
mandoc_vmsg(MANDOCERR_CE_NONUM, |
|
r->parse, ln, pos, "ce %s", buf->buf + pos); |
|
roffce_lines = 1; |
|
} |
|
if (roffce_lines < 1) { |
|
r->man->last = r->man->last->parent; |
|
roffce_node = NULL; |
|
roffce_lines = 0; |
|
} else |
|
roffce_node = r->man->last->parent; |
|
} else { |
|
n->flags |= NODE_VALID | NODE_ENDED; |
|
r->man->last = n; |
|
} |
|
n->flags |= NODE_LINE; |
r->man->next = ROFF_NEXT_SIBLING; |
r->man->next = ROFF_NEXT_SIBLING; |
return ROFF_IGN; |
return ROFF_IGN; |
} |
} |