version 1.94, 2010/07/07 15:04:54 |
version 1.97, 2010/07/27 19:56:50 |
Line 132 static const char *roff_getstrn(const struct roff *, |
|
Line 132 static const char *roff_getstrn(const struct roff *, |
|
const char *, size_t); |
const char *, size_t); |
static enum rofferr roff_line(ROFF_ARGS); |
static enum rofferr roff_line(ROFF_ARGS); |
static enum rofferr roff_nr(ROFF_ARGS); |
static enum rofferr roff_nr(ROFF_ARGS); |
static int roff_res(struct roff *, int, |
static int roff_res(struct roff *, |
char **, size_t *, int, int *); |
char **, size_t *, int); |
static void roff_setstr(struct roff *, |
static void roff_setstr(struct roff *, |
const char *, const char *); |
const char *, const char *); |
|
|
Line 332 roff_alloc(struct regset *regs, const mandocmsg msg, v |
|
Line 332 roff_alloc(struct regset *regs, const mandocmsg msg, v |
|
* is processed. |
* is processed. |
*/ |
*/ |
static int |
static int |
roff_res(struct roff *r, int ln, char **bufp, |
roff_res(struct roff *r, char **bufp, size_t *szp, int pos) |
size_t *szp, int pos, int *offs) |
|
{ |
{ |
const char *cp, *cpp, *st, *res; |
const char *cp, *cpp, *st, *res; |
int i, maxl; |
int i, maxl; |
size_t nsz; |
size_t nsz; |
char *n; |
char *n; |
|
|
|
/* LINTED */ |
for (cp = &(*bufp)[pos]; (cpp = strstr(cp, "\\*")); cp++) { |
for (cp = &(*bufp)[pos]; (cpp = strstr(cp, "\\*")); cp++) { |
cp = cpp + 2; |
cp = cpp + 2; |
switch (*cp) { |
switch (*cp) { |
Line 406 roff_parseln(struct roff *r, int ln, char **bufp, |
|
Line 406 roff_parseln(struct roff *r, int ln, char **bufp, |
|
* words to fill in. |
* words to fill in. |
*/ |
*/ |
|
|
if (r->first_string && ! roff_res(r, ln, bufp, szp, pos, offs)) |
if (r->first_string && ! roff_res(r, bufp, szp, pos)) |
return(ROFF_RERUN); |
return(ROFF_RERUN); |
|
|
/* |
/* |
Line 969 roff_cond(ROFF_ARGS) |
|
Line 969 roff_cond(ROFF_ARGS) |
|
static enum rofferr |
static enum rofferr |
roff_ds(ROFF_ARGS) |
roff_ds(ROFF_ARGS) |
{ |
{ |
char *name, *string, *end; |
char *name, *string; |
|
|
|
/* |
|
* A symbol is named by the first word following the macro |
|
* invocation up to a space. Its value is anything after the |
|
* name's trailing whitespace and optional double-quote. Thus, |
|
* |
|
* [.ds foo "bar " ] |
|
* |
|
* will have `bar " ' as its value. |
|
*/ |
|
|
name = *bufp + pos; |
name = *bufp + pos; |
if ('\0' == *name) |
if ('\0' == *name) |
return(ROFF_IGN); |
return(ROFF_IGN); |
|
|
string = name; |
string = name; |
|
/* Read until end of name. */ |
while (*string && ' ' != *string) |
while (*string && ' ' != *string) |
string++; |
string++; |
|
|
|
/* Nil-terminate name. */ |
if (*string) |
if (*string) |
*(string++) = NULL; |
*(string++) = '\0'; |
if (*string && '"' == *string) |
|
string++; |
/* Read past spaces. */ |
while (*string && ' ' == *string) |
while (*string && ' ' == *string) |
string++; |
string++; |
end = string; |
|
while (*end) |
|
end++; |
|
if (string < end) { |
|
end--; |
|
if (*end == '"') |
|
*end = '\0'; |
|
} |
|
|
|
|
/* Read passed initial double-quote. */ |
|
if (*string && '"' == *string) |
|
string++; |
|
|
|
/* The rest is the value. */ |
roff_setstr(r, name, string); |
roff_setstr(r, name, string); |
return(ROFF_IGN); |
return(ROFF_IGN); |
} |
} |
Line 1060 roff_setstr(struct roff *r, const char *name, const ch |
|
Line 1070 roff_setstr(struct roff *r, const char *name, const ch |
|
} else |
} else |
free(n->string); |
free(n->string); |
|
|
|
ROFF_DEBUG("roff: new symbol: [%s] = [%s]\n", name, string); |
n->string = string ? strdup(string) : NULL; |
n->string = string ? strdup(string) : NULL; |
} |
} |
|
|
Line 1070 roff_getstrn(const struct roff *r, const char *name, s |
|
Line 1081 roff_getstrn(const struct roff *r, const char *name, s |
|
const struct roffstr *n; |
const struct roffstr *n; |
|
|
n = r->first_string; |
n = r->first_string; |
while (n && (strncmp(name, n->name, len) || '\0' != n->name[len])) |
while (n && (strncmp(name, n->name, len) || '\0' != n->name[(int)len])) |
n = n->next; |
n = n->next; |
|
|
return(n ? n->string : NULL); |
return(n ? n->string : NULL); |