version 1.1, 2010/12/29 14:38:14 |
version 1.4, 2011/01/01 21:23:01 |
|
|
#include <ctype.h> |
#include <ctype.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
#include <time.h> |
|
|
#include "mandoc.h" |
#include "mandoc.h" |
#include "libmandoc.h" |
#include "libmandoc.h" |
Line 28 struct tbl_phrase { |
|
Line 29 struct tbl_phrase { |
|
enum tbl_cellt key; |
enum tbl_cellt key; |
}; |
}; |
|
|
#define KEYS_MAX 17 |
#define KEYS_MAX 11 |
|
|
static const struct tbl_phrase keys[KEYS_MAX] = { |
static const struct tbl_phrase keys[KEYS_MAX] = { |
{ 'c', TBL_CELL_CENTRE }, |
{ 'c', TBL_CELL_CENTRE }, |
{ 'C', TBL_CELL_CENTRE }, |
|
{ 'r', TBL_CELL_RIGHT }, |
{ 'r', TBL_CELL_RIGHT }, |
{ 'R', TBL_CELL_RIGHT }, |
|
{ 'l', TBL_CELL_LEFT }, |
{ 'l', TBL_CELL_LEFT }, |
{ 'L', TBL_CELL_LEFT }, |
|
{ 'n', TBL_CELL_NUMBER }, |
{ 'n', TBL_CELL_NUMBER }, |
{ 'N', TBL_CELL_NUMBER }, |
|
{ 's', TBL_CELL_SPAN }, |
{ 's', TBL_CELL_SPAN }, |
{ 'S', TBL_CELL_SPAN }, |
|
{ 'a', TBL_CELL_LONG }, |
{ 'a', TBL_CELL_LONG }, |
{ 'A', TBL_CELL_LONG }, |
|
{ '^', TBL_CELL_DOWN }, |
{ '^', TBL_CELL_DOWN }, |
{ '-', TBL_CELL_HORIZ }, |
{ '-', TBL_CELL_HORIZ }, |
{ '_', TBL_CELL_HORIZ }, |
{ '_', TBL_CELL_HORIZ }, |
|
|
|
|
/* TODO: GNU has many more extensions. */ |
/* TODO: GNU has many more extensions. */ |
|
|
switch (p[(*pos)++]) { |
switch (tolower(p[(*pos)++])) { |
case ('z'): |
case ('z'): |
/* FALLTHROUGH */ |
|
case ('Z'): |
|
cp->flags |= TBL_CELL_WIGN; |
cp->flags |= TBL_CELL_WIGN; |
goto mod; |
goto mod; |
case ('u'): |
case ('u'): |
/* FALLTHROUGH */ |
|
case ('U'): |
|
cp->flags |= TBL_CELL_UP; |
cp->flags |= TBL_CELL_UP; |
goto mod; |
goto mod; |
case ('e'): |
case ('e'): |
/* FALLTHROUGH */ |
|
case ('E'): |
|
cp->flags |= TBL_CELL_EQUAL; |
cp->flags |= TBL_CELL_EQUAL; |
goto mod; |
goto mod; |
case ('t'): |
case ('t'): |
/* FALLTHROUGH */ |
|
case ('T'): |
|
cp->flags |= TBL_CELL_TALIGN; |
cp->flags |= TBL_CELL_TALIGN; |
goto mod; |
goto mod; |
case ('d'): |
case ('d'): |
/* FALLTHROUGH */ |
|
case ('D'): |
|
cp->flags |= TBL_CELL_BALIGN; |
cp->flags |= TBL_CELL_BALIGN; |
goto mod; |
goto mod; |
case ('f'): |
case ('f'): |
/* FALLTHROUGH */ |
break; |
case ('B'): |
|
/* FALLTHROUGH */ |
|
case ('I'): |
|
/* FALLTHROUGH */ |
|
case ('b'): |
case ('b'): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case ('i'): |
case ('i'): |
|
(*pos)--; |
break; |
break; |
default: |
default: |
TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1); |
TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1); |
return(0); |
return(0); |
} |
} |
|
|
switch (p[(*pos)++]) { |
switch (tolower(p[(*pos)++])) { |
case ('b'): |
case ('b'): |
/* FALLTHROUGH */ |
|
case ('B'): |
|
cp->flags |= TBL_CELL_BOLD; |
cp->flags |= TBL_CELL_BOLD; |
goto mod; |
goto mod; |
case ('i'): |
case ('i'): |
/* FALLTHROUGH */ |
|
case ('I'): |
|
cp->flags |= TBL_CELL_ITALIC; |
cp->flags |= TBL_CELL_ITALIC; |
goto mod; |
goto mod; |
default: |
default: |
Line 182 cell(struct tbl *tbl, struct tbl_row *rp, |
|
Line 160 cell(struct tbl *tbl, struct tbl_row *rp, |
|
/* Parse the column position (`r', `R', `|', ...). */ |
/* Parse the column position (`r', `R', `|', ...). */ |
|
|
for (i = 0; i < KEYS_MAX; i++) |
for (i = 0; i < KEYS_MAX; i++) |
if (p[*pos] == keys[i].name) |
if (tolower(p[*pos]) == keys[i].name) |
break; |
break; |
|
|
if (KEYS_MAX == i) { |
if (KEYS_MAX == i) { |
|
|
*/ |
*/ |
|
|
rp = mandoc_calloc(1, sizeof(struct tbl_row)); |
rp = mandoc_calloc(1, sizeof(struct tbl_row)); |
if (tbl->last) { |
if (tbl->last_row) { |
tbl->last->next = rp; |
tbl->last_row->next = rp; |
tbl->last = rp; |
tbl->last_row = rp; |
} else |
} else |
tbl->last = tbl->first = rp; |
tbl->last_row = tbl->first_row = rp; |
|
|
cell: |
cell: |
while (isspace((unsigned char)p[*pos])) |
while (isspace((unsigned char)p[*pos])) |
|
|
|
|
if ('.' == p[*pos]) { |
if ('.' == p[*pos]) { |
tbl->part = TBL_PART_DATA; |
tbl->part = TBL_PART_DATA; |
if (NULL == tbl->first) |
if (NULL == tbl->first_row) |
TBL_MSG(tbl, MANDOCERR_TBLNOLAYOUT, ln, *pos); |
TBL_MSG(tbl, MANDOCERR_TBLNOLAYOUT, ln, *pos); |
(*pos)++; |
(*pos)++; |
return; |
return; |