[BACK]Return to tbl_opts.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/tbl_opts.c between version 1.17 and 1.18

version 1.17, 2015/01/26 00:57:22 version 1.18, 2015/01/26 13:03:48
Line 28 
Line 28 
 #include "libmandoc.h"  #include "libmandoc.h"
 #include "libroff.h"  #include "libroff.h"
   
 enum    tbl_ident {  #define KEY_DPOINT      0
         KEY_CENTRE = 0,  #define KEY_DELIM       1
         KEY_DELIM,  #define KEY_LINESIZE    2
         KEY_EXPAND,  #define KEY_TAB         3
         KEY_BOX,  
         KEY_DBOX,  
         KEY_ALLBOX,  
         KEY_TAB,  
         KEY_LINESIZE,  
         KEY_NOKEEP,  
         KEY_DPOINT,  
         KEY_NOSPACE,  
         KEY_FRAME,  
         KEY_DFRAME,  
         KEY_MAX  
 };  
   
 struct  tbl_phrase {  struct  tbl_phrase {
         const char      *name;          const char      *name;
         int              key;          int              key;
         enum tbl_ident   ident;  
 };  };
   
 /* Handle Commonwealth/American spellings. */  static  const struct tbl_phrase keys[] = {
 #define KEY_MAXKEYS      14          {"decimalpoint", 0},
           {"delim",        0},
 static  const struct tbl_phrase keys[KEY_MAXKEYS] = {          {"linesize",     0},
         { "center",      TBL_OPT_CENTRE,        KEY_CENTRE},          {"tab",          0},
         { "centre",      TBL_OPT_CENTRE,        KEY_CENTRE},          {"allbox",       TBL_OPT_ALLBOX | TBL_OPT_BOX},
         { "delim",       0,                     KEY_DELIM},          {"box",          TBL_OPT_BOX},
         { "expand",      TBL_OPT_EXPAND,        KEY_EXPAND},          {"frame",        TBL_OPT_BOX},
         { "box",         TBL_OPT_BOX,           KEY_BOX},          {"center",       TBL_OPT_CENTRE},
         { "doublebox",   TBL_OPT_DBOX,          KEY_DBOX},          {"centre",       TBL_OPT_CENTRE},
         { "allbox",      TBL_OPT_ALLBOX,        KEY_ALLBOX},          {"doublebox",    TBL_OPT_DBOX},
         { "frame",       TBL_OPT_BOX,           KEY_FRAME},          {"doubleframe",  TBL_OPT_DBOX},
         { "doubleframe", TBL_OPT_DBOX,          KEY_DFRAME},          {"expand",       TBL_OPT_EXPAND},
         { "tab",         0,                     KEY_TAB},          {"nokeep",       TBL_OPT_NOKEEP},
         { "linesize",    0,                     KEY_LINESIZE},          {"nospaces",     TBL_OPT_NOSPACE},
         { "nokeep",      TBL_OPT_NOKEEP,        KEY_NOKEEP},          {"nowarn",       TBL_OPT_NOWARN},
         { "decimalpoint", 0,                    KEY_DPOINT},  
         { "nospaces",    TBL_OPT_NOSPACE,       KEY_NOSPACE},  
 };  };
   
 static  void             arg(struct tbl_node *, int,  #define KEY_MAXKEYS ((int)(sizeof(keys)/sizeof(keys[0])))
                                 const char *, int *, enum tbl_ident);  
   
   static  void     arg(struct tbl_node *, int, const char *, int *, int);
   
   
 static void  static void
 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, int key)
 {  {
         const char      *optname;  
         int              len, want;          int              len, want;
   
         while (isspace((unsigned char)p[*pos]))          while (p[*pos] == ' ' || p[*pos] == '\t')
                 (*pos)++;                  (*pos)++;
   
         /* Arguments are enclosed in parentheses. */          /* Arguments are enclosed in parentheses. */
Line 95  arg(struct tbl_node *tbl, int ln, const char *p, int *
Line 80  arg(struct tbl_node *tbl, int ln, const char *p, int *
   
         switch (key) {          switch (key) {
         case KEY_DELIM:          case KEY_DELIM:
                 optname = "delim";                  mandoc_msg(MANDOCERR_TBLEQN, tbl->parse, ln, *pos, NULL);
                 want = 2;                  want = 2;
                 break;                  break;
         case KEY_TAB:          case KEY_TAB:
                 optname = "tab";  
                 want = 1;                  want = 1;
                 if (len == want)                  if (len == want)
                         tbl->opts.tab = p[*pos];                          tbl->opts.tab = p[*pos];
                 break;                  break;
         case KEY_LINESIZE:          case KEY_LINESIZE:
                 optname = "linesize";  
                 want = 0;                  want = 0;
                 break;                  break;
         case KEY_DPOINT:          case KEY_DPOINT:
                 optname = "decimalpoint";  
                 want = 1;                  want = 1;
                 if (len == want)                  if (len == want)
                         tbl->opts.decimal = p[*pos];                          tbl->opts.decimal = p[*pos];
Line 121  arg(struct tbl_node *tbl, int ln, const char *p, int *
Line 103  arg(struct tbl_node *tbl, int ln, const char *p, int *
   
         if (len == 0)          if (len == 0)
                 mandoc_msg(MANDOCERR_TBLOPT_NOARG,                  mandoc_msg(MANDOCERR_TBLOPT_NOARG,
                     tbl->parse, ln, *pos, optname);                      tbl->parse, ln, *pos, keys[key].name);
         else if (want && len != want)          else if (want && len != want)
                 mandoc_vmsg(MANDOCERR_TBLOPT_ARGSZ,                  mandoc_vmsg(MANDOCERR_TBLOPT_ARGSZ,
                     tbl->parse, ln, *pos,                      tbl->parse, ln, *pos, "%s want %d have %d",
                     "%s want %d have %d", optname, want, len);                      keys[key].name, want, len);
   
         *pos += len;          *pos += len;
         if (p[*pos] == ')')          if (p[*pos] == ')')
Line 144  tbl_option(struct tbl_node *tbl, int ln, const char *p
Line 126  tbl_option(struct tbl_node *tbl, int ln, const char *p
   
         pos = 0;          pos = 0;
         for (;;) {          for (;;) {
                 while (isspace((unsigned char)p[pos]) || p[pos] == ',')                  while (p[pos] == ' ' || p[pos] == '\t' || p[pos] == ',')
                         pos++;                          pos++;
   
                 if (p[pos] == ';')                  if (p[pos] == ';')
Line 184  tbl_option(struct tbl_node *tbl, int ln, const char *p
Line 166  tbl_option(struct tbl_node *tbl, int ln, const char *p
                 if (keys[i].key)                  if (keys[i].key)
                         tbl->opts.opts |= keys[i].key;                          tbl->opts.opts |= keys[i].key;
                 else                  else
                         arg(tbl, ln, p, &pos, keys[i].ident);                          arg(tbl, ln, p, &pos, i);
         }          }
 }  }

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

CVSweb