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

Diff for /mandoc/eqn.c between version 1.10 and 1.11

version 1.10, 2011/07/17 14:15:11 version 1.11, 2011/07/18 13:35:07
Line 28 
Line 28 
 #include "libmandoc.h"  #include "libmandoc.h"
 #include "libroff.h"  #include "libroff.h"
   
   #define EQN_NEST_MAX     128 /* maximum nesting of defines */
   
 #define EQN_ARGS         struct eqn_node *ep, \  #define EQN_ARGS         struct eqn_node *ep, \
                          int ln, \                           int ln, \
                          int pos, \                           int pos, \
Line 46  enum eqnpartt {
Line 48  enum eqnpartt {
         EQN__MAX          EQN__MAX
 };  };
   
   static  void             eqn_append(struct eqn_node *,
                                   struct mparse *, int,
                                   int, const char *, int);
 static  int              eqn_do_define(EQN_ARGS);  static  int              eqn_do_define(EQN_ARGS);
 static  int              eqn_do_set(EQN_ARGS);  static  int              eqn_do_ign2(EQN_ARGS);
 static  int              eqn_do_undef(EQN_ARGS);  static  int              eqn_do_undef(EQN_ARGS);
 static  const char      *eqn_nexttok(struct mparse *, int, int,  static  const char      *eqn_nexttok(struct mparse *, int, int,
                                 const char **, size_t *);                                  const char **, size_t *);
   
 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_set }, /* EQN_SET */          { "set", 3, eqn_do_ign2 }, /* EQN_SET */
         { "undef", 5, eqn_do_undef }, /* EQN_UNDEF */          { "undef", 5, eqn_do_undef }, /* EQN_UNDEF */
 };  };
   
Line 101  eqn_read(struct eqn_node **epp, int ln, 
Line 106  eqn_read(struct eqn_node **epp, int ln, 
                 return(ROFF_RERUN);                  return(ROFF_RERUN);
         }          }
   
         end = p + pos;          eqn_append(ep, mp, ln, pos, p + pos, 0);
           return(ROFF_IGN);
   }
   
   static void
   eqn_append(struct eqn_node *ep, struct mparse *mp,
                   int ln, int pos, const char *end, int re)
   {
           const char      *start;
           size_t           sz;
           int              i;
   
           if (re >= EQN_NEST_MAX) {
                   mandoc_msg(MANDOCERR_BADQUOTE, mp, ln, pos, NULL);
                   return;
           }
   
         while (NULL != (start = eqn_nexttok(mp, ln, pos, &end, &sz))) {          while (NULL != (start = eqn_nexttok(mp, ln, pos, &end, &sz))) {
                 if (0 == sz)                  if (0 == sz)
                         continue;                          continue;
   
                 for (i = 0; i < (int)ep->defsz; i++) {                  for (i = 0; i < (int)ep->defsz; i++) {
                         if (0 == ep->defs[i].keysz)                          if (0 == ep->defs[i].keysz)
                                 continue;                                  continue;
Line 115  eqn_read(struct eqn_node **epp, int ln, 
Line 135  eqn_read(struct eqn_node **epp, int ln, 
                                 continue;                                  continue;
                         start = ep->defs[i].val;                          start = ep->defs[i].val;
                         sz = ep->defs[i].valsz;                          sz = ep->defs[i].valsz;
   
                           eqn_append(ep, mp, ln, pos, start, re + 1);
                         break;                          break;
                 }                  }
                   if (i < (int)ep->defsz)
                           continue;
   
                 ep->eqn.data = mandoc_realloc                  ep->eqn.data = mandoc_realloc
                         (ep->eqn.data, ep->eqn.sz + sz + 1);                          (ep->eqn.data, ep->eqn.sz + sz + 1);
Line 127  eqn_read(struct eqn_node **epp, int ln, 
Line 151  eqn_read(struct eqn_node **epp, int ln, 
                 ep->eqn.sz += sz;                  ep->eqn.sz += sz;
                 strlcat(ep->eqn.data, start, ep->eqn.sz + 1);                  strlcat(ep->eqn.data, start, ep->eqn.sz + 1);
         }          }
   
         return(ROFF_IGN);  
 }  }
   
 struct eqn_node *  struct eqn_node *
Line 217  eqn_nexttok(struct mparse *mp, int ln, int pos,
Line 239  eqn_nexttok(struct mparse *mp, int ln, int pos,
 }  }
   
 static int  static int
 eqn_do_set(struct eqn_node *ep, int ln, int pos, const char **end)  eqn_do_ign2(struct eqn_node *ep, int ln, int pos, const char **end)
 {  {
         const char      *start;          const char      *start;
         struct mparse   *mp;          struct mparse   *mp;

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

CVSweb