diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-01-01 15:45:18 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-01-01 15:45:18 +0000 |
commit | 11a4a49536978db711f68cc010fec41f76c2f970 (patch) | |
tree | 898f1e145588b487ca875c4fd3df9e132eddb1ff | |
parent | 31916df7856f6ea8b704f200c8a68d72e536fd32 (diff) | |
download | mandoc-11a4a49536978db711f68cc010fec41f76c2f970.tar.gz |
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.
-rw-r--r-- | libroff.h | 5 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | mandoc.h | 1 | ||||
-rw-r--r-- | roff.3 | 12 | ||||
-rw-r--r-- | roff.c | 8 | ||||
-rw-r--r-- | tbl.c | 12 |
6 files changed, 34 insertions, 5 deletions
@@ -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, const char *); 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 @@ -183,6 +183,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "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", @@ -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 */ @@ -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 @@ -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; @@ -64,11 +64,13 @@ tbl_read(struct tbl *tbl, int ln, const char *p, int offs) } 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; @@ -127,3 +129,11 @@ 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); +} |