version 1.23, 2009/02/28 13:47:36 |
version 1.30, 2009/03/05 13:12:12 |
|
|
|
|
/* Per-macro action routines. */ |
/* Per-macro action routines. */ |
|
|
|
static int post_ar(struct mdoc *); |
static int post_bl(struct mdoc *); |
static int post_bl(struct mdoc *); |
static int post_bl_width(struct mdoc *); |
static int post_bl_width(struct mdoc *); |
static int post_bl_tagwidth(struct mdoc *); |
static int post_bl_tagwidth(struct mdoc *); |
static int post_sh(struct mdoc *); |
|
static int post_os(struct mdoc *); |
|
static int post_dt(struct mdoc *); |
|
static int post_dd(struct mdoc *); |
static int post_dd(struct mdoc *); |
|
static int post_dt(struct mdoc *); |
static int post_nm(struct mdoc *); |
static int post_nm(struct mdoc *); |
|
static int post_os(struct mdoc *); |
|
static int post_sh(struct mdoc *); |
|
static int post_ex(struct mdoc *); |
|
|
static int post_prologue(struct mdoc *); |
static int post_prologue(struct mdoc *); |
|
|
Line 66 const struct actions mdoc_actions[MDOC_MAX] = { |
|
Line 68 const struct actions mdoc_actions[MDOC_MAX] = { |
|
{ NULL }, /* It */ |
{ NULL }, /* It */ |
{ NULL }, /* Ad */ |
{ NULL }, /* Ad */ |
{ NULL }, /* An */ |
{ NULL }, /* An */ |
{ NULL }, /* Ar */ |
{ post_ar }, /* Ar */ |
{ NULL }, /* Cd */ |
{ NULL }, /* Cd */ |
{ NULL }, /* Cm */ |
{ NULL }, /* Cm */ |
{ NULL }, /* Dv */ |
{ NULL }, /* Dv */ |
{ NULL }, /* Er */ |
{ NULL }, /* Er */ |
{ NULL }, /* Ev */ |
{ NULL }, /* Ev */ |
{ NULL }, /* Ex */ |
{ post_ex }, /* Ex */ |
{ NULL }, /* Fa */ |
{ NULL }, /* Fa */ |
{ NULL }, /* Fd */ |
{ NULL }, /* Fd */ |
{ NULL }, /* Fl */ |
{ NULL }, /* Fl */ |
Line 160 const struct actions mdoc_actions[MDOC_MAX] = { |
|
Line 162 const struct actions mdoc_actions[MDOC_MAX] = { |
|
|
|
|
|
static int |
static int |
|
post_ex(struct mdoc *mdoc) |
|
{ |
|
|
|
/* |
|
* If `.Ex -std' is invoked without an argument, fill it in with |
|
* our name (if it's been set). |
|
*/ |
|
|
|
if (0 == mdoc->last->data.elem.argc) |
|
return(1); |
|
if (mdoc->last->data.elem.argv[0].sz) |
|
return(1); |
|
|
|
assert(mdoc->meta.name); |
|
|
|
mdoc_msg(mdoc, "writing %s argument: %s", |
|
mdoc_argnames[MDOC_Std], mdoc->meta.name); |
|
|
|
mdoc->last->data.elem.argv[0].sz = 1; |
|
mdoc->last->data.elem.argv[0].value = xcalloc(1, sizeof(char *)); |
|
mdoc->last->data.elem.argv[0].value[0] = xstrdup(mdoc->meta.name); |
|
return(1); |
|
} |
|
|
|
|
|
static int |
post_nm(struct mdoc *mdoc) |
post_nm(struct mdoc *mdoc) |
{ |
{ |
char buf[64]; |
char buf[64]; |
Line 259 post_dt(struct mdoc *mdoc) |
|
Line 287 post_dt(struct mdoc *mdoc) |
|
mdoc->meta.msec = mdoc_atomsec(p); |
mdoc->meta.msec = mdoc_atomsec(p); |
if (MSEC_DEFAULT != mdoc->meta.msec) |
if (MSEC_DEFAULT != mdoc->meta.msec) |
break; |
break; |
return(mdoc_nerr(mdoc, n, "invalid parameter syntax")); |
return(mdoc_nerr(mdoc, n, |
|
"invalid parameter syntax")); |
case (2): |
case (2): |
mdoc->meta.vol = mdoc_atovol(p); |
mdoc->meta.vol = mdoc_atovol(p); |
if (VOL_DEFAULT != mdoc->meta.vol) |
if (VOL_DEFAULT != mdoc->meta.vol) |
Line 267 post_dt(struct mdoc *mdoc) |
|
Line 296 post_dt(struct mdoc *mdoc) |
|
mdoc->meta.arch = mdoc_atoarch(p); |
mdoc->meta.arch = mdoc_atoarch(p); |
if (ARCH_DEFAULT != mdoc->meta.arch) |
if (ARCH_DEFAULT != mdoc->meta.arch) |
break; |
break; |
return(mdoc_nerr(mdoc, n, "invalid parameter syntax")); |
return(mdoc_nerr(mdoc, n, |
|
"invalid parameter syntax")); |
default: |
default: |
return(mdoc_nerr(mdoc, n, "too many parameters")); |
return(mdoc_nerr(mdoc, n, |
|
"too many parameters")); |
} |
} |
} |
} |
|
|
Line 392 post_bl_width(struct mdoc *mdoc) |
|
Line 423 post_bl_width(struct mdoc *mdoc) |
|
* 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 (MDOC_MAX == (tok = mdoc_find(mdoc, *p))) |
if (xstrcmp(*p, "Ds")) |
|
width = 8; |
|
else if (MDOC_MAX == (tok = mdoc_find(mdoc, *p))) |
return(1); |
return(1); |
|
else if (0 == (width = mdoc_macro2len(tok))) |
if (0 == (width = mdoc_macro2len(tok))) |
|
return(mdoc_warn(mdoc, WARN_SYNTAX, |
return(mdoc_warn(mdoc, WARN_SYNTAX, |
"-%s macro has no length", |
"%s macro has no length", |
mdoc_argnames[MDOC_Width])); |
mdoc_argnames[MDOC_Width])); |
|
|
mdoc_msg(mdoc, "re-writing %s argument: %s -> %zun", |
mdoc_msg(mdoc, "re-writing %s argument: %s -> %zun", |
Line 444 post_bl(struct mdoc *mdoc) |
|
Line 476 post_bl(struct mdoc *mdoc) |
|
if ( ! post_bl_width(mdoc)) |
if ( ! post_bl_width(mdoc)) |
return(0); |
return(0); |
|
|
|
return(1); |
|
} |
|
|
|
|
|
static int |
|
post_ar(struct mdoc *mdoc) |
|
{ |
|
struct mdoc_node *n; |
|
|
|
if (mdoc->last->child) |
|
return(1); |
|
|
|
n = mdoc->last; |
|
|
|
mdoc->next = MDOC_NEXT_CHILD; |
|
mdoc_word_alloc(mdoc, mdoc->last->line, |
|
mdoc->last->pos, "file"); |
|
mdoc->next = MDOC_NEXT_SIBLING; |
|
mdoc_word_alloc(mdoc, mdoc->last->line, |
|
mdoc->last->pos, "..."); |
|
|
|
mdoc->last = n; |
|
mdoc->next = MDOC_NEXT_SIBLING; |
return(1); |
return(1); |
} |
} |
|
|