=================================================================== RCS file: /cvs/mandoc/Attic/mdoc_action.c,v retrieving revision 1.59 retrieving revision 1.65 diff -u -p -r1.59 -r1.65 --- mandoc/Attic/mdoc_action.c 2010/05/17 22:11:42 1.59 +++ mandoc/Attic/mdoc_action.c 2010/06/03 13:44:36 1.65 @@ -1,4 +1,4 @@ -/* $Id: mdoc_action.c,v 1.59 2010/05/17 22:11:42 kristaps Exp $ */ +/* $Id: mdoc_action.c,v 1.65 2010/06/03 13:44:36 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -33,7 +33,7 @@ #include "libmandoc.h" #define POST_ARGS struct mdoc *m, struct mdoc_node *n -#define PRE_ARGS struct mdoc *m, const struct mdoc_node *n +#define PRE_ARGS struct mdoc *m, struct mdoc_node *n #define NUMSIZ 32 #define DATESIZ 32 @@ -57,6 +57,7 @@ static int post_dd(POST_ARGS); static int post_display(POST_ARGS); static int post_dt(POST_ARGS); static int post_lb(POST_ARGS); +static int post_li(POST_ARGS); static int post_nm(POST_ARGS); static int post_os(POST_ARGS); static int post_pa(POST_ARGS); @@ -102,7 +103,7 @@ static const struct actions mdoc_actions[MDOC_MAX] = { { NULL, NULL }, /* Ft */ { NULL, NULL }, /* Ic */ { NULL, NULL }, /* In */ - { NULL, NULL }, /* Li */ + { NULL, post_li }, /* Li */ { NULL, NULL }, /* Nd */ { NULL, post_nm }, /* Nm */ { NULL, NULL }, /* Op */ @@ -193,6 +194,7 @@ static const struct actions mdoc_actions[MDOC_MAX] = { { NULL, NULL }, /* br */ { NULL, NULL }, /* sp */ { NULL, NULL }, /* %U */ + { NULL, NULL }, /* Ta */ }; #define RSORD_MAX 14 @@ -216,7 +218,7 @@ static const enum mdoct rsord[RSORD_MAX] = { int -mdoc_action_pre(struct mdoc *m, const struct mdoc_node *n) +mdoc_action_pre(struct mdoc *m, struct mdoc_node *n) { switch (n->type) { @@ -498,8 +500,8 @@ post_dt(POST_ARGS) if (NULL == (nn = n->child)) { /* XXX: make these macro values. */ /* FIXME: warn about missing values. */ - m->meta.title = mandoc_strdup("unknown"); - m->meta.vol = mandoc_strdup("local"); + m->meta.title = mandoc_strdup("UNKNOWN"); + m->meta.vol = mandoc_strdup("LOCAL"); m->meta.msec = mandoc_strdup("1"); return(post_prol(m, n)); } @@ -508,12 +510,13 @@ post_dt(POST_ARGS) * --> title = TITLE, volume = local, msec = 0, arch = NULL */ - m->meta.title = mandoc_strdup(nn->string); + m->meta.title = mandoc_strdup + ('\0' == nn->string[0] ? "UNKNOWN" : nn->string); if (NULL == (nn = nn->next)) { /* FIXME: warn about missing msec. */ /* XXX: make this a macro value. */ - m->meta.vol = mandoc_strdup("local"); + m->meta.vol = mandoc_strdup("LOCAL"); m->meta.msec = mandoc_strdup("1"); return(post_prol(m, n)); } @@ -637,11 +640,14 @@ post_bl_tagwidth(POST_ARGS) /* Defaults to ten ens. */ sz = 10; /* XXX: make this a macro value. */ - nn = n->body->child; + for (nn = n->body->child; nn; nn = nn->next) { + if (MDOC_It == nn->tok) + break; + } + if (nn) { assert(MDOC_BLOCK == nn->type); - assert(MDOC_It == nn->tok); nn = nn->head->child; if (MDOC_TEXT != nn->type) { sz = mdoc_macro2len(nn->tok); @@ -834,6 +840,27 @@ post_pa(POST_ARGS) /* + * Empty `Li' macros get an empty string to make front-ends add an extra + * space. + */ +static int +post_li(POST_ARGS) +{ + struct mdoc_node *np; + + if (n->child) + return(1); + + np = n; + m->next = MDOC_NEXT_CHILD; + if ( ! mdoc_word_alloc(m, n->line, n->pos, "")) + return(0); + m->last = np; + return(1); +} + + +/* * The `Ar' macro defaults to two strings "file ..." if no value is * provided as an argument. */ @@ -921,8 +948,7 @@ pre_offset(PRE_ARGS) * stipulated by mdoc.samples. */ - assert(n->args); - for (i = 0; i < (int)n->args->argc; i++) { + for (i = 0; n->args && i < (int)n->args->argc; i++) { if (MDOC_Offset != n->args->argv[i].arg) continue; if (n->args->argv[i].sz) @@ -943,7 +969,9 @@ static int pre_bl(PRE_ARGS) { - return(MDOC_BLOCK == n->type ? pre_offset(m, n) : 1); + if (MDOC_BLOCK == n->type) + return(pre_offset(m, n)); + return(1); }