summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2010-10-15 20:45:04 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2010-10-15 20:45:04 +0000
commitaee39240bb5c1864b2c71e6ea552b46d90463fcf (patch)
tree2c36f38eec63f2abf5a8e02164d2d57f2ee073e9 /usr.bin/mandoc
parent4dd735d2ad0e1362c6c908b076491a2db8f0b4d4 (diff)
Minimal glue to integrate tbl into the mandoc man(7) parser and formatter.
The output dosn't look nice yet, escape handling is still missing, but will follow soon. "move forward aggressively :-)" deraadt@
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/Makefile3
-rw-r--r--usr.bin/mandoc/man.c18
-rw-r--r--usr.bin/mandoc/man.h7
-rw-r--r--usr.bin/mandoc/man_action.c18
-rw-r--r--usr.bin/mandoc/man_html.c4
-rw-r--r--usr.bin/mandoc/man_macro.c7
-rw-r--r--usr.bin/mandoc/man_term.c23
-rw-r--r--usr.bin/mandoc/man_validate.c4
8 files changed, 75 insertions, 9 deletions
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile
index d0ddeafbe87..17c175ee2d5 100644
--- a/usr.bin/mandoc/Makefile
+++ b/usr.bin/mandoc/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.45 2010/09/27 21:25:28 schwarze Exp $
+# $OpenBSD: Makefile,v 1.46 2010/10/15 20:45:03 schwarze Exp $
.include <bsd.own.mk>
@@ -19,6 +19,7 @@ SRCS+= man_macro.c man.c man_hash.c man_validate.c \
SRCS+= main.c mdoc_term.c chars.c term.c tree.c man_term.c
SRCS+= html.c mdoc_html.c man_html.c out.c
SRCS+= term_ps.c term_ascii.c
+SRCS+= tbl.c tbl_data.c tbl_layout.c tbl_option.c tbl_term.c tbl_tree.c
PROG= mandoc
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index fa92a5fe971..58ca126725b 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.40 2010/08/20 00:53:35 schwarze Exp $ */
+/* $Id: man.c,v 1.41 2010/10/15 20:45:03 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -26,6 +26,8 @@
#include "libman.h"
#include "libmandoc.h"
+#include "tbl.h"
+
const char *const __man_macronames[MAN_MAX] = {
"br", "TH", "SH", "SS",
"TP", "LP", "PP", "P",
@@ -36,7 +38,7 @@ const char *const __man_macronames[MAN_MAX] = {
"nf", "fi", "r", "RE",
"RS", "DT", "UC", "PD",
"Sp", "Vb", "Ve", "AT",
- "in"
+ "in", "TS", "TE"
};
const char * const *man_macronames = __man_macronames;
@@ -121,10 +123,20 @@ man_endparse(struct man *m)
int
man_parseln(struct man *m, int ln, char *buf, int offs)
{
+ struct man_node *n;
if (MAN_HALT & m->flags)
return(0);
+ n = m->last;
+
+ if (n && MAN_TS == n->tok && MAN_BODY == n->type &&
+ strncmp(buf+offs, ".TE", 3)) {
+ n = n->parent;
+ return(tbl_read(n->data.TS, "<man>", ln, buf+offs,
+ strlen(buf+offs)) ? 1 : 0);
+ }
+
return(('.' == buf[offs] || '\'' == buf[offs]) ?
man_pmacro(m, ln, buf, offs) :
man_ptext(m, ln, buf, offs));
@@ -322,6 +334,8 @@ man_node_free(struct man_node *p)
if (p->string)
free(p->string);
+ if (p->data.TS)
+ tbl_free(p->data.TS);
free(p);
}
diff --git a/usr.bin/mandoc/man.h b/usr.bin/mandoc/man.h
index 732a565d0ba..a838c82f907 100644
--- a/usr.bin/mandoc/man.h
+++ b/usr.bin/mandoc/man.h
@@ -1,4 +1,4 @@
-/* $Id: man.h,v 1.26 2010/08/20 00:53:35 schwarze Exp $ */
+/* $Id: man.h,v 1.27 2010/10/15 20:45:03 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -57,6 +57,8 @@ enum mant {
MAN_Ve,
MAN_AT,
MAN_in,
+ MAN_TS,
+ MAN_TE,
MAN_MAX
};
@@ -95,6 +97,9 @@ struct man_node {
char *string;
struct man_node *head;
struct man_node *body;
+ union {
+ struct tbl *TS;
+ } data;
};
extern const char *const *man_macronames;
diff --git a/usr.bin/mandoc/man_action.c b/usr.bin/mandoc/man_action.c
index eda931be653..c823738bee3 100644
--- a/usr.bin/mandoc/man_action.c
+++ b/usr.bin/mandoc/man_action.c
@@ -1,4 +1,4 @@
-/* $Id: man_action.c,v 1.24 2010/07/25 18:05:54 schwarze Exp $ */
+/* $Id: man_action.c,v 1.25 2010/10/15 20:45:03 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -23,6 +23,8 @@
#include "libman.h"
#include "libmandoc.h"
+#include "tbl.h"
+
struct actions {
int (*post)(struct man *);
};
@@ -32,6 +34,7 @@ static int post_fi(struct man *);
static int post_nf(struct man *);
static int post_AT(struct man *);
static int post_UC(struct man *);
+static int post_TS(struct man *);
const struct actions man_actions[MAN_MAX] = {
{ NULL }, /* br */
@@ -71,6 +74,8 @@ const struct actions man_actions[MAN_MAX] = {
{ post_fi }, /* Ve */
{ post_AT }, /* AT */
{ NULL }, /* in */
+ { post_TS }, /* TS */
+ { NULL }, /* TE */
};
@@ -276,3 +281,14 @@ post_UC(struct man *m)
return(1);
}
+
+
+static int
+post_TS(struct man *m)
+{
+
+ if (MAN_HEAD == m->last->type)
+ m->last->parent->data.TS = tbl_alloc();
+
+ return(1);
+}
diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c
index b127639e546..c2852273b81 100644
--- a/usr.bin/mandoc/man_html.c
+++ b/usr.bin/mandoc/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.18 2010/07/25 18:05:54 schwarze Exp $ */
+/* $Id: man_html.c,v 1.19 2010/10/15 20:45:03 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -113,6 +113,8 @@ static const struct htmlman mans[MAN_MAX] = {
{ man_literal_pre, NULL }, /* Ve */
{ man_ign_pre, NULL }, /* AT */
{ man_in_pre, NULL }, /* in */
+ { NULL, NULL }, /* TS */
+ { NULL, NULL }, /* TE */
};
diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c
index 7e01af81161..70c0123cfed 100644
--- a/usr.bin/mandoc/man_macro.c
+++ b/usr.bin/mandoc/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.20 2010/07/25 18:05:54 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.21 2010/10/15 20:45:03 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -80,6 +80,8 @@ const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, 0 }, /* Ve */
{ in_line_eoln, 0 }, /* AT */
{ in_line_eoln, 0 }, /* in */
+ { blk_exp, MAN_EXPLICIT }, /* TS */
+ { blk_close, 0 }, /* TE */
};
const struct man_macro * const man_macros = __man_macros;
@@ -265,6 +267,9 @@ blk_close(MACRO_PROT_ARGS)
case (MAN_RE):
ntok = MAN_RS;
break;
+ case (MAN_TE):
+ ntok = MAN_TS;
+ break;
default:
abort();
/* NOTREACHED */
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index 074c3b7d257..c3e03b39d2b 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.46 2010/09/21 22:33:41 schwarze Exp $ */
+/* $Id: man_term.c,v 1.47 2010/10/15 20:45:03 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -28,6 +28,7 @@
#include "term.h"
#include "chars.h"
#include "main.h"
+#include "tbl.h"
#define INDENT 7
#define HALFINDENT 3
@@ -92,6 +93,7 @@ static int pre_ign(DECL_ARGS);
static int pre_in(DECL_ARGS);
static int pre_literal(DECL_ARGS);
static int pre_sp(DECL_ARGS);
+static int pre_TS(DECL_ARGS);
static void post_IP(DECL_ARGS);
static void post_HP(DECL_ARGS);
@@ -138,6 +140,8 @@ static const struct termact termacts[MAN_MAX] = {
{ pre_literal, NULL, 0 }, /* Ve */
{ pre_ign, NULL, 0 }, /* AT */
{ pre_in, NULL, MAN_NOTEXT }, /* in */
+ { pre_TS, NULL, 0 }, /* TS */
+ { NULL, NULL, 0 }, /* TE */
};
@@ -826,6 +830,23 @@ post_RS(DECL_ARGS)
}
+/* ARGSUSED */
+static int
+pre_TS(DECL_ARGS)
+{
+
+ if (MAN_BLOCK != n->type)
+ return(0);
+
+ if ( ! tbl_close(n->data.TS, "<man>", n->line))
+ return(0);
+
+ tbl_write(n->data.TS);
+
+ return(0);
+}
+
+
static void
print_man_node(DECL_ARGS)
{
diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c
index 873c625c549..4b838feadfe 100644
--- a/usr.bin/mandoc/man_validate.c
+++ b/usr.bin/mandoc/man_validate.c
@@ -1,4 +1,4 @@
-/* $Id: man_validate.c,v 1.29 2010/08/20 00:53:35 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.30 2010/10/15 20:45:03 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -95,6 +95,8 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ pres_bline, posts_eq0 }, /* Ve */
{ NULL, NULL }, /* AT */
{ NULL, NULL }, /* in */
+ { NULL, NULL }, /* TS */
+ { NULL, NULL }, /* TE */
};