version 1.210, 2014/04/20 16:46:05 |
version 1.212, 2014/04/20 20:48:53 |
|
|
#define PRE_ARGS struct mdoc *mdoc, struct mdoc_node *n |
#define PRE_ARGS struct mdoc *mdoc, struct mdoc_node *n |
#define POST_ARGS struct mdoc *mdoc |
#define POST_ARGS struct mdoc *mdoc |
|
|
#define NUMSIZ 32 |
|
|
|
enum check_ineq { |
enum check_ineq { |
CHECK_LT, |
CHECK_LT, |
CHECK_GT, |
CHECK_GT, |
Line 1046 post_bf(POST_ARGS) |
|
Line 1044 post_bf(POST_ARGS) |
|
static int |
static int |
post_lb(POST_ARGS) |
post_lb(POST_ARGS) |
{ |
{ |
const char *p; |
struct mdoc_node *n; |
char *buf; |
const char *stdlibname; |
size_t sz; |
char *libname; |
|
|
check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_EQ, 1); |
check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_EQ, 1); |
|
|
assert(mdoc->last->child); |
n = mdoc->last->child; |
assert(MDOC_TEXT == mdoc->last->child->type); |
|
|
|
p = mdoc_a2lib(mdoc->last->child->string); |
assert(n); |
|
assert(MDOC_TEXT == n->type); |
|
|
/* If lookup ok, replace with table value. */ |
if (NULL == (stdlibname = mdoc_a2lib(n->string))) |
|
mandoc_asprintf(&libname, |
|
"library \\(lq%s\\(rq", n->string); |
|
else |
|
libname = mandoc_strdup(stdlibname); |
|
|
if (p) { |
free(n->string); |
free(mdoc->last->child->string); |
n->string = libname; |
mdoc->last->child->string = mandoc_strdup(p); |
|
return(1); |
|
} |
|
|
|
/* If not, use "library ``xxxx''. */ |
|
|
|
sz = strlen(mdoc->last->child->string) + 2 + |
|
strlen("\\(lqlibrary\\(rq"); |
|
buf = mandoc_malloc(sz); |
|
snprintf(buf, sz, "library \\(lq%s\\(rq", |
|
mdoc->last->child->string); |
|
free(mdoc->last->child->string); |
|
mdoc->last->child->string = buf; |
|
return(1); |
return(1); |
} |
} |
|
|
Line 1388 post_bl_block_width(POST_ARGS) |
|
Line 1377 post_bl_block_width(POST_ARGS) |
|
int i; |
int i; |
enum mdoct tok; |
enum mdoct tok; |
struct mdoc_node *n; |
struct mdoc_node *n; |
char buf[NUMSIZ]; |
char buf[24]; |
|
|
n = mdoc->last; |
n = mdoc->last; |
|
|
Line 1420 post_bl_block_width(POST_ARGS) |
|
Line 1409 post_bl_block_width(POST_ARGS) |
|
|
|
assert(i < (int)n->args->argc); |
assert(i < (int)n->args->argc); |
|
|
snprintf(buf, NUMSIZ, "%un", (unsigned int)width); |
(void)snprintf(buf, sizeof(buf), "%un", (unsigned int)width); |
free(n->args->argv[i].value[0]); |
free(n->args->argv[i].value[0]); |
n->args->argv[i].value[0] = mandoc_strdup(buf); |
n->args->argv[i].value[0] = mandoc_strdup(buf); |
|
|
Line 1435 post_bl_block_tag(POST_ARGS) |
|
Line 1424 post_bl_block_tag(POST_ARGS) |
|
struct mdoc_node *n, *nn; |
struct mdoc_node *n, *nn; |
size_t sz, ssz; |
size_t sz, ssz; |
int i; |
int i; |
char buf[NUMSIZ]; |
char buf[24]; |
|
|
/* |
/* |
* Calculate the -width for a `Bl -tag' list if it hasn't been |
* Calculate the -width for a `Bl -tag' list if it hasn't been |
Line 1470 post_bl_block_tag(POST_ARGS) |
|
Line 1459 post_bl_block_tag(POST_ARGS) |
|
|
|
/* Defaults to ten ens. */ |
/* Defaults to ten ens. */ |
|
|
snprintf(buf, NUMSIZ, "%un", (unsigned int)sz); |
(void)snprintf(buf, sizeof(buf), "%un", (unsigned int)sz); |
|
|
/* |
/* |
* We have to dynamically add this to the macro's argument list. |
* We have to dynamically add this to the macro's argument list. |