* mdocml: Add table processing structures to -mdoc.
@ 2011-01-01 12:18 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-01-01 12:18 UTC (permalink / raw)
To: source
Log Message:
-----------
Add table processing structures to -mdoc. This consists of an
external-facing function mdoc_addspan(), then various bits to prohibit
printing and scanning (this requires some if's to be converted into
switch's).
Modified Files:
--------------
mdocml:
mdoc.3
mdoc.c
mdoc.h
mdoc_html.c
mdoc_term.c
mdoc_validate.c
Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.149
retrieving revision 1.150
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.149 -r1.150
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -329,12 +329,19 @@ mdoc_valid_pre(struct mdoc *mdoc, struct
int line, pos;
char *tp;
- if (MDOC_TEXT == n->type) {
+ switch (n->type) {
+ case (MDOC_TEXT):
tp = n->string;
line = n->line;
pos = n->pos;
check_text(mdoc, line, pos, tp);
+ /* FALLTHROUGH */
+ case (MDOC_TBL):
+ /* FALLTHROUGH */
+ case (MDOC_ROOT):
return(1);
+ default:
+ break;
}
check_args(mdoc, n);
@@ -357,10 +364,16 @@ mdoc_valid_post(struct mdoc *mdoc)
return(1);
mdoc->last->flags |= MDOC_VALID;
- if (MDOC_TEXT == mdoc->last->type)
+ switch (mdoc->last->type) {
+ case (MDOC_TEXT):
+ /* FALLTHROUGH */
+ case (MDOC_TBL):
return(1);
- if (MDOC_ROOT == mdoc->last->type)
+ case (MDOC_ROOT):
return(post_root(mdoc));
+ default:
+ break;
+ }
if (NULL == mdoc_valids[mdoc->last->tok].post)
return(1);
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.139
retrieving revision 1.140
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.139 -r1.140
--- mdoc_html.c
+++ mdoc_html.c
@@ -422,6 +422,8 @@ print_mdoc_node(MDOC_ARGS)
case (MDOC_TEXT):
print_text(h, n->string);
return;
+ case (MDOC_TBL):
+ return;
default:
if (mdocs[n->tok].pre && ENDBODY_NOT == n->end)
child = (*mdocs[n->tok].pre)(m, n, h);
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.205
retrieving revision 1.206
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.205 -r1.206
--- mdoc_term.c
+++ mdoc_term.c
@@ -312,11 +312,19 @@ print_mdoc_node(DECL_ARGS)
memset(&npair, 0, sizeof(struct termpair));
npair.ppair = pair;
-
- if (MDOC_TEXT == n->type)
- term_word(p, n->string);
- else if (termacts[n->tok].pre && ENDBODY_NOT == n->end)
- chld = (*termacts[n->tok].pre)(p, &npair, m, n);
+
+ switch (n->type) {
+ case (MDOC_TEXT):
+ term_word(p, n->string);
+ break;
+ case (MDOC_TBL):
+ break;
+ default:
+ if (termacts[n->tok].pre && ENDBODY_NOT == n->end)
+ chld = (*termacts[n->tok].pre)
+ (p, &npair, m, n);
+ break;
+ }
/*
* Keeps only work until the end of a line. If a keep was
@@ -353,8 +361,14 @@ print_mdoc_node(DECL_ARGS)
term_fontpopq(p, font);
- if (MDOC_TEXT != n->type && termacts[n->tok].post &&
- ! (MDOC_ENDED & n->flags)) {
+ switch (n->type) {
+ case (MDOC_TEXT):
+ break;
+ case (MDOC_TBL):
+ break;
+ default:
+ if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags)
+ break;
(void)(*termacts[n->tok].post)(p, &npair, m, n);
/*
@@ -372,6 +386,7 @@ print_mdoc_node(DECL_ARGS)
*/
if (ENDBODY_NOSPACE == n->end)
p->flags |= TERMP_NOSPACE;
+ break;
}
if (MDOC_EOS & n->flags)
Index: mdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.h,v
retrieving revision 1.113
retrieving revision 1.114
diff -Lmdoc.h -Lmdoc.h -u -p -r1.113 -r1.114
--- mdoc.h
+++ mdoc.h
@@ -190,6 +190,7 @@ enum mdoc_type {
MDOC_TAIL,
MDOC_BODY,
MDOC_BLOCK,
+ MDOC_TBL,
MDOC_ROOT
};
@@ -399,6 +400,7 @@ struct mdoc_node {
struct mdoc_node *body; /* BLOCK */
struct mdoc_node *tail; /* BLOCK */
char *string; /* TEXT */
+ const struct tbl_span *span; /* TBL */
enum mdoc_endbody end; /* BODY */
};
@@ -426,6 +428,8 @@ int mdoc_parseln(struct mdoc *, int,
const struct mdoc_node *mdoc_node(const struct mdoc *);
const struct mdoc_meta *mdoc_meta(const struct mdoc *);
int mdoc_endparse(struct mdoc *);
+int mdoc_addspan(struct mdoc *,
+ const struct tbl_span *);
__END_DECLS
Index: mdoc.3
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.3,v
retrieving revision 1.51
retrieving revision 1.52
diff -Lmdoc.3 -Lmdoc.3 -u -p -r1.51 -r1.52
--- mdoc.3
+++ mdoc.3
@@ -33,6 +33,11 @@
.In mdoc.h
.Vt extern const char * const * mdoc_macronames;
.Vt extern const char * const * mdoc_argnames;
+.Ft int
+.Fo mdoc_addspan
+.Fa "struct mdoc *mdoc"
+.Fa "const struct tbl_span *span"
+.Fc
.Ft "struct mdoc *"
.Fo mdoc_alloc
.Fa "struct regset *regs"
@@ -92,6 +97,9 @@ for details.
.El
.Ss Functions
.Bl -ohang
+.It Fn mdoc_addspan
+Add a table span to the parsing stream.
+Returns 0 on failure, 1 on success.
.It Fn mdoc_alloc
Allocates a parsing structure.
The
Index: mdoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -Lmdoc.c -Lmdoc.c -u -p -r1.174 -r1.175
--- mdoc.c
+++ mdoc.c
@@ -98,6 +98,8 @@ static int node_append(struct mdoc *,
struct mdoc_node *);
static int mdoc_ptext(struct mdoc *, int, char *, int);
static int mdoc_pmacro(struct mdoc *, int, char *, int);
+static int mdoc_span_alloc(struct mdoc *,
+ const struct tbl_span *);
const struct mdoc_node *
@@ -221,6 +223,24 @@ mdoc_endparse(struct mdoc *m)
return(0);
}
+int
+mdoc_addspan(struct mdoc *m, const struct tbl_span *sp)
+{
+
+ if (MDOC_HALT & m->flags)
+ return(0);
+
+ /* No text before an initial macro. */
+
+ if (SEC_NONE == m->lastnamed) {
+ /* FIXME: grab from span. */
+ mdoc_pmsg(m, 0, 0, MANDOCERR_NOTEXT);
+ return(1);
+ }
+
+ return(mdoc_span_alloc(m, sp));
+}
+
/*
* Main parse routine. Parses a single line -- really just hands off to
@@ -522,6 +542,22 @@ mdoc_elem_alloc(struct mdoc *m, int line
if ( ! node_append(m, p))
return(0);
m->next = MDOC_NEXT_CHILD;
+ return(1);
+}
+
+static int
+mdoc_span_alloc(struct mdoc *m, const struct tbl_span *sp)
+{
+ struct mdoc_node *n;
+
+ /* FIXME: grab from tbl_span. */
+ n = node_alloc(m, 0, 0, MDOC_MAX, MDOC_TBL);
+ n->span = sp;
+
+ if ( ! node_append(m, n))
+ return(0);
+
+ m->next = MDOC_NEXT_SIBLING;
return(1);
}
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-01-01 12:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-01 12:18 mdocml: Add table processing structures to -mdoc kristaps
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).