version 1.130, 2014/04/20 20:48:34 |
version 1.131, 2014/04/23 16:07:06 |
|
|
static int |
static int |
post_at(POST_ARGS) |
post_at(POST_ARGS) |
{ |
{ |
const char *p, *q; |
struct mdoc_node *n; |
char *buf; |
const char *std_att; |
size_t sz; |
char *att; |
|
|
/* |
/* |
* If we have a child, look it up in the standard keys. If a |
* If we have a child, look it up in the standard keys. If a |
|
|
* prefix "AT&T UNIX " to the existing data. |
* prefix "AT&T UNIX " to the existing data. |
*/ |
*/ |
|
|
if (NULL == mdoc->last->child) |
if (NULL == (n = mdoc->last->child)) |
return(1); |
return(1); |
|
|
assert(MDOC_TEXT == mdoc->last->child->type); |
assert(MDOC_TEXT == n->type); |
p = mdoc_a2att(mdoc->last->child->string); |
if (NULL == (std_att = mdoc_a2att(n->string))) { |
|
|
if (p) { |
|
free(mdoc->last->child->string); |
|
mdoc->last->child->string = mandoc_strdup(p); |
|
} else { |
|
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADATT); |
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADATT); |
p = "AT&T UNIX "; |
mandoc_asprintf(&att, "AT&T UNIX %s", n->string); |
q = mdoc->last->child->string; |
} else |
sz = strlen(p) + strlen(q) + 1; |
att = mandoc_strdup(std_att); |
buf = mandoc_malloc(sz); |
|
strlcpy(buf, p, sz); |
|
strlcat(buf, q, sz); |
|
free(mdoc->last->child->string); |
|
mdoc->last->child->string = buf; |
|
} |
|
|
|
|
free(n->string); |
|
n->string = att; |
return(1); |
return(1); |
} |
} |
|
|