* mdocml: Add documentation bits for libroff's new roff_span().
@ 2011-01-01 15:45 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-01-01 15:45 UTC (permalink / raw)
To: source
Log Message:
-----------
Add documentation bits for libroff's new roff_span().
Add bits to remember tbl's invocation point.
Add ERROR class message if no data's in the table.
Modified Files:
--------------
mdocml:
libroff.h
main.c
mandoc.h
roff.3
roff.c
tbl.c
Revision Data
-------------
Index: roff.3
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.3,v
retrieving revision 1.8
retrieving revision 1.9
diff -Lroff.3 -Lroff.3 -u -p -r1.8 -r1.9
--- roff.3
+++ roff.3
@@ -23,7 +23,8 @@
.Nm roff_endparse ,
.Nm roff_free ,
.Nm roff_parseln ,
-.Nm roff_reset
+.Nm roff_reset ,
+.Nm roff_span
.Nd roff macro compiler library
.Sh SYNOPSIS
.In mandoc.h
@@ -49,6 +50,8 @@
.Fc
.Ft void
.Fn roff_reset "struct roff *roff"
+.Ft "const struct tbl_span *"
+.Fn roff_span "const struct roff *roff"
.Sh DESCRIPTION
The
.Nm
@@ -139,6 +142,13 @@ Returns 0 on failure, 1 on success.
.It Fn roff_endparse
Signals that the parse is complete.
Returns 0 on failure, 1 on success.
+.It Fn roff_span
+If
+.Fn roff_parseln
+returned
+.Va ROFF_TBL ,
+return the last parsed table row.
+Returns NULL otherwise.
.El
.Sh EXAMPLES
See
Index: tbl.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/tbl.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -Ltbl.c -Ltbl.c -u -p -r1.12 -r1.13
--- tbl.c
+++ tbl.c
@@ -64,11 +64,13 @@ tbl_read(struct tbl *tbl, int ln, const
}
struct tbl *
-tbl_alloc(void *data, const mandocmsg msg)
+tbl_alloc(int pos, int line, void *data, const mandocmsg msg)
{
struct tbl *p;
p = mandoc_calloc(1, sizeof(struct tbl));
+ p->line = line;
+ p->pos = pos;
p->data = data;
p->msg = msg;
p->part = TBL_PART_OPTS;
@@ -126,4 +128,12 @@ tbl_span(const struct tbl *tbl)
assert(tbl);
return(tbl->last_span);
+}
+
+void
+tbl_end(struct tbl *tbl)
+{
+
+ if (NULL == tbl->first_span || NULL == tbl->first_span->first)
+ TBL_MSG(tbl, MANDOCERR_TBLNODATA, tbl->line, tbl->pos);
}
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -Lmandoc.h -Lmandoc.h -u -p -r1.38 -r1.39
--- mandoc.h
+++ mandoc.h
@@ -105,6 +105,7 @@ enum mandocerr {
MANDOCERR_TBLOPT, /* bad table option */
MANDOCERR_TBLLAYOUT, /* bad table layout */
MANDOCERR_TBLNOLAYOUT, /* no table layout cells specified */
+ MANDOCERR_TBLNODATA, /* no table data cells specified */
MANDOCERR_ROFFLOOP, /* input stack limit exceeded, infinite loop? */
MANDOCERR_BADCHAR, /* skipping bad character */
MANDOCERR_NOTEXT, /* skipping text before the first section header */
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -Lroff.c -Lroff.c -u -p -r1.114 -r1.115
--- roff.c
+++ roff.c
@@ -1123,6 +1123,8 @@ roff_TE(ROFF_ARGS)
if (NULL == r->tbl)
(*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL);
+ else
+ tbl_end(r->tbl);
r->tbl = NULL;
return(ROFF_IGN);
@@ -1147,10 +1149,12 @@ roff_TS(ROFF_ARGS)
{
struct tbl *t;
- if (r->tbl)
+ if (r->tbl) {
(*r->msg)(MANDOCERR_SCOPEBROKEN, r->data, ln, ppos, NULL);
+ tbl_end(r->tbl);
+ }
- t = tbl_alloc(r->data, r->msg);
+ t = tbl_alloc(ppos, ln, r->data, r->msg);
if (r->last_tbl)
r->last_tbl->next = t;
Index: libroff.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libroff.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -Llibroff.h -Llibroff.h -u -p -r1.11 -r1.12
--- libroff.h
+++ libroff.h
@@ -31,6 +31,8 @@ struct tbl {
enum tbl_part part;
char tab; /* cell-separator */
char decimal; /* decimal point */
+ int pos; /* invocation column */
+ int line; /* invocation line */
int linesize;
char delims[2];
int opts;
@@ -51,7 +53,7 @@ struct tbl {
#define TBL_MSG(tblp, type, line, col) \
(*(tblp)->msg)((type), (tblp)->data, (line), (col), NULL)
-struct tbl *tbl_alloc(void *, mandocmsg);
+struct tbl *tbl_alloc(int, int, void *, mandocmsg);
void tbl_restart(struct tbl *);
void tbl_free(struct tbl *);
void tbl_reset(struct tbl *);
@@ -60,6 +62,7 @@ int tbl_option(struct tbl *, int, cons
int tbl_layout(struct tbl *, int, const char *);
int tbl_data(struct tbl *, int, const char *);
const struct tbl_span *tbl_span(const struct tbl *);
+void tbl_end(struct tbl *);
__END_DECLS
Index: main.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.c,v
retrieving revision 1.128
retrieving revision 1.129
diff -Lmain.c -Lmain.c -u -p -r1.128 -r1.129
--- main.c
+++ main.c
@@ -183,6 +183,7 @@ static const char * const mandocerrs[MAN
"bad table option",
"bad table layout",
"no table layout cells specified",
+ "no table data cells specified",
"input stack limit exceeded, infinite loop?",
"skipping bad character",
"skipping text before the first section header",
--
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 15:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-01 15:45 mdocml: Add documentation bits for libroff's new roff_span() 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).