version 1.53, 2010/04/06 11:33:00 |
version 1.58, 2010/05/15 16:24:38 |
|
|
|
|
static int concat(struct mdoc *, char *, |
static int concat(struct mdoc *, char *, |
const struct mdoc_node *, size_t); |
const struct mdoc_node *, size_t); |
static inline int order_rs(int); |
static inline int order_rs(enum mdoct); |
|
|
static int post_ar(POST_ARGS); |
static int post_ar(POST_ARGS); |
static int post_at(POST_ARGS); |
static int post_at(POST_ARGS); |
Line 196 static const struct actions mdoc_actions[MDOC_MAX] = { |
|
Line 196 static const struct actions mdoc_actions[MDOC_MAX] = { |
|
|
|
#define RSORD_MAX 14 |
#define RSORD_MAX 14 |
|
|
static const int rsord[RSORD_MAX] = { |
static const enum mdoct rsord[RSORD_MAX] = { |
MDOC__A, |
MDOC__A, |
MDOC__T, |
MDOC__T, |
MDOC__B, |
MDOC__B, |
Line 366 post_st(POST_ARGS) |
|
Line 366 post_st(POST_ARGS) |
|
|
|
assert(MDOC_TEXT == n->child->type); |
assert(MDOC_TEXT == n->child->type); |
p = mdoc_a2st(n->child->string); |
p = mdoc_a2st(n->child->string); |
assert(p); |
if (p != NULL) { |
free(n->child->string); |
free(n->child->string); |
n->child->string = mandoc_strdup(p); |
n->child->string = mandoc_strdup(p); |
|
} |
return(1); |
return(1); |
} |
} |
|
|
Line 381 post_st(POST_ARGS) |
|
Line 382 post_st(POST_ARGS) |
|
static int |
static int |
post_at(POST_ARGS) |
post_at(POST_ARGS) |
{ |
{ |
struct mdoc_node *nn; |
struct mdoc_node *nn; |
const char *p; |
const char *p, *q; |
|
char *buf; |
|
size_t sz; |
|
|
if (n->child) { |
if (n->child) { |
assert(MDOC_TEXT == n->child->type); |
assert(MDOC_TEXT == n->child->type); |
p = mdoc_a2att(n->child->string); |
p = mdoc_a2att(n->child->string); |
assert(p); |
if (p) { |
free(n->child->string); |
free(n->child->string); |
n->child->string = mandoc_strdup(p); |
n->child->string = mandoc_strdup(p); |
|
} else { |
|
p = "AT&T UNIX "; |
|
q = n->child->string; |
|
sz = strlen(p) + strlen(q) + 1; |
|
buf = mandoc_malloc(sz); |
|
strlcpy(buf, p, sz); |
|
strlcat(buf, q, sz); |
|
free(n->child->string); |
|
n->child->string = buf; |
|
} |
return(1); |
return(1); |
} |
} |
|
|
Line 419 post_sh(POST_ARGS) |
|
Line 432 post_sh(POST_ARGS) |
|
|
|
if ( ! concat(m, buf, n->child, BUFSIZ)) |
if ( ! concat(m, buf, n->child, BUFSIZ)) |
return(0); |
return(0); |
sec = mdoc_atosec(buf); |
sec = mdoc_str2sec(buf); |
/* |
/* |
* The first section should always make us move into a non-new |
* The first section should always make us move into a non-new |
* state. |
* state. |
Line 433 post_sh(POST_ARGS) |
|
Line 446 post_sh(POST_ARGS) |
|
case (SEC_RETURN_VALUES): |
case (SEC_RETURN_VALUES): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (SEC_ERRORS): |
case (SEC_ERRORS): |
switch (m->meta.msec) { |
assert(m->meta.msec); |
case (2): |
if (*m->meta.msec == '2') |
/* FALLTHROUGH */ |
|
case (3): |
|
/* FALLTHROUGH */ |
|
case (9): |
|
break; |
break; |
default: |
if (*m->meta.msec == '3') |
return(mdoc_nwarn(m, n, EBADSEC)); |
break; |
} |
if (*m->meta.msec == '9') |
break; |
break; |
|
return(mdoc_nwarn(m, n, EWRONGMSEC)); |
default: |
default: |
break; |
break; |
} |
} |
Line 460 post_dt(POST_ARGS) |
|
Line 470 post_dt(POST_ARGS) |
|
{ |
{ |
struct mdoc_node *nn; |
struct mdoc_node *nn; |
const char *cp; |
const char *cp; |
char *ep; |
|
long lval; |
|
|
|
if (m->meta.title) |
if (m->meta.title) |
free(m->meta.title); |
free(m->meta.title); |
Line 471 post_dt(POST_ARGS) |
|
Line 479 post_dt(POST_ARGS) |
|
free(m->meta.arch); |
free(m->meta.arch); |
|
|
m->meta.title = m->meta.vol = m->meta.arch = NULL; |
m->meta.title = m->meta.vol = m->meta.arch = NULL; |
m->meta.msec = 0; |
|
|
|
/* Handles: `.Dt' |
/* Handles: `.Dt' |
* --> title = unknown, volume = local, msec = 0, arch = NULL |
* --> title = unknown, volume = local, msec = 0, arch = NULL |
*/ |
*/ |
|
|
if (NULL == (nn = n->child)) { |
if (NULL == (nn = n->child)) { |
/* XXX: make these macro values. */ |
/* XXX: make these macro values. */ |
|
/* FIXME: warn about missing values. */ |
m->meta.title = mandoc_strdup("unknown"); |
m->meta.title = mandoc_strdup("unknown"); |
m->meta.vol = mandoc_strdup("local"); |
m->meta.vol = mandoc_strdup("local"); |
|
m->meta.msec = mandoc_strdup("1"); |
return(post_prol(m, n)); |
return(post_prol(m, n)); |
} |
} |
|
|
Line 491 post_dt(POST_ARGS) |
|
Line 499 post_dt(POST_ARGS) |
|
m->meta.title = mandoc_strdup(nn->string); |
m->meta.title = mandoc_strdup(nn->string); |
|
|
if (NULL == (nn = nn->next)) { |
if (NULL == (nn = nn->next)) { |
|
/* FIXME: warn about missing msec. */ |
/* XXX: make this a macro value. */ |
/* XXX: make this a macro value. */ |
m->meta.vol = mandoc_strdup("local"); |
m->meta.vol = mandoc_strdup("local"); |
|
m->meta.msec = mandoc_strdup("1"); |
return(post_prol(m, n)); |
return(post_prol(m, n)); |
} |
} |
|
|
Line 505 post_dt(POST_ARGS) |
|
Line 515 post_dt(POST_ARGS) |
|
|
|
cp = mdoc_a2msec(nn->string); |
cp = mdoc_a2msec(nn->string); |
if (cp) { |
if (cp) { |
/* FIXME: where is strtonum!? */ |
|
m->meta.vol = mandoc_strdup(cp); |
m->meta.vol = mandoc_strdup(cp); |
lval = strtol(nn->string, &ep, 10); |
m->meta.msec = mandoc_strdup(nn->string); |
if (nn->string[0] != '\0' && *ep == '\0') |
} else if (mdoc_nwarn(m, n, EBADMSEC)) { |
m->meta.msec = (int)lval; |
|
} else |
|
m->meta.vol = mandoc_strdup(nn->string); |
m->meta.vol = mandoc_strdup(nn->string); |
|
m->meta.msec = mandoc_strdup(nn->string); |
|
} else |
|
return(0); |
|
|
if (NULL == (nn = nn->next)) |
if (NULL == (nn = nn->next)) |
return(post_prol(m, n)); |
return(post_prol(m, n)); |
Line 528 post_dt(POST_ARGS) |
|
Line 538 post_dt(POST_ARGS) |
|
free(m->meta.vol); |
free(m->meta.vol); |
m->meta.vol = mandoc_strdup(cp); |
m->meta.vol = mandoc_strdup(cp); |
} else { |
} else { |
|
/* FIXME: warn about bad arch. */ |
cp = mdoc_a2arch(nn->string); |
cp = mdoc_a2arch(nn->string); |
if (NULL == cp) { |
if (NULL == cp) { |
free(m->meta.vol); |
free(m->meta.vol); |
Line 945 post_display(POST_ARGS) |
|
Line 956 post_display(POST_ARGS) |
|
|
|
|
|
static inline int |
static inline int |
order_rs(int t) |
order_rs(enum mdoct t) |
{ |
{ |
int i; |
int i; |
|
|
for (i = 0; i < RSORD_MAX; i++) |
for (i = 0; i < (int)RSORD_MAX; i++) |
if (rsord[i] == t) |
if (rsord[i] == t) |
return(i); |
return(i); |
|
|