=================================================================== RCS file: /cvs/mandoc/tbl_layout.c,v retrieving revision 1.1 retrieving revision 1.4 diff -u -p -r1.1 -r1.4 --- mandoc/tbl_layout.c 2010/12/29 14:38:14 1.1 +++ mandoc/tbl_layout.c 2011/01/01 21:23:01 1.4 @@ -1,4 +1,4 @@ -/* $Id: tbl_layout.c,v 1.1 2010/12/29 14:38:14 kristaps Exp $ */ +/* $Id: tbl_layout.c,v 1.4 2011/01/01 21:23:01 kristaps Exp $ */ /* * Copyright (c) 2009, 2010 Kristaps Dzonsons * @@ -18,6 +18,7 @@ #include #include #include +#include #include "mandoc.h" #include "libmandoc.h" @@ -28,21 +29,15 @@ struct tbl_phrase { enum tbl_cellt key; }; -#define KEYS_MAX 17 +#define KEYS_MAX 11 static const struct tbl_phrase keys[KEYS_MAX] = { { 'c', TBL_CELL_CENTRE }, - { 'C', TBL_CELL_CENTRE }, { 'r', TBL_CELL_RIGHT }, - { 'R', TBL_CELL_RIGHT }, { 'l', TBL_CELL_LEFT }, - { 'L', TBL_CELL_LEFT }, { 'n', TBL_CELL_NUMBER }, - { 'N', TBL_CELL_NUMBER }, { 's', TBL_CELL_SPAN }, - { 'S', TBL_CELL_SPAN }, { 'a', TBL_CELL_LONG }, - { 'A', TBL_CELL_LONG }, { '^', TBL_CELL_DOWN }, { '-', TBL_CELL_HORIZ }, { '_', TBL_CELL_HORIZ }, @@ -111,56 +106,39 @@ mod: /* TODO: GNU has many more extensions. */ - switch (p[(*pos)++]) { + switch (tolower(p[(*pos)++])) { case ('z'): - /* FALLTHROUGH */ - case ('Z'): cp->flags |= TBL_CELL_WIGN; goto mod; case ('u'): - /* FALLTHROUGH */ - case ('U'): cp->flags |= TBL_CELL_UP; goto mod; case ('e'): - /* FALLTHROUGH */ - case ('E'): cp->flags |= TBL_CELL_EQUAL; goto mod; case ('t'): - /* FALLTHROUGH */ - case ('T'): cp->flags |= TBL_CELL_TALIGN; goto mod; case ('d'): - /* FALLTHROUGH */ - case ('D'): cp->flags |= TBL_CELL_BALIGN; goto mod; case ('f'): - /* FALLTHROUGH */ - case ('B'): - /* FALLTHROUGH */ - case ('I'): - /* FALLTHROUGH */ + break; case ('b'): /* FALLTHROUGH */ case ('i'): + (*pos)--; break; default: TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1); return(0); } - switch (p[(*pos)++]) { + switch (tolower(p[(*pos)++])) { case ('b'): - /* FALLTHROUGH */ - case ('B'): cp->flags |= TBL_CELL_BOLD; goto mod; case ('i'): - /* FALLTHROUGH */ - case ('I'): cp->flags |= TBL_CELL_ITALIC; goto mod; default: @@ -182,7 +160,7 @@ cell(struct tbl *tbl, struct tbl_row *rp, /* Parse the column position (`r', `R', `|', ...). */ for (i = 0; i < KEYS_MAX; i++) - if (p[*pos] == keys[i].name) + if (tolower(p[*pos]) == keys[i].name) break; if (KEYS_MAX == i) { @@ -240,11 +218,11 @@ row: /* */ rp = mandoc_calloc(1, sizeof(struct tbl_row)); - if (tbl->last) { - tbl->last->next = rp; - tbl->last = rp; + if (tbl->last_row) { + tbl->last_row->next = rp; + tbl->last_row = rp; } else - tbl->last = tbl->first = rp; + tbl->last_row = tbl->first_row = rp; cell: while (isspace((unsigned char)p[*pos])) @@ -254,7 +232,7 @@ cell: if ('.' == p[*pos]) { tbl->part = TBL_PART_DATA; - if (NULL == tbl->first) + if (NULL == tbl->first_row) TBL_MSG(tbl, MANDOCERR_TBLNOLAYOUT, ln, *pos); (*pos)++; return;