-/* $Id: mdoc_action.c,v 1.15 2009/06/17 14:10:09 kristaps Exp $ */
+/* $Id: mdoc_action.c,v 1.20 2009/06/25 08:42:06 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
enum merr {
ETOOLONG,
EMALLOC,
+ EUTSNAME,
ENUMFMT
};
{ NULL, NULL }, /* Ad */
{ NULL, NULL }, /* An */
{ NULL, post_ar }, /* Ar */
- { NULL, NULL }, /* Cd */
+ { NULL, NULL }, /* Cd */ /* FIXME: tabs are accepted! */
{ NULL, NULL }, /* Cm */
{ NULL, NULL }, /* Dv */
{ NULL, NULL }, /* Er */
case (ETOOLONG):
p = "argument text too long";
break;
+ case (EUTSNAME):
+ p = "utsname";
+ break;
case (EMALLOC):
p = "memory exhausted";
break;
if (0 == buf[0]) {
if (-1 == uname(&utsname))
- return(mdoc_err(m, "utsname"));
+ return(verr(m, EUTSNAME));
if (strlcat(buf, utsname.sysname, 64) >= 64)
return(verr(m, ETOOLONG));
if (strlcat(buf, " ", 64) >= 64)
*/
if (0 == strcmp(p, "Ds"))
- width = 8;
+ width = 6;
else if (MDOC_MAX == (tok = mdoc_hash_find(m->htab, p)))
return(1);
else if (0 == (width = mdoc_macro2len(tok)))
* column field. Then, delete the head children.
*/
- for (i = 0, nn = m->last->child; nn; nn = nn->next, i++)
- /* Count children. */;
-
- n->args->argv[c].sz = (size_t)i;
- n->args->argv[c].value = malloc((size_t)i * sizeof(char *));
+ n->args->argv[c].sz = (size_t)m->last->nchild;
+ n->args->argv[c].value = malloc
+ ((size_t)m->last->nchild * sizeof(char *));
for (i = 0, nn = m->last->child; nn; i++) {
n->args->argv[c].value[i] = nn->string;
mdoc_node_free(nnp);
}
+ m->last->nchild = 0;
m->last->child = NULL;
+
return(1);
}
pre_dl(PRE_ARGS)
{
- if (MDOC_BODY != n->type)
- return(1);
- m->flags |= MDOC_LITERAL;
+ if (MDOC_BODY == n->type)
+ m->flags |= MDOC_LITERAL;
return(1);
}