version 1.227, 2014/09/06 22:39:36 |
version 1.233, 2014/10/20 15:04:56 |
|
|
ROFF_nh, |
ROFF_nh, |
ROFF_nr, |
ROFF_nr, |
ROFF_ns, |
ROFF_ns, |
|
ROFF_pl, |
ROFF_ps, |
ROFF_ps, |
ROFF_rm, |
ROFF_rm, |
ROFF_rr, |
ROFF_rr, |
|
|
struct eqn_node *last_eqn; /* last equation parsed */ |
struct eqn_node *last_eqn; /* last equation parsed */ |
struct eqn_node *first_eqn; /* first equation parsed */ |
struct eqn_node *first_eqn; /* first equation parsed */ |
struct eqn_node *eqn; /* current equation being parsed */ |
struct eqn_node *eqn; /* current equation being parsed */ |
|
int eqn_inline; /* current equation is inline */ |
int options; /* parse options */ |
int options; /* parse options */ |
int rstacksz; /* current size limit of rstack */ |
int rstacksz; /* current size limit of rstack */ |
int rstackpos; /* position in rstack */ |
int rstackpos; /* position in rstack */ |
Line 182 static enum rofferr roff_cond(ROFF_ARGS); |
|
Line 184 static enum rofferr roff_cond(ROFF_ARGS); |
|
static enum rofferr roff_cond_text(ROFF_ARGS); |
static enum rofferr roff_cond_text(ROFF_ARGS); |
static enum rofferr roff_cond_sub(ROFF_ARGS); |
static enum rofferr roff_cond_sub(ROFF_ARGS); |
static enum rofferr roff_ds(ROFF_ARGS); |
static enum rofferr roff_ds(ROFF_ARGS); |
|
static enum rofferr roff_eqndelim(struct roff *, |
|
char **, size_t *, int); |
static int roff_evalcond(const char *, int *); |
static int roff_evalcond(const char *, int *); |
static int roff_evalnum(const char *, int *, int *, int); |
static int roff_evalnum(const char *, int *, int *, int); |
static int roff_evalpar(const char *, int *, int *); |
static int roff_evalpar(const char *, int *, int *); |
Line 256 static struct roffmac roffs[ROFF_MAX] = { |
|
Line 260 static struct roffmac roffs[ROFF_MAX] = { |
|
{ "nh", roff_line_ignore, NULL, NULL, 0, NULL }, |
{ "nh", roff_line_ignore, NULL, NULL, 0, NULL }, |
{ "nr", roff_nr, NULL, NULL, 0, NULL }, |
{ "nr", roff_nr, NULL, NULL, 0, NULL }, |
{ "ns", roff_line_ignore, NULL, NULL, 0, NULL }, |
{ "ns", roff_line_ignore, NULL, NULL, 0, NULL }, |
|
{ "pl", roff_line_ignore, NULL, NULL, 0, NULL }, |
{ "ps", roff_line_ignore, NULL, NULL, 0, NULL }, |
{ "ps", roff_line_ignore, NULL, NULL, 0, NULL }, |
{ "rm", roff_rm, NULL, NULL, 0, NULL }, |
{ "rm", roff_rm, NULL, NULL, 0, NULL }, |
{ "rr", roff_rr, NULL, NULL, 0, NULL }, |
{ "rr", roff_rr, NULL, NULL, 0, NULL }, |
Line 722 roff_parseln(struct roff *r, int ln, char **bufp, |
|
Line 727 roff_parseln(struct roff *r, int ln, char **bufp, |
|
enum rofferr e; |
enum rofferr e; |
int ppos, ctl; |
int ppos, ctl; |
|
|
/* |
/* Handle in-line equation delimiters. */ |
* Run the reserved-word filter only if we have some reserved |
|
* words to fill in. |
|
*/ |
|
|
|
|
if (r->last_eqn != NULL && r->last_eqn->delim && |
|
(r->eqn == NULL || r->eqn_inline)) { |
|
e = roff_eqndelim(r, bufp, szp, pos); |
|
if (e == ROFF_REPARSE) |
|
return(e); |
|
assert(e == ROFF_CONT); |
|
} |
|
|
|
/* Expand some escape sequences. */ |
|
|
e = roff_res(r, bufp, szp, ln, pos); |
e = roff_res(r, bufp, szp, ln, pos); |
if (ROFF_IGN == e) |
if (ROFF_IGN == e) |
return(e); |
return(e); |
Line 759 roff_parseln(struct roff *r, int ln, char **bufp, |
|
Line 771 roff_parseln(struct roff *r, int ln, char **bufp, |
|
return(roff_parsetext(bufp, szp, pos, offs)); |
return(roff_parsetext(bufp, szp, pos, offs)); |
} |
} |
|
|
|
/* Skip empty request lines. */ |
|
|
|
if ((*bufp)[pos] == '"') { |
|
mandoc_msg(MANDOCERR_COMMENT_BAD, r->parse, |
|
ln, pos, NULL); |
|
return(ROFF_IGN); |
|
} else if ((*bufp)[pos] == '\0') |
|
return(ROFF_IGN); |
|
|
/* |
/* |
* If a scope is open, go to the child handler for that macro, |
* If a scope is open, go to the child handler for that macro, |
* as it may want to preprocess before doing anything with it. |
* as it may want to preprocess before doing anything with it. |
Line 1830 roff_T_(ROFF_ARGS) |
|
Line 1851 roff_T_(ROFF_ARGS) |
|
return(ROFF_IGN); |
return(ROFF_IGN); |
} |
} |
|
|
#if 0 |
/* |
static int |
* Handle in-line equation delimiters. |
roff_closeeqn(struct roff *r) |
*/ |
|
static enum rofferr |
|
roff_eqndelim(struct roff *r, char **bufp, size_t *szp, int pos) |
{ |
{ |
|
char *cp1, *cp2; |
|
const char *bef_pr, *bef_nl, *mac, *aft_nl, *aft_pr; |
|
|
return(r->eqn && ROFF_EQN == eqn_end(&r->eqn) ? 1 : 0); |
/* |
|
* Outside equations, look for an opening delimiter. |
|
* If we are inside an equation, we already know it is |
|
* in-line, or this function wouldn't have been called; |
|
* so look for a closing delimiter. |
|
*/ |
|
|
|
cp1 = *bufp + pos; |
|
cp2 = strchr(cp1, r->eqn == NULL ? |
|
r->last_eqn->odelim : r->last_eqn->cdelim); |
|
if (cp2 == NULL) |
|
return(ROFF_CONT); |
|
|
|
*cp2++ = '\0'; |
|
bef_pr = bef_nl = aft_nl = aft_pr = ""; |
|
|
|
/* Handle preceding text, protecting whitespace. */ |
|
|
|
if (**bufp != '\0') { |
|
if (r->eqn == NULL) |
|
bef_pr = "\\&"; |
|
bef_nl = "\n"; |
|
} |
|
|
|
/* |
|
* Prepare replacing the delimiter with an equation macro |
|
* and drop leading white space from the equation. |
|
*/ |
|
|
|
if (r->eqn == NULL) { |
|
while (*cp2 == ' ') |
|
cp2++; |
|
mac = ".EQ"; |
|
} else |
|
mac = ".EN"; |
|
|
|
/* Handle following text, protecting whitespace. */ |
|
|
|
if (*cp2 != '\0') { |
|
aft_nl = "\n"; |
|
if (r->eqn != NULL) |
|
aft_pr = "\\&"; |
|
} |
|
|
|
/* Do the actual replacement. */ |
|
|
|
*szp = mandoc_asprintf(&cp1, "%s%s%s%s%s%s%s", *bufp, |
|
bef_pr, bef_nl, mac, aft_nl, aft_pr, cp2) + 1; |
|
free(*bufp); |
|
*bufp = cp1; |
|
|
|
/* Toggle the in-line state of the eqn subsystem. */ |
|
|
|
r->eqn_inline = r->eqn == NULL; |
|
return(ROFF_REPARSE); |
} |
} |
#endif |
|
|
|
static void |
static void |
roff_openeqn(struct roff *r, const char *name, int line, |
roff_openeqn(struct roff *r, const char *name, int line, |
Line 1849 roff_openeqn(struct roff *r, const char *name, int lin |
|
Line 1927 roff_openeqn(struct roff *r, const char *name, int lin |
|
assert(NULL == r->eqn); |
assert(NULL == r->eqn); |
e = eqn_alloc(name, offs, line, r->parse); |
e = eqn_alloc(name, offs, line, r->parse); |
|
|
if (r->last_eqn) |
if (r->last_eqn) { |
r->last_eqn->next = e; |
r->last_eqn->next = e; |
else |
e->delim = r->last_eqn->delim; |
|
e->odelim = r->last_eqn->odelim; |
|
e->cdelim = r->last_eqn->cdelim; |
|
} else |
r->first_eqn = r->last_eqn = e; |
r->first_eqn = r->last_eqn = e; |
|
|
r->eqn = r->last_eqn = e; |
r->eqn = r->last_eqn = e; |