aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--libmdoc.h3
-rw-r--r--mdoc.h3
-rw-r--r--mdoc_action.c52
-rw-r--r--mdoc_term.c23
4 files changed, 44 insertions, 37 deletions
diff --git a/libmdoc.h b/libmdoc.h
index f351e78f..901bd5ed 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.15 2009/07/12 09:13:21 kristaps Exp $ */
+/* $Id: libmdoc.h,v 1.16 2009/07/12 20:24:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -153,6 +153,7 @@ enum mdoc_sec mdoc_atosec(const char *);
time_t mdoc_atotime(const char *);
size_t mdoc_macro2len(int);
+const char *mdoc_a2att(const char *);
const char *mdoc_a2arch(const char *);
const char *mdoc_a2vol(const char *);
const char *mdoc_a2msec(const char *);
diff --git a/mdoc.h b/mdoc.h
index 89f80d49..78d09fac 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.62 2009/07/06 09:21:24 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.63 2009/07/12 20:24:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -295,7 +295,6 @@ const struct mdoc_node *mdoc_node(const struct mdoc *);
const struct mdoc_meta *mdoc_meta(const struct mdoc *);
int mdoc_endparse(struct mdoc *);
-const char *mdoc_a2att(const char *);
const char *mdoc_a2lib(const char *);
const char *mdoc_a2st(const char *);
diff --git a/mdoc_action.c b/mdoc_action.c
index 438b6752..176dd195 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_action.c,v 1.24 2009/07/07 11:47:17 kristaps Exp $ */
+/* $Id: mdoc_action.c,v 1.25 2009/07/12 20:24:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -32,14 +32,12 @@ struct actions {
int (*post)(POST_ARGS);
};
-static int concat(struct mdoc *, const struct mdoc_node *,
- char *, size_t);
-
static int post_ar(POST_ARGS);
+static int post_at(POST_ARGS);
static int post_bl(POST_ARGS);
static int post_bl_head(POST_ARGS);
-static int post_bl_width(POST_ARGS);
static int post_bl_tagwidth(POST_ARGS);
+static int post_bl_width(POST_ARGS);
static int post_dd(POST_ARGS);
static int post_display(POST_ARGS);
static int post_dt(POST_ARGS);
@@ -109,7 +107,7 @@ const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL, NULL }, /* Ac */
{ NULL, NULL }, /* Ao */
{ NULL, NULL }, /* Aq */
- { NULL, NULL }, /* At */
+ { NULL, post_at }, /* At */
{ NULL, NULL }, /* Bc */
{ NULL, NULL }, /* Bf */
{ NULL, NULL }, /* Bo */
@@ -174,9 +172,11 @@ const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL, NULL }, /* %Q */
};
+static int concat(struct mdoc *, const struct mdoc_node *,
+ char *, size_t);
#ifdef __linux__
-extern size_t strlcat(char *, const char *, size_t);
+extern size_t strlcat(char *, const char *, size_t);
#endif
@@ -290,6 +290,35 @@ post_nm(POST_ARGS)
static int
+post_at(POST_ARGS)
+{
+ struct mdoc_node *n;
+ const char *p;
+
+ if (m->last->child) {
+ assert(MDOC_TEXT == m->last->child->type);
+ p = mdoc_a2att(m->last->child->string);
+ assert(p);
+ free(m->last->child->string);
+ m->last->child->string = strdup(p);
+ if (NULL == m->last->child->string)
+ return(mdoc_nerr(m, m->last, EMALLOC));
+ return(1);
+ }
+
+ n = m->last;
+ m->next = MDOC_NEXT_CHILD;
+
+ if ( ! mdoc_word_alloc(m, n->line, n->pos, "AT&T UNIX"))
+ return(0);
+
+ m->last = n;
+ m->next = MDOC_NEXT_SIBLING;
+ return(1);
+}
+
+
+static int
post_sh(POST_ARGS)
{
enum mdoc_sec sec;
@@ -667,8 +696,7 @@ post_lk(POST_ARGS)
m->next = MDOC_NEXT_CHILD;
/* XXX: this isn't documented anywhere! */
- if ( ! mdoc_word_alloc(m, m->last->line,
- m->last->pos, "~"))
+ if ( ! mdoc_word_alloc(m, m->last->line, m->last->pos, "~"))
return(0);
m->last = n;
@@ -687,12 +715,10 @@ post_ar(POST_ARGS)
n = m->last;
m->next = MDOC_NEXT_CHILD;
- if ( ! mdoc_word_alloc(m, m->last->line,
- m->last->pos, "file"))
+ if ( ! mdoc_word_alloc(m, m->last->line, m->last->pos, "file"))
return(0);
m->next = MDOC_NEXT_SIBLING;
- if ( ! mdoc_word_alloc(m, m->last->line,
- m->last->pos, "..."))
+ if ( ! mdoc_word_alloc(m, m->last->line, m->last->pos, "..."))
return(0);
m->last = n;
diff --git a/mdoc_term.c b/mdoc_term.c
index 5709f1bf..81b786fd 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.34 2009/07/12 20:07:04 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.35 2009/07/12 20:24:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -127,7 +127,6 @@ static int termp__t_pre(DECL_ARGS);
static int termp_ap_pre(DECL_ARGS);
static int termp_aq_pre(DECL_ARGS);
static int termp_ar_pre(DECL_ARGS);
-static int termp_at_pre(DECL_ARGS);
static int termp_bd_pre(DECL_ARGS);
static int termp_bf_pre(DECL_ARGS);
static int termp_bq_pre(DECL_ARGS);
@@ -232,7 +231,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ NULL, NULL }, /* Ac */
{ termp_aq_pre, termp_aq_post }, /* Ao */
{ termp_aq_pre, termp_aq_post }, /* Aq */
- { termp_at_pre, NULL }, /* At */
+ { NULL, NULL }, /* At */
{ NULL, NULL }, /* Bc */
{ termp_bf_pre, NULL }, /* Bf */
{ termp_bq_pre, termp_bq_post }, /* Bo */
@@ -1838,24 +1837,6 @@ termp_in_post(DECL_ARGS)
/* ARGSUSED */
static int
-termp_at_pre(DECL_ARGS)
-{
- const char *att;
-
- att = NULL;
-
- if (node->child)
- att = mdoc_a2att(node->child->string);
- if (NULL == att)
- att = "AT&T UNIX";
-
- term_word(p, att);
- return(0);
-}
-
-
-/* ARGSUSED */
-static int
termp_brq_pre(DECL_ARGS)
{