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

Diff for /mandoc/eqn.c between version 1.13 and 1.14

version 1.13, 2011/07/21 11:34:53 version 1.14, 2011/07/21 11:57:56
Line 48  static void   eqn_box_free(struct eqn_box *);
Line 48  static void   eqn_box_free(struct eqn_box *);
 static  struct eqn_def  *eqn_def_find(struct eqn_node *,  static  struct eqn_def  *eqn_def_find(struct eqn_node *,
                                 const char *, size_t);                                  const char *, size_t);
 static  int              eqn_do_define(struct eqn_node *);  static  int              eqn_do_define(struct eqn_node *);
 static  int              eqn_do_ign2(struct eqn_node *);  static  int              eqn_do_set(struct eqn_node *);
 static  int              eqn_do_undef(struct eqn_node *);  static  int              eqn_do_undef(struct eqn_node *);
 static  const char      *eqn_nexttok(struct eqn_node *, size_t *);  static  const char      *eqn_nexttok(struct eqn_node *, size_t *);
 static  const char      *eqn_next(struct eqn_node *, char, size_t *);  static  const char      *eqn_nextrawtok(struct eqn_node *, size_t *);
   static  const char      *eqn_next(struct eqn_node *,
                                   char, size_t *, int);
 static  int              eqn_box(struct eqn_node *, struct eqn_box *);  static  int              eqn_box(struct eqn_node *, struct eqn_box *);
   
 static  const struct eqnpart eqnparts[EQN__MAX] = {  static  const struct eqnpart eqnparts[EQN__MAX] = {
         { "define", 6, eqn_do_define }, /* EQN_DEFINE */          { "define", 6, eqn_do_define }, /* EQN_DEFINE */
         { "set", 3, eqn_do_ign2 }, /* EQN_SET */          { "set", 3, eqn_do_set }, /* EQN_SET */
         { "undef", 5, eqn_do_undef }, /* EQN_UNDEF */          { "undef", 5, eqn_do_undef }, /* EQN_UNDEF */
 };  };
   
Line 206  eqn_box_free(struct eqn_box *bp)
Line 208  eqn_box_free(struct eqn_box *bp)
 }  }
   
 static const char *  static const char *
   eqn_nextrawtok(struct eqn_node *ep, size_t *sz)
   {
   
           return(eqn_next(ep, '"', sz, 0));
   }
   
   static const char *
 eqn_nexttok(struct eqn_node *ep, size_t *sz)  eqn_nexttok(struct eqn_node *ep, size_t *sz)
 {  {
   
         return(eqn_next(ep, '"', sz));          return(eqn_next(ep, '"', sz, 1));
 }  }
   
 static const char *  static const char *
 eqn_next(struct eqn_node *ep, char quote, size_t *sz)  eqn_next(struct eqn_node *ep, char quote, size_t *sz, int repl)
 {  {
         char            *start, *next;          char            *start, *next;
         int              q, diff, lim;          int              q, diff, lim;
Line 265  again:
Line 274  again:
   
         /* Quotes aren't expanded for values. */          /* Quotes aren't expanded for values. */
   
         if (q)          if (q || ! repl)
                 return(start);                  return(start);
   
         if (NULL != (def = eqn_def_find(ep, start, *sz))) {          if (NULL != (def = eqn_def_find(ep, start, *sz))) {
Line 289  again:
Line 298  again:
 }  }
   
 static int  static int
 eqn_do_ign2(struct eqn_node *ep)  eqn_do_set(struct eqn_node *ep)
 {  {
         const char      *start;          const char      *start;
   
         if (NULL == (start = eqn_nexttok(ep, NULL)))          if (NULL == (start = eqn_nextrawtok(ep, NULL)))
                 EQN_MSG(MANDOCERR_EQNARGS, ep);                  EQN_MSG(MANDOCERR_EQNARGS, ep);
         else if (NULL == (start = eqn_nexttok(ep, NULL)))          else if (NULL == (start = eqn_nextrawtok(ep, NULL)))
                 EQN_MSG(MANDOCERR_EQNARGS, ep);                  EQN_MSG(MANDOCERR_EQNARGS, ep);
         else          else
                 return(1);                  return(1);
Line 311  eqn_do_define(struct eqn_node *ep)
Line 320  eqn_do_define(struct eqn_node *ep)
         struct eqn_def  *def;          struct eqn_def  *def;
         int              i;          int              i;
   
         if (NULL == (start = eqn_nexttok(ep, &sz))) {          if (NULL == (start = eqn_nextrawtok(ep, &sz))) {
                 EQN_MSG(MANDOCERR_EQNARGS, ep);                  EQN_MSG(MANDOCERR_EQNARGS, ep);
                 return(0);                  return(0);
         }          }
Line 344  eqn_do_define(struct eqn_node *ep)
Line 353  eqn_do_define(struct eqn_node *ep)
                 def = &ep->defs[i];                  def = &ep->defs[i];
         }          }
   
         start = eqn_next(ep, ep->data[(int)ep->cur], &sz);          start = eqn_next(ep, ep->data[(int)ep->cur], &sz, 0);
   
         if (NULL == start) {          if (NULL == start) {
                 EQN_MSG(MANDOCERR_EQNARGS, ep);                  EQN_MSG(MANDOCERR_EQNARGS, ep);
Line 355  eqn_do_define(struct eqn_node *ep)
Line 364  eqn_do_define(struct eqn_node *ep)
         def->val = mandoc_realloc(def->val, sz + 1);          def->val = mandoc_realloc(def->val, sz + 1);
         memcpy(def->val, start, sz);          memcpy(def->val, start, sz);
         def->val[(int)sz] = '\0';          def->val[(int)sz] = '\0';
   
         /*fprintf(stderr, "Defining: [%s], [%s]\n",  
                         def->key, def->val);*/  
         return(1);          return(1);
 }  }
   
Line 368  eqn_do_undef(struct eqn_node *ep)
Line 374  eqn_do_undef(struct eqn_node *ep)
         struct eqn_def  *def;          struct eqn_def  *def;
         size_t           sz;          size_t           sz;
   
         if (NULL == (start = eqn_nexttok(ep, &sz))) {          if (NULL == (start = eqn_nextrawtok(ep, &sz))) {
                 EQN_MSG(MANDOCERR_EQNARGS, ep);                  EQN_MSG(MANDOCERR_EQNARGS, ep);
                 return(0);                  return(0);
         } else if (NULL != (def = eqn_def_find(ep, start, sz)))          } else if (NULL != (def = eqn_def_find(ep, start, sz)))

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

CVSweb