version 1.120, 2011/01/03 23:24:16 |
version 1.122, 2011/01/16 04:00:34 |
Line 134 static enum rofferr roff_cond_sub(ROFF_ARGS); |
|
Line 134 static enum rofferr roff_cond_sub(ROFF_ARGS); |
|
static enum rofferr roff_ds(ROFF_ARGS); |
static enum rofferr roff_ds(ROFF_ARGS); |
static enum roffrule roff_evalcond(const char *, int *); |
static enum roffrule roff_evalcond(const char *, int *); |
static void roff_freestr(struct roff *); |
static void roff_freestr(struct roff *); |
|
static char *roff_getname(struct roff *, char **, int, int); |
static const char *roff_getstrn(const struct roff *, |
static const char *roff_getstrn(const struct roff *, |
const char *, size_t); |
const char *, size_t); |
static enum rofferr roff_line_ignore(ROFF_ARGS); |
static enum rofferr roff_line_ignore(ROFF_ARGS); |
static enum rofferr roff_line_error(ROFF_ARGS); |
|
static enum rofferr roff_nr(ROFF_ARGS); |
static enum rofferr roff_nr(ROFF_ARGS); |
static int roff_res(struct roff *, |
static int roff_res(struct roff *, |
char **, size_t *, int); |
char **, size_t *, int); |
|
static enum rofferr roff_rm(ROFF_ARGS); |
static void roff_setstr(struct roff *, |
static void roff_setstr(struct roff *, |
const char *, const char *, int); |
const char *, const char *, int); |
static enum rofferr roff_so(ROFF_ARGS); |
static enum rofferr roff_so(ROFF_ARGS); |
Line 174 static struct roffmac roffs[ROFF_MAX] = { |
|
Line 175 static struct roffmac roffs[ROFF_MAX] = { |
|
{ "ne", roff_line_ignore, NULL, NULL, 0, NULL }, |
{ "ne", roff_line_ignore, NULL, NULL, 0, NULL }, |
{ "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 }, |
{ "rm", roff_line_error, NULL, NULL, 0, NULL }, |
{ "rm", roff_rm, NULL, NULL, 0, NULL }, |
{ "so", roff_so, NULL, NULL, 0, NULL }, |
{ "so", roff_so, NULL, NULL, 0, NULL }, |
{ "tr", roff_line_ignore, NULL, NULL, 0, NULL }, |
{ "tr", roff_line_ignore, NULL, NULL, 0, NULL }, |
{ "TS", roff_TS, NULL, NULL, 0, NULL }, |
{ "TS", roff_TS, NULL, NULL, 0, NULL }, |
Line 520 roff_endparse(struct roff *r) |
|
Line 521 roff_endparse(struct roff *r) |
|
{ |
{ |
|
|
if (r->last) |
if (r->last) |
(*r->msg)(MANDOCERR_SCOPEEXIT, r->data, |
(*r->msg)(MANDOCERR_SCOPEEXIT, r->data, |
r->last->line, r->last->col, NULL); |
r->last->line, r->last->col, NULL); |
|
|
if (r->tbl) { |
if (r->tbl) { |
Line 939 roff_line_ignore(ROFF_ARGS) |
|
Line 940 roff_line_ignore(ROFF_ARGS) |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static enum rofferr |
static enum rofferr |
roff_line_error(ROFF_ARGS) |
|
{ |
|
|
|
(*r->msg)(MANDOCERR_REQUEST, r->data, ln, ppos, roffs[tok].name); |
|
return(ROFF_IGN); |
|
} |
|
|
|
/* ARGSUSED */ |
|
static enum rofferr |
|
roff_cond(ROFF_ARGS) |
roff_cond(ROFF_ARGS) |
{ |
{ |
int sv; |
int sv; |
Line 1056 roff_ds(ROFF_ARGS) |
|
Line 1048 roff_ds(ROFF_ARGS) |
|
* will have `bar " ' as its value. |
* will have `bar " ' as its value. |
*/ |
*/ |
|
|
name = *bufp + pos; |
string = *bufp + pos; |
|
name = roff_getname(r, &string, ln, pos); |
if ('\0' == *name) |
if ('\0' == *name) |
return(ROFF_IGN); |
return(ROFF_IGN); |
|
|
string = name; |
/* Read past initial double-quote. */ |
/* Read until end of name. */ |
if ('"' == *string) |
while (*string && ' ' != *string) |
|
string++; |
string++; |
|
|
/* Nil-terminate name. */ |
|
if (*string) |
|
*(string++) = '\0'; |
|
|
|
/* Read past spaces. */ |
|
while (*string && ' ' == *string) |
|
string++; |
|
|
|
/* Read passed initial double-quote. */ |
|
if (*string && '"' == *string) |
|
string++; |
|
|
|
/* The rest is the value. */ |
/* The rest is the value. */ |
roff_setstr(r, name, string, 0); |
roff_setstr(r, name, string, 0); |
return(ROFF_IGN); |
return(ROFF_IGN); |
Line 1087 roff_ds(ROFF_ARGS) |
|
Line 1067 roff_ds(ROFF_ARGS) |
|
static enum rofferr |
static enum rofferr |
roff_nr(ROFF_ARGS) |
roff_nr(ROFF_ARGS) |
{ |
{ |
const char *key, *val; |
const char *key; |
|
char *val; |
struct reg *rg; |
struct reg *rg; |
|
|
key = &(*bufp)[pos]; |
val = *bufp + pos; |
|
key = roff_getname(r, &val, ln, pos); |
rg = r->regs->regs; |
rg = r->regs->regs; |
|
|
/* Parse register request. */ |
|
while ((*bufp)[pos] && ' ' != (*bufp)[pos]) |
|
pos++; |
|
|
|
/* |
|
* Set our nil terminator. Because this line is going to be |
|
* ignored anyway, we can munge it as we please. |
|
*/ |
|
if ((*bufp)[pos]) |
|
(*bufp)[pos++] = '\0'; |
|
|
|
/* Skip whitespace to register token. */ |
|
while ((*bufp)[pos] && ' ' == (*bufp)[pos]) |
|
pos++; |
|
|
|
val = &(*bufp)[pos]; |
|
|
|
/* Process register token. */ |
|
|
|
if (0 == strcmp(key, "nS")) { |
if (0 == strcmp(key, "nS")) { |
rg[(int)REG_nS].set = 1; |
rg[(int)REG_nS].set = 1; |
if ( ! roff_parse_nat(val, &rg[(int)REG_nS].v.u)) |
if ( ! roff_parse_nat(val, &rg[(int)REG_nS].v.u)) |
Line 1123 roff_nr(ROFF_ARGS) |
|
Line 1086 roff_nr(ROFF_ARGS) |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static enum rofferr |
static enum rofferr |
|
roff_rm(ROFF_ARGS) |
|
{ |
|
const char *name; |
|
char *cp; |
|
|
|
cp = *bufp + pos; |
|
while ('\0' != *cp) { |
|
name = roff_getname(r, &cp, ln, cp - *bufp); |
|
if ('\0' != *name) |
|
roff_setstr(r, name, NULL, 0); |
|
} |
|
return(ROFF_IGN); |
|
} |
|
|
|
/* ARGSUSED */ |
|
static enum rofferr |
roff_TE(ROFF_ARGS) |
roff_TE(ROFF_ARGS) |
{ |
{ |
|
|
Line 1249 roff_userdef(ROFF_ARGS) |
|
Line 1228 roff_userdef(ROFF_ARGS) |
|
return(*szp > 1 && '\n' == (*bufp)[(int)*szp - 2] ? |
return(*szp > 1 && '\n' == (*bufp)[(int)*szp - 2] ? |
ROFF_REPARSE : ROFF_APPEND); |
ROFF_REPARSE : ROFF_APPEND); |
} |
} |
|
|
|
|
|
static char * |
|
roff_getname(struct roff *r, char **cpp, int ln, int pos) |
|
{ |
|
char *name, *cp; |
|
|
|
name = *cpp; |
|
if ('\0' == *name) |
|
return(name); |
|
|
|
/* Read until end of name. */ |
|
for (cp = name; '\0' != *cp && ' ' != *cp; cp++) { |
|
if ('\\' != *cp) |
|
continue; |
|
cp++; |
|
if ('\\' == *cp) |
|
continue; |
|
(*r->msg)(MANDOCERR_NAMESC, r->data, ln, pos, NULL); |
|
*cp = '\0'; |
|
name = cp; |
|
} |
|
|
|
/* Nil-terminate name. */ |
|
if ('\0' != *cp) |
|
*(cp++) = '\0'; |
|
|
|
/* Read past spaces. */ |
|
while (' ' == *cp) |
|
cp++; |
|
|
|
*cpp = cp; |
|
return(name); |
|
} |
|
|
|
|
/* |
/* |
* Store *string into the user-defined string called *name. |
* Store *string into the user-defined string called *name. |