aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-10-26 04:09:45 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-10-26 04:09:45 +0000
commitbf91378aa0490e0917301c7a0525831c1ffcc6b0 (patch)
treee8b11962f7e13765ec8428c9657488d47bda1469 /mdoc_term.c
parenta431e0577bc752f93c6b97e47de59c843d59bd96 (diff)
downloadmandoc-bf91378aa0490e0917301c7a0525831c1ffcc6b0.tar.gz
mandoc-bf91378aa0490e0917301c7a0525831c1ffcc6b0.tar.zst
mandoc-bf91378aa0490e0917301c7a0525831c1ffcc6b0.zip
Full `%U' support.
`Lk' display fixed. Renamed arg2xxxx as a2xxxx for consistency. Renamed print_foot to print_man_foot for consistency. Removed default printing of `~' when `Lk' not provided (not sure where I got that from).
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c79
1 files changed, 40 insertions, 39 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index bda0a669..a7b6828c 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.95 2009/10/24 05:52:14 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.96 2009/10/26 04:09:46 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -48,6 +48,28 @@ struct termact {
void (*post)(DECL_ARGS);
};
+static size_t a2width(const struct mdoc_argv *, int);
+static size_t a2height(const struct mdoc_node *);
+static size_t a2offs(const struct mdoc_argv *);
+
+static int arg_hasattr(int, const struct mdoc_node *);
+static int arg_getattrs(const int *, int *, size_t,
+ const struct mdoc_node *);
+static int arg_getattr(int, const struct mdoc_node *);
+static int arg_listtype(const struct mdoc_node *);
+static void print_bvspace(struct termp *,
+ const struct mdoc_node *,
+ const struct mdoc_node *);
+static void print_node(DECL_ARGS);
+static void print_head(DECL_ARGS);
+static void print_body(DECL_ARGS);
+static void print_foot(DECL_ARGS);
+
+#ifdef __linux__
+extern size_t strlcpy(char *, const char *, size_t);
+extern size_t strlcat(char *, const char *, size_t);
+#endif
+
static void termp____post(DECL_ARGS);
static void termp_an_post(DECL_ARGS);
static void termp_aq_post(DECL_ARGS);
@@ -236,31 +258,9 @@ static const struct termact termacts[MDOC_MAX] = {
{ NULL, termp____post }, /* %Q */
{ termp_sp_pre, NULL }, /* br */
{ termp_sp_pre, NULL }, /* sp */
- { NULL, termp____post }, /* %U */
+ { termp_under_pre, termp____post }, /* %U */
};
-#ifdef __linux__
-extern size_t strlcpy(char *, const char *, size_t);
-extern size_t strlcat(char *, const char *, size_t);
-#endif
-
-static size_t arg2width(const struct mdoc_argv *, int);
-static size_t arg2height(const struct mdoc_node *);
-static size_t arg2offs(const struct mdoc_argv *);
-
-static int arg_hasattr(int, const struct mdoc_node *);
-static int arg_getattrs(const int *, int *, size_t,
- const struct mdoc_node *);
-static int arg_getattr(int, const struct mdoc_node *);
-static int arg_listtype(const struct mdoc_node *);
-static void print_bvspace(struct termp *,
- const struct mdoc_node *,
- const struct mdoc_node *);
-static void print_node(DECL_ARGS);
-static void print_head(DECL_ARGS);
-static void print_body(DECL_ARGS);
-static void print_foot(DECL_ARGS);
-
void
terminal_mdoc(void *arg, const struct mdoc *mdoc)
@@ -469,7 +469,7 @@ print_head(DECL_ARGS)
static size_t
-arg2height(const struct mdoc_node *n)
+a2height(const struct mdoc_node *n)
{
struct roffsu su;
@@ -483,7 +483,7 @@ arg2height(const struct mdoc_node *n)
static size_t
-arg2width(const struct mdoc_argv *arg, int pos)
+a2width(const struct mdoc_argv *arg, int pos)
{
struct roffsu su;
@@ -538,7 +538,7 @@ arg_listtype(const struct mdoc_node *n)
static size_t
-arg2offs(const struct mdoc_argv *arg)
+a2offs(const struct mdoc_argv *arg)
{
struct roffsu su;
@@ -717,23 +717,23 @@ termp_it_pre(DECL_ARGS)
for (i = 0, nn = n->prev; nn &&
i < (int)bl->args->argv[vals[2]].sz;
nn = nn->prev, i++)
- offset += arg2width
+ offset += a2width
(&bl->args->argv[vals[2]], i);
/* Whether exceeds maximum column. */
if (i < (int)bl->args->argv[vals[2]].sz)
- width = arg2width(&bl->args->argv[vals[2]], i);
+ width = a2width(&bl->args->argv[vals[2]], i);
else
width = 0;
if (vals[1] >= 0)
- offset += arg2offs(&bl->args->argv[vals[1]]);
+ offset += a2offs(&bl->args->argv[vals[1]]);
break;
default:
if (vals[0] >= 0)
- width = arg2width(&bl->args->argv[vals[0]], 0);
+ width = a2width(&bl->args->argv[vals[0]], 0);
if (vals[1] >= 0)
- offset += arg2offs(&bl->args->argv[vals[1]]);
+ offset += a2offs(&bl->args->argv[vals[1]]);
break;
}
@@ -1556,7 +1556,7 @@ termp_bd_pre(DECL_ARGS)
type = nn->args->argv[i].arg;
break;
case (MDOC_Offset):
- p->offset += arg2offs(&nn->args->argv[i]);
+ p->offset += a2offs(&nn->args->argv[i]);
break;
default:
break;
@@ -1811,7 +1811,7 @@ termp_sp_pre(DECL_ARGS)
switch (n->tok) {
case (MDOC_sp):
- len = n->child ? arg2height(n->child) : 1;
+ len = n->child ? a2height(n->child) : 1;
break;
case (MDOC_br):
len = 0;
@@ -2028,16 +2028,17 @@ termp_lk_pre(DECL_ARGS)
{
const struct mdoc_node *nn;
- if (NULL == (nn = n->child->next)) {
- p->under++;
+ p->under++;
+ nn = n->child;
+
+ if (NULL == nn->next)
return(1);
- }
- p->under++;
term_word(p, nn->string);
+ p->under--;
+
p->flags |= TERMP_NOSPACE;
term_word(p, ":");
- p->under--;
p->bold++;
for (nn = nn->next; nn; nn = nn->next)