version 1.28, 2014/01/05 18:37:53 |
version 1.31, 2014/04/23 16:08:33 |
|
|
#include <time.h> |
#include <time.h> |
|
|
#include "mandoc.h" |
#include "mandoc.h" |
|
#include "mandoc_aux.h" |
#include "libmandoc.h" |
#include "libmandoc.h" |
#include "libroff.h" |
#include "libroff.h" |
|
|
static int getdata(struct tbl_node *, struct tbl_span *, |
static int getdata(struct tbl_node *, struct tbl_span *, |
int, const char *, int *); |
int, const char *, int *); |
static struct tbl_span *newspan(struct tbl_node *, int, |
static struct tbl_span *newspan(struct tbl_node *, int, |
struct tbl_row *); |
struct tbl_row *); |
|
|
|
|
static int |
static int |
getdata(struct tbl_node *tbl, struct tbl_span *dp, |
getdata(struct tbl_node *tbl, struct tbl_span *dp, |
int ln, const char *p, int *pos) |
int ln, const char *p, int *pos) |
{ |
{ |
struct tbl_dat *dat; |
struct tbl_dat *dat; |
Line 48 getdata(struct tbl_node *tbl, struct tbl_span *dp, |
|
Line 50 getdata(struct tbl_node *tbl, struct tbl_span *dp, |
|
else if (NULL == dp->last) |
else if (NULL == dp->last) |
cp = dp->layout->first; |
cp = dp->layout->first; |
|
|
/* |
/* |
* Skip over spanners, since |
* Skip over spanners, since |
* we want to match data with data layout cells in the header. |
* we want to match data with data layout cells in the header. |
*/ |
*/ |
Line 62 getdata(struct tbl_node *tbl, struct tbl_span *dp, |
|
Line 64 getdata(struct tbl_node *tbl, struct tbl_span *dp, |
|
*/ |
*/ |
|
|
if (NULL == cp) { |
if (NULL == cp) { |
mandoc_msg(MANDOCERR_TBLEXTRADAT, |
mandoc_msg(MANDOCERR_TBLEXTRADAT, tbl->parse, |
tbl->parse, ln, *pos, NULL); |
ln, *pos, NULL); |
/* Skip to the end... */ |
/* Skip to the end... */ |
while (p[*pos]) |
while (p[*pos]) |
(*pos)++; |
(*pos)++; |
Line 81 getdata(struct tbl_node *tbl, struct tbl_span *dp, |
|
Line 83 getdata(struct tbl_node *tbl, struct tbl_span *dp, |
|
spans++; |
spans++; |
else |
else |
break; |
break; |
|
|
dat->spans = spans; |
dat->spans = spans; |
|
|
if (dp->last) { |
if (dp->last) { |
Line 126 getdata(struct tbl_node *tbl, struct tbl_span *dp, |
|
Line 128 getdata(struct tbl_node *tbl, struct tbl_span *dp, |
|
dat->pos = TBL_DATA_DATA; |
dat->pos = TBL_DATA_DATA; |
|
|
if (TBL_CELL_HORIZ == dat->layout->pos || |
if (TBL_CELL_HORIZ == dat->layout->pos || |
TBL_CELL_DHORIZ == dat->layout->pos || |
TBL_CELL_DHORIZ == dat->layout->pos || |
TBL_CELL_DOWN == dat->layout->pos) |
TBL_CELL_DOWN == dat->layout->pos) |
if (TBL_DATA_DATA == dat->pos && '\0' != *dat->string) |
if (TBL_DATA_DATA == dat->pos && '\0' != *dat->string) |
mandoc_msg(MANDOCERR_TBLIGNDATA, |
mandoc_msg(MANDOCERR_TBLIGNDATA, |
tbl->parse, ln, sv, NULL); |
tbl->parse, ln, sv, NULL); |
|
|
return(1); |
return(1); |
} |
} |
|
|
/* ARGSUSED */ |
|
int |
int |
tbl_cdata(struct tbl_node *tbl, int ln, const char *p) |
tbl_cdata(struct tbl_node *tbl, int ln, const char *p) |
{ |
{ |
struct tbl_dat *dat; |
struct tbl_dat *dat; |
size_t sz; |
size_t sz; |
int pos; |
int pos; |
|
|
pos = 0; |
pos = 0; |
Line 166 tbl_cdata(struct tbl_node *tbl, int ln, const char *p) |
|
Line 167 tbl_cdata(struct tbl_node *tbl, int ln, const char *p) |
|
if (dat->string) { |
if (dat->string) { |
sz = strlen(p) + strlen(dat->string) + 2; |
sz = strlen(p) + strlen(dat->string) + 2; |
dat->string = mandoc_realloc(dat->string, sz); |
dat->string = mandoc_realloc(dat->string, sz); |
strlcat(dat->string, " ", sz); |
(void)strlcat(dat->string, " ", sz); |
strlcat(dat->string, p, sz); |
(void)strlcat(dat->string, p, sz); |
} else |
} else |
dat->string = mandoc_strdup(p); |
dat->string = mandoc_strdup(p); |
|
|
if (TBL_CELL_DOWN == dat->layout->pos) |
if (TBL_CELL_DOWN == dat->layout->pos) |
mandoc_msg(MANDOCERR_TBLIGNDATA, |
mandoc_msg(MANDOCERR_TBLIGNDATA, tbl->parse, |
tbl->parse, ln, pos, NULL); |
ln, pos, NULL); |
|
|
return(0); |
return(0); |
} |
} |
Line 215 tbl_data(struct tbl_node *tbl, int ln, const char *p) |
|
Line 216 tbl_data(struct tbl_node *tbl, int ln, const char *p) |
|
return(0); |
return(0); |
} |
} |
|
|
/* |
/* |
* Choose a layout row: take the one following the last parsed |
* Choose a layout row: take the one following the last parsed |
* span's. If that doesn't exist, use the last parsed span's. |
* span's. If that doesn't exist, use the last parsed span's. |
* If there's no last parsed span, use the first row. Lastly, |
* If there's no last parsed span, use the first row. Lastly, |
Line 229 tbl_data(struct tbl_node *tbl, int ln, const char *p) |
|
Line 230 tbl_data(struct tbl_node *tbl, int ln, const char *p) |
|
for (rp = tbl->last_span->layout->next; |
for (rp = tbl->last_span->layout->next; |
rp && rp->first; rp = rp->next) { |
rp && rp->first; rp = rp->next) { |
switch (rp->first->pos) { |
switch (rp->first->pos) { |
case (TBL_CELL_HORIZ): |
case TBL_CELL_HORIZ: |
dp = newspan(tbl, ln, rp); |
dp = newspan(tbl, ln, rp); |
dp->pos = TBL_SPAN_HORIZ; |
dp->pos = TBL_SPAN_HORIZ; |
continue; |
continue; |
case (TBL_CELL_DHORIZ): |
case TBL_CELL_DHORIZ: |
dp = newspan(tbl, ln, rp); |
dp = newspan(tbl, ln, rp); |
dp->pos = TBL_SPAN_DHORIZ; |
dp->pos = TBL_SPAN_DHORIZ; |
continue; |
continue; |