[BACK]Return to tbl_opts.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Diff for /src/usr.bin/mandoc/tbl_opts.c between version 1.4 and 1.5

version 1.4, 2011/04/24 16:22:02 version 1.5, 2014/04/20 16:44:44
Line 58 
Line 58 
 static  const struct tbl_phrase keys[KEY_MAXKEYS] = {  static  const struct tbl_phrase keys[KEY_MAXKEYS] = {
         { "center",      TBL_OPT_CENTRE,        KEY_CENTRE},          { "center",      TBL_OPT_CENTRE,        KEY_CENTRE},
         { "centre",      TBL_OPT_CENTRE,        KEY_CENTRE},          { "centre",      TBL_OPT_CENTRE,        KEY_CENTRE},
         { "delim",       0,                     KEY_DELIM},          { "delim",       0,                     KEY_DELIM},
         { "expand",      TBL_OPT_EXPAND,        KEY_EXPAND},          { "expand",      TBL_OPT_EXPAND,        KEY_EXPAND},
         { "box",         TBL_OPT_BOX,           KEY_BOX},          { "box",         TBL_OPT_BOX,           KEY_BOX},
         { "doublebox",   TBL_OPT_DBOX,          KEY_DBOX},          { "doublebox",   TBL_OPT_DBOX,          KEY_DBOX},
         { "allbox",      TBL_OPT_ALLBOX,        KEY_ALLBOX},          { "allbox",      TBL_OPT_ALLBOX,        KEY_ALLBOX},
         { "frame",       TBL_OPT_BOX,           KEY_FRAME},          { "frame",       TBL_OPT_BOX,           KEY_FRAME},
         { "doubleframe", TBL_OPT_DBOX,          KEY_DFRAME},          { "doubleframe", TBL_OPT_DBOX,          KEY_DFRAME},
Line 72 
Line 72 
         { "nospaces",    TBL_OPT_NOSPACE,       KEY_NOSPACE},          { "nospaces",    TBL_OPT_NOSPACE,       KEY_NOSPACE},
 };  };
   
 static  int              arg(struct tbl_node *, int,  static  int              arg(struct tbl_node *, int,
                                 const char *, int *, enum tbl_ident);                                  const char *, int *, enum tbl_ident);
 static  void             opt(struct tbl_node *, int,  static  void             opt(struct tbl_node *, int,
                                 const char *, int *);                                  const char *, int *);
   
   
 static int  static int
 arg(struct tbl_node *tbl, int ln, const char *p, int *pos, enum tbl_ident key)  arg(struct tbl_node *tbl, int ln, const char *p, int *pos, enum tbl_ident key)
 {  {
Line 89 
Line 90 
         /* Arguments always begin with a parenthesis. */          /* Arguments always begin with a parenthesis. */
   
         if ('(' != p[*pos]) {          if ('(' != p[*pos]) {
                 mandoc_msg(MANDOCERR_TBL, tbl->parse,                  mandoc_msg(MANDOCERR_TBL, tbl->parse,
                                 ln, *pos, NULL);                      ln, *pos, NULL);
                 return(0);                  return(0);
         }          }
   
Line 103 
Line 104 
          */           */
   
         switch (key) {          switch (key) {
         case (KEY_DELIM):          case KEY_DELIM:
                 if ('\0' == p[(*pos)++]) {                  if ('\0' == p[(*pos)++]) {
                         mandoc_msg(MANDOCERR_TBL, tbl->parse,                          mandoc_msg(MANDOCERR_TBL, tbl->parse,
                                         ln, *pos - 1, NULL);                              ln, *pos - 1, NULL);
                         return(0);                          return(0);
                 }                  }
   
                 if ('\0' == p[(*pos)++]) {                  if ('\0' == p[(*pos)++]) {
                         mandoc_msg(MANDOCERR_TBL, tbl->parse,                          mandoc_msg(MANDOCERR_TBL, tbl->parse,
                                         ln, *pos - 1, NULL);                              ln, *pos - 1, NULL);
                         return(0);                          return(0);
                 }                  }
                 break;                  break;
         case (KEY_TAB):          case KEY_TAB:
                 if ('\0' != (tbl->opts.tab = p[(*pos)++]))                  if ('\0' != (tbl->opts.tab = p[(*pos)++]))
                         break;                          break;
   
                 mandoc_msg(MANDOCERR_TBL, tbl->parse,                  mandoc_msg(MANDOCERR_TBL, tbl->parse,
                                 ln, *pos - 1, NULL);                      ln, *pos - 1, NULL);
                 return(0);                  return(0);
         case (KEY_LINESIZE):          case KEY_LINESIZE:
                 for (i = 0; i < KEY_MAXNUMSZ && p[*pos]; i++, (*pos)++) {                  for (i = 0; i < KEY_MAXNUMSZ && p[*pos]; i++, (*pos)++) {
                         buf[i] = p[*pos];                          buf[i] = p[*pos];
                         if ( ! isdigit((unsigned char)buf[i]))                          if ( ! isdigit((unsigned char)buf[i]))
Line 138 
Line 139 
   
                 mandoc_msg(MANDOCERR_TBL, tbl->parse, ln, *pos, NULL);                  mandoc_msg(MANDOCERR_TBL, tbl->parse, ln, *pos, NULL);
                 return(0);                  return(0);
         case (KEY_DPOINT):          case KEY_DPOINT:
                 if ('\0' != (tbl->opts.decimal = p[(*pos)++]))                  if ('\0' != (tbl->opts.decimal = p[(*pos)++]))
                         break;                          break;
   
                 mandoc_msg(MANDOCERR_TBL, tbl->parse,                  mandoc_msg(MANDOCERR_TBL, tbl->parse,
                                 ln, *pos - 1, NULL);                      ln, *pos - 1, NULL);
                 return(0);                  return(0);
         default:          default:
                 abort();                  abort();
Line 178 
Line 179 
          * options      ::= option_list [:space:]* [;][\n]           * options      ::= option_list [:space:]* [;][\n]
          * option_list  ::= option option_tail           * option_list  ::= option option_tail
          * option_tail  ::= [:space:]+ option_list |           * option_tail  ::= [:space:]+ option_list |
          *              ::= epsilon           *              ::= epsilon
          * option       ::= [:alpha:]+ args           * option       ::= [:alpha:]+ args
          * args         ::= [:space:]* [(] [:alpha:]+ [)]           * args         ::= [:space:]* [(] [:alpha:]+ [)]
          */           */
Line 211 
Line 212 
         while (isspace((unsigned char)p[*pos]))          while (isspace((unsigned char)p[*pos]))
                 (*pos)++;                  (*pos)++;
   
         /*          /*
          * Look through all of the available keys to find one that           * Look through all of the available keys to find one that
          * matches the input.  FIXME: hashtable this.           * matches the input.  FIXME: hashtable this.
          */           */
Line 227 
Line 228 
                  * of the sequence altogether.                   * of the sequence altogether.
                  */                   */
   
                 if (keys[i].key)                  if (keys[i].key)
                         tbl->opts.opts |= keys[i].key;                          tbl->opts.opts |= keys[i].key;
                 else if ( ! arg(tbl, ln, p, pos, keys[i].ident))                  else if ( ! arg(tbl, ln, p, pos, keys[i].ident))
                         return;                          return;
Line 235 
Line 236 
                 break;                  break;
         }          }
   
         /*          /*
          * Allow us to recover from bad options by continuing to another           * Allow us to recover from bad options by continuing to another
          * parse sequence.           * parse sequence.
          */           */

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5