=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/tbl_opts.c,v retrieving revision 1.4 retrieving revision 1.5 diff -c -r1.4 -r1.5 *** src/usr.bin/mandoc/tbl_opts.c 2011/04/24 16:22:02 1.4 --- src/usr.bin/mandoc/tbl_opts.c 2014/04/20 16:44:44 1.5 *************** *** 1,4 **** ! /* $Id: tbl_opts.c,v 1.4 2011/04/24 16:22:02 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * --- 1,4 ---- ! /* $Id: tbl_opts.c,v 1.5 2014/04/20 16:44:44 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * *************** *** 58,67 **** static const struct tbl_phrase keys[KEY_MAXKEYS] = { { "center", TBL_OPT_CENTRE, KEY_CENTRE}, { "centre", TBL_OPT_CENTRE, KEY_CENTRE}, ! { "delim", 0, KEY_DELIM}, { "expand", TBL_OPT_EXPAND, KEY_EXPAND}, ! { "box", TBL_OPT_BOX, KEY_BOX}, ! { "doublebox", TBL_OPT_DBOX, KEY_DBOX}, { "allbox", TBL_OPT_ALLBOX, KEY_ALLBOX}, { "frame", TBL_OPT_BOX, KEY_FRAME}, { "doubleframe", TBL_OPT_DBOX, KEY_DFRAME}, --- 58,67 ---- static const struct tbl_phrase keys[KEY_MAXKEYS] = { { "center", TBL_OPT_CENTRE, KEY_CENTRE}, { "centre", TBL_OPT_CENTRE, KEY_CENTRE}, ! { "delim", 0, KEY_DELIM}, { "expand", TBL_OPT_EXPAND, KEY_EXPAND}, ! { "box", TBL_OPT_BOX, KEY_BOX}, ! { "doublebox", TBL_OPT_DBOX, KEY_DBOX}, { "allbox", TBL_OPT_ALLBOX, KEY_ALLBOX}, { "frame", TBL_OPT_BOX, KEY_FRAME}, { "doubleframe", TBL_OPT_DBOX, KEY_DFRAME}, *************** *** 72,82 **** { "nospaces", TBL_OPT_NOSPACE, KEY_NOSPACE}, }; ! static int arg(struct tbl_node *, int, const char *, int *, enum tbl_ident); ! static void opt(struct tbl_node *, int, const char *, int *); static int arg(struct tbl_node *tbl, int ln, const char *p, int *pos, enum tbl_ident key) { --- 72,83 ---- { "nospaces", TBL_OPT_NOSPACE, KEY_NOSPACE}, }; ! static int arg(struct tbl_node *, int, const char *, int *, enum tbl_ident); ! static void opt(struct tbl_node *, int, const char *, int *); + static int arg(struct tbl_node *tbl, int ln, const char *p, int *pos, enum tbl_ident key) { *************** *** 89,96 **** /* Arguments always begin with a parenthesis. */ if ('(' != p[*pos]) { ! mandoc_msg(MANDOCERR_TBL, tbl->parse, ! ln, *pos, NULL); return(0); } --- 90,97 ---- /* Arguments always begin with a parenthesis. */ if ('(' != p[*pos]) { ! mandoc_msg(MANDOCERR_TBL, tbl->parse, ! ln, *pos, NULL); return(0); } *************** *** 103,129 **** */ switch (key) { ! case (KEY_DELIM): if ('\0' == p[(*pos)++]) { mandoc_msg(MANDOCERR_TBL, tbl->parse, ! ln, *pos - 1, NULL); return(0); ! } if ('\0' == p[(*pos)++]) { mandoc_msg(MANDOCERR_TBL, tbl->parse, ! ln, *pos - 1, NULL); return(0); ! } break; ! case (KEY_TAB): if ('\0' != (tbl->opts.tab = p[(*pos)++])) break; mandoc_msg(MANDOCERR_TBL, tbl->parse, ! ln, *pos - 1, NULL); return(0); ! case (KEY_LINESIZE): for (i = 0; i < KEY_MAXNUMSZ && p[*pos]; i++, (*pos)++) { buf[i] = p[*pos]; if ( ! isdigit((unsigned char)buf[i])) --- 104,130 ---- */ switch (key) { ! case KEY_DELIM: if ('\0' == p[(*pos)++]) { mandoc_msg(MANDOCERR_TBL, tbl->parse, ! ln, *pos - 1, NULL); return(0); ! } if ('\0' == p[(*pos)++]) { mandoc_msg(MANDOCERR_TBL, tbl->parse, ! ln, *pos - 1, NULL); return(0); ! } break; ! case KEY_TAB: if ('\0' != (tbl->opts.tab = p[(*pos)++])) break; mandoc_msg(MANDOCERR_TBL, tbl->parse, ! ln, *pos - 1, NULL); return(0); ! case KEY_LINESIZE: for (i = 0; i < KEY_MAXNUMSZ && p[*pos]; i++, (*pos)++) { buf[i] = p[*pos]; if ( ! isdigit((unsigned char)buf[i])) *************** *** 138,149 **** mandoc_msg(MANDOCERR_TBL, tbl->parse, ln, *pos, NULL); return(0); ! case (KEY_DPOINT): if ('\0' != (tbl->opts.decimal = p[(*pos)++])) break; ! mandoc_msg(MANDOCERR_TBL, tbl->parse, ! ln, *pos - 1, NULL); return(0); default: abort(); --- 139,150 ---- mandoc_msg(MANDOCERR_TBL, tbl->parse, ln, *pos, NULL); return(0); ! case KEY_DPOINT: if ('\0' != (tbl->opts.decimal = p[(*pos)++])) break; ! mandoc_msg(MANDOCERR_TBL, tbl->parse, ! ln, *pos - 1, NULL); return(0); default: abort(); *************** *** 178,184 **** * options ::= option_list [:space:]* [;][\n] * option_list ::= option option_tail * option_tail ::= [:space:]+ option_list | ! * ::= epsilon * option ::= [:alpha:]+ args * args ::= [:space:]* [(] [:alpha:]+ [)] */ --- 179,185 ---- * options ::= option_list [:space:]* [;][\n] * option_list ::= option option_tail * option_tail ::= [:space:]+ option_list | ! * ::= epsilon * option ::= [:alpha:]+ args * args ::= [:space:]* [(] [:alpha:]+ [)] */ *************** *** 211,217 **** while (isspace((unsigned char)p[*pos])) (*pos)++; ! /* * Look through all of the available keys to find one that * matches the input. FIXME: hashtable this. */ --- 212,218 ---- while (isspace((unsigned char)p[*pos])) (*pos)++; ! /* * Look through all of the available keys to find one that * matches the input. FIXME: hashtable this. */ *************** *** 227,233 **** * of the sequence altogether. */ ! if (keys[i].key) tbl->opts.opts |= keys[i].key; else if ( ! arg(tbl, ln, p, pos, keys[i].ident)) return; --- 228,234 ---- * of the sequence altogether. */ ! if (keys[i].key) tbl->opts.opts |= keys[i].key; else if ( ! arg(tbl, ln, p, pos, keys[i].ident)) return; *************** *** 235,241 **** break; } ! /* * Allow us to recover from bad options by continuing to another * parse sequence. */ --- 236,242 ---- break; } ! /* * Allow us to recover from bad options by continuing to another * parse sequence. */