version 1.27, 2014/08/10 23:54:41 |
version 1.30, 2014/11/25 21:41:47 |
Line 59 static int mods(struct tbl_node *, struct tbl_cell * |
|
Line 59 static int mods(struct tbl_node *, struct tbl_cell * |
|
int, const char *, int *); |
int, const char *, int *); |
static int cell(struct tbl_node *, struct tbl_row *, |
static int cell(struct tbl_node *, struct tbl_row *, |
int, const char *, int *); |
int, const char *, int *); |
static void row(struct tbl_node *, int, const char *, int *); |
|
static struct tbl_cell *cell_alloc(struct tbl_node *, struct tbl_row *, |
static struct tbl_cell *cell_alloc(struct tbl_node *, struct tbl_row *, |
enum tbl_cellt, int vert); |
enum tbl_cellt, int vert); |
|
|
|
|
goto mod; |
goto mod; |
case 'w': /* XXX for now, ignore minimal column width */ |
case 'w': /* XXX for now, ignore minimal column width */ |
goto mod; |
goto mod; |
|
case 'x': |
|
cp->flags |= TBL_CELL_WMAX; |
|
goto mod; |
case 'f': |
case 'f': |
break; |
break; |
case 'r': |
case 'r': |
|
|
default: |
default: |
break; |
break; |
} |
} |
|
if (isalnum((unsigned char)p[*pos - 1])) { |
|
mandoc_vmsg(MANDOCERR_FT_BAD, tbl->parse, |
|
ln, *pos - 1, "TS f%c", p[*pos - 1]); |
|
goto mod; |
|
} |
|
|
mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, |
mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, |
ln, *pos - 1, NULL); |
ln, *pos - 1, NULL); |
Line 292 cell(struct tbl_node *tbl, struct tbl_row *rp, |
|
Line 299 cell(struct tbl_node *tbl, struct tbl_row *rp, |
|
return(mods(tbl, cell_alloc(tbl, rp, c, vert), ln, p, pos)); |
return(mods(tbl, cell_alloc(tbl, rp, c, vert), ln, p, pos)); |
} |
} |
|
|
static void |
int |
row(struct tbl_node *tbl, int ln, const char *p, int *pos) |
tbl_layout(struct tbl_node *tbl, int ln, const char *p) |
{ |
{ |
struct tbl_row *rp; |
struct tbl_row *rp; |
|
int pos; |
|
|
row: /* |
pos = 0; |
* EBNF describing this section: |
rp = NULL; |
* |
|
* row ::= row_list [:space:]* [.]?[\n] |
|
* row_list ::= [:space:]* row_elem row_tail |
|
* row_tail ::= [:space:]*[,] row_list | |
|
* epsilon |
|
* row_elem ::= [\t\ ]*[:alpha:]+ |
|
*/ |
|
|
|
rp = mandoc_calloc(1, sizeof(struct tbl_row)); |
for (;;) { |
if (tbl->last_row) |
/* Skip whitespace before and after each cell. */ |
tbl->last_row->next = rp; |
|
else |
|
tbl->first_row = rp; |
|
tbl->last_row = rp; |
|
|
|
cell: |
while (isspace((unsigned char)p[pos])) |
while (isspace((unsigned char)p[*pos])) |
pos++; |
(*pos)++; |
|
|
|
/* Safely exit layout context. */ |
switch (p[pos]) { |
|
case ',': /* Next row on this input line. */ |
if ('.' == p[*pos]) { |
pos++; |
tbl->part = TBL_PART_DATA; |
rp = NULL; |
if (NULL == tbl->first_row) |
continue; |
|
case '\0': /* Next row on next input line. */ |
|
return(1); |
|
case '.': /* End of layout. */ |
|
pos++; |
|
tbl->part = TBL_PART_DATA; |
|
if (tbl->first_row != NULL) |
|
return(1); |
mandoc_msg(MANDOCERR_TBLNOLAYOUT, |
mandoc_msg(MANDOCERR_TBLNOLAYOUT, |
tbl->parse, ln, *pos, NULL); |
tbl->parse, ln, pos, NULL); |
(*pos)++; |
rp = mandoc_calloc(1, sizeof(*rp)); |
return; |
cell_alloc(tbl, rp, TBL_CELL_LEFT, 0); |
} |
tbl->first_row = tbl->last_row = rp; |
|
return(1); |
|
default: /* Cell. */ |
|
break; |
|
} |
|
|
/* End (and possibly restart) a row. */ |
if (rp == NULL) { /* First cell on this line. */ |
|
rp = mandoc_calloc(1, sizeof(*rp)); |
if (',' == p[*pos]) { |
if (tbl->last_row) |
(*pos)++; |
tbl->last_row->next = rp; |
goto row; |
else |
} else if ('\0' == p[*pos]) |
tbl->first_row = rp; |
return; |
tbl->last_row = rp; |
|
} |
if ( ! cell(tbl, rp, ln, p, pos)) |
if ( ! cell(tbl, rp, ln, p, &pos)) |
return; |
return(1); |
|
} |
goto cell; |
|
/* NOTREACHED */ |
|
} |
|
|
|
int |
|
tbl_layout(struct tbl_node *tbl, int ln, const char *p) |
|
{ |
|
int pos; |
|
|
|
pos = 0; |
|
row(tbl, ln, p, &pos); |
|
|
|
/* Always succeed. */ |
|
return(1); |
|
} |
} |
|
|
static struct tbl_cell * |
static struct tbl_cell * |