From 69615b3529bd47f73a5c431c091fb8baf554096c Mon Sep 17 00:00:00 2001 From: schwarze Date: Fri, 15 Oct 2010 20:45:03 +0000 Subject: 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@ --- usr.bin/mandoc/man.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'usr.bin/mandoc/man.c') 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 * @@ -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, "", 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); } -- cgit v1.2.3-59-g8ed1b