summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/man.c
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/man.c
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/man.c')
-rw-r--r--usr.bin/mandoc/man.c18
1 files changed, 16 insertions, 2 deletions
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);
}