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

Diff for /mandoc/eqn.c between version 1.21 and 1.23

version 1.21, 2011/07/21 23:42:28 version 1.23, 2011/07/22 09:57:04
Line 56  enum eqnpartt {
Line 56  enum eqnpartt {
         EQN__MAX          EQN__MAX
 };  };
   
   static  enum eqn_rest    eqn_box(struct eqn_node *, struct eqn_box *);
 static  struct eqn_box  *eqn_box_alloc(struct eqn_box *);  static  struct eqn_box  *eqn_box_alloc(struct eqn_box *);
 static  void             eqn_box_free(struct eqn_box *);  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 *,
Line 63  static struct eqn_def *eqn_def_find(struct eqn_node *,
Line 64  static struct eqn_def *eqn_def_find(struct eqn_node *,
 static  int              eqn_do_define(struct eqn_node *);  static  int              eqn_do_define(struct eqn_node *);
 static  int              eqn_do_set(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  enum eqn_rest    eqn_eqn(struct eqn_node *, struct eqn_box *);
   static  enum eqn_rest    eqn_list(struct eqn_node *, struct eqn_box *);
 static  const char      *eqn_nexttok(struct eqn_node *, size_t *);  static  const char      *eqn_nexttok(struct eqn_node *, size_t *);
 static  const char      *eqn_nextrawtok(struct eqn_node *, size_t *);  static  const char      *eqn_nextrawtok(struct eqn_node *, size_t *);
 static  const char      *eqn_next(struct eqn_node *,  static  const char      *eqn_next(struct eqn_node *,
                                 char, size_t *, int);                                  char, size_t *, int);
 static  void             eqn_rewind(struct eqn_node *);  static  void             eqn_rewind(struct eqn_node *);
 static  enum eqn_rest    eqn_eqn(struct eqn_node *, struct eqn_box *);  
 static  enum eqn_rest    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 */
Line 204  eqn_eqn(struct eqn_node *ep, struct eqn_box *last)
Line 205  eqn_eqn(struct eqn_node *ep, struct eqn_box *last)
 }  }
   
 static enum eqn_rest  static enum eqn_rest
   eqn_list(struct eqn_node *ep, struct eqn_box *last)
   {
           struct eqn_box  *bp;
           const char      *start;
           size_t           sz;
           enum eqn_rest    c;
   
           bp = eqn_box_alloc(last);
           bp->type = EQN_LIST;
   
           if (NULL == (start = eqn_nexttok(ep, &sz))) {
                   EQN_MSG(MANDOCERR_EQNEOF, ep);
                   return(EQN_ERR);
           }
           if (1 != sz || strncmp("{", start, 1)) {
                   EQN_MSG(MANDOCERR_EQNSYNT, ep);
                   return(EQN_ERR);
           }
   
           while (EQN_DESCOPE == (c = eqn_eqn(ep, bp))) {
                   eqn_rewind(ep);
                   start = eqn_nexttok(ep, &sz);
                   assert(start);
                   if (5 != sz || strncmp("above", start, 5))
                           break;
                   bp->last->above = 1;
           }
   
           if (EQN_DESCOPE != c) {
                   if (EQN_ERR != c)
                           EQN_MSG(MANDOCERR_EQNSCOPE, ep);
                   return(EQN_ERR);
           }
   
           eqn_rewind(ep);
           start = eqn_nexttok(ep, &sz);
           assert(start);
           if (1 == sz && 0 == strncmp("}", start, 1))
                   return(EQN_OK);
   
           EQN_MSG(MANDOCERR_EQNBADSCOPE, ep);
           return(EQN_ERR);
   }
   
   static enum eqn_rest
 eqn_box(struct eqn_node *ep, struct eqn_box *last)  eqn_box(struct eqn_node *ep, struct eqn_box *last)
 {  {
         size_t           sz;          size_t           sz;
Line 251  eqn_box(struct eqn_node *ep, struct eqn_box *last)
Line 297  eqn_box(struct eqn_node *ep, struct eqn_box *last)
                         continue;                          continue;
                 if (strncmp(eqnpiles[i].name, start, sz))                  if (strncmp(eqnpiles[i].name, start, sz))
                         continue;                          continue;
                 if (NULL == (start = eqn_nexttok(ep, &sz))) {                  if (EQN_OK == (c = eqn_list(ep, last)))
                         EQN_MSG(MANDOCERR_EQNEOF, ep);  
                         return(EQN_ERR);  
                 }  
                 if (1 != sz || strncmp("{", start, 1)) {  
                         EQN_MSG(MANDOCERR_EQNSYNT, ep);  
                         return(EQN_ERR);  
                 }  
   
                 while (EQN_DESCOPE == (c = eqn_eqn(ep, last))) {  
                         assert(last->last);  
                         last->last->pile = (enum eqn_pilet)i;                          last->last->pile = (enum eqn_pilet)i;
                         eqn_rewind(ep);                  return(c);
                         start = eqn_nexttok(ep, &sz);  
                         assert(start);  
                         if (5 != sz || strncmp("above", start, 5))  
                                 break;  
                         last->last->above = 1;  
                 }  
   
                 if (EQN_DESCOPE != c) {  
                         if (EQN_ERR != c)  
                                 EQN_MSG(MANDOCERR_EQNSCOPE, ep);  
                         return(EQN_ERR);  
                 }  
   
                 eqn_rewind(ep);  
                 start = eqn_nexttok(ep, &sz);  
                 assert(start);  
                 if (1 == sz && 0 == strncmp("}", start, 1))  
                         return(EQN_OK);  
   
                 EQN_MSG(MANDOCERR_EQNBADSCOPE, ep);  
                 return(EQN_ERR);  
         }          }
   
         if (4 == sz && 0 == strncmp("left", start, 4)) {          if (4 == sz && 0 == strncmp("left", start, 4)) {
Line 453  eqn_next(struct eqn_node *ep, char quote, size_t *sz, 
Line 468  eqn_next(struct eqn_node *ep, char quote, size_t *sz, 
 {  {
         char            *start, *next;          char            *start, *next;
         int              q, diff, lim;          int              q, diff, lim;
         size_t           ssz;          size_t           ssz, dummy;
         struct eqn_def  *def;          struct eqn_def  *def;
   
         if (NULL == sz)          if (NULL == sz)
                 sz = &ssz;                  sz = &dummy;
   
         lim = 0;          lim = 0;
         ep->rew = ep->cur;          ep->rew = ep->cur;
Line 482  again:
Line 497  again:
         }          }
   
         start = &ep->data[(int)ep->cur];          start = &ep->data[(int)ep->cur];
         next = q ? strchr(start, quote) : strchr(start, ' ');  
   
           if ( ! q) {
                   if ('{' == *start || '}' == *start)
                           ssz = 1;
                   else
                           ssz = strcspn(start + 1, " ~\"{}\t") + 1;
                   next = start + (int)ssz;
                   if ('\0' == *next)
                           next = NULL;
           } else
                   next = strchr(start, quote);
   
         if (NULL != next) {          if (NULL != next) {
                 *sz = (size_t)(next - start);                  *sz = (size_t)(next - start);
                 ep->cur += *sz;                  ep->cur += *sz;
                 if (q)                  if (q)
                         ep->cur++;                          ep->cur++;
                 while (' ' == ep->data[(int)ep->cur])                  while (' ' == ep->data[(int)ep->cur] ||
                                   '\t' == ep->data[(int)ep->cur] ||
                                   '~' == ep->data[(int)ep->cur])
                         ep->cur++;                          ep->cur++;
         } else {          } else {
                 if (q)                  if (q)

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.23

CVSweb