summaryrefslogtreecommitdiffstatshomepage
path: root/action.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-05 12:08:52 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-05 12:08:52 +0000
commit6f9d9cf4d38fa9a821a61f50e3ee7caa2306cdb5 (patch)
treef0a2ca1fddd15953f1ab76305a20acda471a7b89 /action.c
parentccdc28b884f5297f967078a51434c264fafd91ae (diff)
downloadmandoc-6f9d9cf4d38fa9a821a61f50e3ee7caa2306cdb5.tar.gz
mandoc-6f9d9cf4d38fa9a821a61f50e3ee7caa2306cdb5.tar.zst
mandoc-6f9d9cf4d38fa9a821a61f50e3ee7caa2306cdb5.zip
Added argv regression tests.
Table-ised argument flags in argv.c.
Diffstat (limited to 'action.c')
-rw-r--r--action.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/action.c b/action.c
index 0733c797..1b4f157d 100644
--- a/action.c
+++ b/action.c
@@ -1,4 +1,4 @@
-/* $Id: action.c,v 1.28 2009/03/01 23:14:15 kristaps Exp $ */
+/* $Id: action.c,v 1.29 2009/03/05 12:08:53 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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];