From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (kristaps@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p01FjKcA015479 for ; Sat, 1 Jan 2011 10:45:21 -0500 (EST) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id p01FjJ7b032471; Sat, 1 Jan 2011 10:45:19 -0500 (EST) Date: Sat, 1 Jan 2011 10:45:19 -0500 (EST) Message-Id: <201101011545.p01FjJ7b032471@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Add documentation bits for libroff's new roff_span(). X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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