=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mdoc_validate.c,v retrieving revision 1.130 retrieving revision 1.131 diff -u -r1.130 -r1.131 --- src/usr.bin/mandoc/mdoc_validate.c 2014/04/20 20:48:34 1.130 +++ src/usr.bin/mandoc/mdoc_validate.c 2014/04/23 16:07:06 1.131 @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.130 2014/04/20 20:48:34 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.131 2014/04/23 16:07:06 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -1179,9 +1179,9 @@ static int post_at(POST_ARGS) { - const char *p, *q; - char *buf; - size_t sz; + struct mdoc_node *n; + const char *std_att; + char *att; /* * If we have a child, look it up in the standard keys. If a @@ -1189,27 +1189,18 @@ * prefix "AT&T UNIX " to the existing data. */ - if (NULL == mdoc->last->child) + if (NULL == (n = mdoc->last->child)) return(1); - assert(MDOC_TEXT == mdoc->last->child->type); - p = mdoc_a2att(mdoc->last->child->string); - - if (p) { - free(mdoc->last->child->string); - mdoc->last->child->string = mandoc_strdup(p); - } else { + assert(MDOC_TEXT == n->type); + if (NULL == (std_att = mdoc_a2att(n->string))) { mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADATT); - p = "AT&T UNIX "; - q = mdoc->last->child->string; - sz = strlen(p) + strlen(q) + 1; - buf = mandoc_malloc(sz); - strlcpy(buf, p, sz); - strlcat(buf, q, sz); - free(mdoc->last->child->string); - mdoc->last->child->string = buf; - } + mandoc_asprintf(&att, "AT&T UNIX %s", n->string); + } else + att = mandoc_strdup(std_att); + free(n->string); + n->string = att; return(1); }