=================================================================== RCS file: /cvs/mandoc/Attic/action.c,v retrieving revision 1.24 retrieving revision 1.29 diff -u -p -r1.24 -r1.29 --- mandoc/Attic/action.c 2009/02/28 14:40:07 1.24 +++ mandoc/Attic/action.c 2009/03/05 12:08:53 1.29 @@ -1,4 +1,4 @@ -/* $Id: action.c,v 1.24 2009/02/28 14:40:07 kristaps Exp $ */ +/* $Id: action.c,v 1.29 2009/03/05 12:08:53 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -39,11 +39,12 @@ struct actions { static int post_bl(struct mdoc *); static int post_bl_width(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_dt(struct mdoc *); +static int post_ex(struct mdoc *); static int post_nm(struct mdoc *); +static int post_os(struct mdoc *); +static int post_sh(struct mdoc *); static int post_prologue(struct mdoc *); @@ -72,7 +73,7 @@ const struct actions mdoc_actions[MDOC_MAX] = { { NULL }, /* Dv */ { NULL }, /* Er */ { NULL }, /* Ev */ - { NULL }, /* Ex */ + { post_ex }, /* Ex */ { NULL }, /* Fa */ { NULL }, /* Fd */ { NULL }, /* Fl */ @@ -160,6 +161,36 @@ const struct actions mdoc_actions[MDOC_MAX] = { 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); + + assert(1 == mdoc->last->data.elem.argc); + if (1 == mdoc->last->data.elem.argv[0].sz) + return(1); + assert(0 == mdoc->last->data.elem.argv[0].sz); + + if (NULL == mdoc->meta.name) + return(mdoc_err(mdoc, "default name not yet set")); + + 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) { char buf[64]; @@ -259,7 +290,8 @@ post_dt(struct mdoc *mdoc) mdoc->meta.msec = mdoc_atomsec(p); if (MSEC_DEFAULT != mdoc->meta.msec) break; - return(mdoc_nerr(mdoc, n, "invalid parameter syntax")); + return(mdoc_nerr(mdoc, n, + "invalid parameter syntax")); case (2): mdoc->meta.vol = mdoc_atovol(p); if (VOL_DEFAULT != mdoc->meta.vol) @@ -267,9 +299,11 @@ post_dt(struct mdoc *mdoc) mdoc->meta.arch = mdoc_atoarch(p); if (ARCH_DEFAULT != mdoc->meta.arch) break; - return(mdoc_nerr(mdoc, n, "invalid parameter syntax")); + return(mdoc_nerr(mdoc, n, + "invalid parameter syntax")); default: - return(mdoc_nerr(mdoc, n, "too many parameters")); + return(mdoc_nerr(mdoc, n, + "too many parameters")); } } @@ -393,12 +427,12 @@ post_bl_width(struct mdoc *mdoc) */ if (xstrcmp(*p, "Ds")) - width = 6; + width = 8; else if (MDOC_MAX == (tok = mdoc_find(mdoc, *p))) return(1); else if (0 == (width = mdoc_macro2len(tok))) return(mdoc_warn(mdoc, WARN_SYNTAX, - "-%s macro has no length", + "%s macro has no length", mdoc_argnames[MDOC_Width])); mdoc_msg(mdoc, "re-writing %s argument: %s -> %zun",