version 1.33, 2009/03/08 11:41:22 |
version 1.34, 2009/03/08 12:40:27 |
Line 514 post_bl_width(struct mdoc *m) |
|
Line 514 post_bl_width(struct mdoc *m) |
|
size_t width; |
size_t width; |
int i, tok; |
int i, tok; |
char buf[32]; |
char buf[32]; |
char **p; |
char *p; |
|
|
if (NULL == m->last->args) |
if (NULL == m->last->args) |
return(merr(m, ENOWIDTH)); |
return(merr(m, ENOWIDTH)); |
Line 526 post_bl_width(struct mdoc *m) |
|
Line 526 post_bl_width(struct mdoc *m) |
|
if (i == (int)m->last->args->argc) |
if (i == (int)m->last->args->argc) |
return(merr(m, ENOWIDTH)); |
return(merr(m, ENOWIDTH)); |
|
|
p = &m->last->args->argv[i].value[0]; |
p = m->last->args->argv[i].value[0]; |
|
|
/* |
/* |
* If the value to -width is a macro, then we re-write it to be |
* If the value to -width is a macro, then we re-write it to be |
* the macro's width as set in share/tmac/mdoc/doc-common. |
* the macro's width as set in share/tmac/mdoc/doc-common. |
*/ |
*/ |
|
|
if (xstrcmp(*p, "Ds")) |
if (xstrcmp(p, "Ds")) |
width = 8; |
width = 8; |
else if (MDOC_MAX == (tok = mdoc_tokhash_find(m->htab, *p))) |
else if (MDOC_MAX == (tok = mdoc_tokhash_find(m->htab, p))) |
return(1); |
return(1); |
else if (0 == (width = mdoc_macro2len(tok))) |
else if (0 == (width = mdoc_macro2len(tok))) |
return(mwarn(m, WNOWIDTH)); |
return(mwarn(m, WNOWIDTH)); |
|
|
mdoc_msg(m, "re-writing %s argument: %s -> %zun", |
mdoc_msg(m, "re-writing %s argument: %s -> %zun", |
mdoc_argnames[MDOC_Width], *p, width); |
mdoc_argnames[MDOC_Width], p, width); |
|
|
/* The value already exists: free and reallocate it. */ |
/* The value already exists: free and reallocate it. */ |
|
|
(void)snprintf(buf, sizeof(buf), "%zun", width); |
(void)snprintf(buf, sizeof(buf), "%zun", width); |
|
|
free(*p); |
free(m->last->args->argv[i].value[0]); |
*p = xstrdup(buf); |
m->last->args->argv[i].value[0] = xstrdup(buf); |
|
|
return(1); |
return(1); |
} |
} |