-.\" $Id: man.3,v 1.27 2010/12/17 11:41:45 kristaps Exp $
+.\" $Id: man.3,v 1.28 2011/01/01 12:59:17 kristaps Exp $
.\"
.\" Copyright (c) 2009-2010 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: December 17 2010 $
+.Dd $Mdocdate: January 1 2011 $
.Dt MAN 3
.Os
.Sh NAME
.In mandoc.h
.In man.h
.Vt extern const char * const * man_macronames;
+.Ft int
+.Fo man_addspan
+.Fa "struct man *man"
+.Fa "const struct tbl_span *span"
+.Fc
.Ft "struct man *"
.Fo man_alloc
.Fa "struct regset *regs"
.El
.Ss Functions
.Bl -ohang
+.It Fn man_addspan
+Add a table span to the parsing stream.
+Returns 0 on failure, 1 on success.
.It Fn man_alloc
Allocates a parsing structure.
The
-/* $Id: man.c,v 1.93 2011/01/01 10:51:30 kristaps Exp $ */
+/* $Id: man.c,v 1.94 2011/01/01 12:59:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
enum man_type, enum mant);
static int man_node_append(struct man *,
struct man_node *);
+static int man_span_alloc(struct man *,
+ const struct tbl_span *);
static void man_node_free(struct man_node *);
static void man_node_unlink(struct man *,
struct man_node *);
static int man_pmacro(struct man *, int, char *, int);
static void man_free1(struct man *);
static void man_alloc1(struct man *);
+static int man_descope(struct man *, int, int);
const struct man_node *
man->last = p;
switch (p->type) {
+ case (MAN_TBL):
+ /* FALLTHROUGH */
case (MAN_TEXT):
if ( ! man_valid_post(man))
return(0);
return(1);
}
+static int
+man_span_alloc(struct man *m, const struct tbl_span *span)
+{
+ struct man_node *n;
+
+ /* FIXME: grab from span */
+ n = man_node_alloc(0, 0, MAN_TBL, MAN_MAX);
+
+ if ( ! man_node_append(m, n))
+ return(0);
+
+ m->next = MAN_NEXT_SIBLING;
+ return(1);
+}
int
man_word_alloc(struct man *m, int line, int pos, const char *word)
}
+int
+man_addspan(struct man *m, const struct tbl_span *sp)
+{
+
+ if ( ! man_span_alloc(m, sp))
+ return(0);
+ return(man_descope(m, 0, 0));
+}
+
+static int
+man_descope(struct man *m, int line, int offs)
+{
+ /*
+ * Co-ordinate what happens with having a next-line scope open:
+ * first close out the element scope (if applicable), then close
+ * out the block scope (also if applicable).
+ */
+
+ if (MAN_ELINE & m->flags) {
+ m->flags &= ~MAN_ELINE;
+ if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX))
+ return(0);
+ }
+
+ if ( ! (MAN_BLINE & m->flags))
+ return(1);
+ m->flags &= ~MAN_BLINE;
+
+ if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX))
+ return(0);
+ return(man_body_alloc(m, line, offs, m->last->tok));
+}
+
+
static int
man_ptext(struct man *m, int line, char *buf, int offs)
{
if (MAN_LITERAL & m->flags) {
if ( ! man_word_alloc(m, line, offs, buf + offs))
return(0);
- goto descope;
+ return(man_descope(m, line, offs));
}
/* Pump blank lines directly into the backend. */
/* Allocate a blank entry. */
if ( ! man_word_alloc(m, line, offs, ""))
return(0);
- goto descope;
+ return(man_descope(m, line, offs));
}
/*
if (mandoc_eos(buf, (size_t)i, 0))
m->last->flags |= MAN_EOS;
-descope:
- /*
- * Co-ordinate what happens with having a next-line scope open:
- * first close out the element scope (if applicable), then close
- * out the block scope (also if applicable).
- */
-
- if (MAN_ELINE & m->flags) {
- m->flags &= ~MAN_ELINE;
- if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX))
- return(0);
- }
-
- if ( ! (MAN_BLINE & m->flags))
- return(1);
- m->flags &= ~MAN_BLINE;
-
- if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX))
- return(0);
- return(man_body_alloc(m, line, offs, m->last->tok));
+ return(man_descope(m, line, offs));
}
-/* $Id: man.h,v 1.49 2010/12/26 14:44:13 kristaps Exp $ */
+/* $Id: man.h,v 1.50 2011/01/01 12:59:17 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
MAN_ROOT,
MAN_BLOCK,
MAN_HEAD,
- MAN_BODY
+ MAN_BODY,
+ MAN_TBL
};
/*
char *string; /* TEXT node argument */
struct man_node *head; /* BLOCK node HEAD ptr */
struct man_node *body; /* BLOCK node BODY ptr */
+ const struct tbl_span *span; /* TBL */
};
/*
void man_reset(struct man *);
int man_parseln(struct man *, int, char *, int);
int man_endparse(struct man *);
+int man_addspan(struct man *,
+ const struct tbl_span *);
const struct man_node *man_node(const struct man *);
const struct man_meta *man_meta(const struct man *);
-/* $Id: man_html.c,v 1.57 2010/12/24 00:46:49 kristaps Exp $ */
+/* $Id: man_html.c,v 1.58 2011/01/01 12:59:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
break;
case (MAN_TEXT):
print_text(h, n->string);
-
if (MANH_LITERAL & mh->fl)
print_otag(h, TAG_BR, 0, NULL);
-
+ return;
+ case (MAN_TBL):
return;
default:
/*
bufinit(h);
- switch (n->type) {
- case (MAN_ROOT):
+ if (MAN_ROOT == n->type)
man_root_post(m, n, mh, h);
- break;
- case (MAN_TEXT):
- break;
- default:
- if (mans[n->tok].post)
- (*mans[n->tok].post)(m, n, mh, h);
- break;
- }
+ else if (mans[n->tok].post)
+ (*mans[n->tok].post)(m, n, mh, h);
}
-/* $Id: man_term.c,v 1.90 2010/12/08 10:58:22 kristaps Exp $ */
+/* $Id: man_term.c,v 1.91 2011/01/01 12:59:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
p->maxrmargin = rmax;
}
break;
+ case (MAN_TBL):
+ break;
default:
if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
term_fontrepl(p, TERMFONT_NONE);
if (c && n->child)
print_man_nodelist(p, mt, n->child, m);
- if (MAN_TEXT != n->type) {
+ switch (n->type) {
+ case (MAN_TEXT):
+ /* FALLTHROUGH */
+ case (MAN_TBL):
+ break;
+ default:
if (termacts[n->tok].post)
(*termacts[n->tok].post)(p, mt, n, m);
if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
term_fontrepl(p, TERMFONT_NONE);
+ break;
}
if (MAN_EOS & n->flags)
-/* $Id: man_validate.c,v 1.56 2010/12/08 10:58:22 kristaps Exp $ */
+/* $Id: man_validate.c,v 1.57 2011/01/01 12:59:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
{
v_check *cp;
- if (MAN_TEXT == n->type)
- return(1);
- if (MAN_ROOT == n->type)
+ switch (n->type) {
+ case (MAN_TEXT):
+ /* FALLTHROUGH */
+ case (MAN_ROOT):
+ /* FALLTHROUGH */
+ case (MAN_TBL):
return(1);
+ default:
+ break;
+ }
if (NULL == (cp = man_valids[n->tok].pres))
return(1);
return(check_text(m, m->last));
case (MAN_ROOT):
return(check_root(m, m->last));
+ case (MAN_TBL):
+ return(1);
default:
break;
}
-/* $Id: mdoc.c,v 1.175 2011/01/01 12:18:37 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.176 2011/01/01 12:59:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
mdoc->last = p;
switch (p->type) {
+ case (MDOC_TBL):
+ /* FALLTHROUGH */
case (MDOC_TEXT):
if ( ! mdoc_valid_post(mdoc))
return(0);