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

Diff for /mandoc/roff.c between version 1.183 and 1.184

version 1.183, 2013/10/05 22:21:20 version 1.184, 2013/10/05 22:25:12
Line 185  static void   roff_free1(struct roff *);
Line 185  static void   roff_free1(struct roff *);
 static  void             roff_freereg(struct roffreg *);  static  void             roff_freereg(struct roffreg *);
 static  void             roff_freestr(struct roffkv *);  static  void             roff_freestr(struct roffkv *);
 static  char            *roff_getname(struct roff *, char **, int, int);  static  char            *roff_getname(struct roff *, char **, int, int);
   static  int              roff_getnum(const char *, int *, int *);
   static  int              roff_getop(const char *, int *, char *);
 static  int              roff_getregn(const struct roff *,  static  int              roff_getregn(const struct roff *,
                                 const char *, size_t);                                  const char *, size_t);
 static  const char      *roff_getstrn(const struct roff *,  static  const char      *roff_getstrn(const struct roff *,
Line 1125  roff_cond_text(ROFF_ARGS)
Line 1127  roff_cond_text(ROFF_ARGS)
         return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT);          return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT);
 }  }
   
   static int
   roff_getnum(const char *v, int *pos, int *res)
   {
           int p, n;
   
           p = *pos;
           n = v[p] == '-';
           if (n)
                   p++;
   
           for (*res = 0; isdigit((unsigned char)v[p]); p++)
                   *res += 10 * *res + v[p] - '0';
           if (p == *pos + n)
                   return 0;
   
           if (n)
                   *res = -*res;
   
           *pos = p;
           return 1;
   }
   
   static int
   roff_getop(const char *v, int *pos, char *res)
   {
           int e;
   
           *res = v[*pos];
           e = v[*pos + 1] == '=';
   
           switch (*res) {
           case '=':
                   break;
           case '>':
                   if (e)
                           *res = 'g';
                   break;
           case '<':
                   if (e)
                           *res = 'l';
                   break;
           default:
                   return(0);
           }
   
           *pos += 1 + e;
   
           return(*res);
   }
   
 static enum roffrule  static enum roffrule
 roff_evalcond(const char *v, int *pos)  roff_evalcond(const char *v, int *pos)
 {  {
           int      not, lh, rh;
           char     op;
   
         switch (v[*pos]) {          switch (v[*pos]) {
         case ('n'):          case ('n'):
Line 1140  roff_evalcond(const char *v, int *pos)
Line 1194  roff_evalcond(const char *v, int *pos)
         case ('t'):          case ('t'):
                 (*pos)++;                  (*pos)++;
                 return(ROFFRULE_DENY);                  return(ROFFRULE_DENY);
           case ('!'):
                   (*pos)++;
                   not = 1;
                   break;
         default:          default:
                   not = 0;
                 break;                  break;
         }          }
   
         while (v[*pos] && ' ' != v[*pos])          if (!roff_getnum(v, pos, &lh))
                 (*pos)++;                  return ROFFRULE_DENY;
         return(ROFFRULE_DENY);          if (!roff_getop(v, pos, &op)) {
                   if (lh < 0)
                           lh = 0;
                   goto out;
           }
           if (!roff_getnum(v, pos, &rh))
                   return ROFFRULE_DENY;
           switch (op) {
           case 'g':
                   lh = lh >= rh;
                   break;
           case 'l':
                   lh = lh <= rh;
                   break;
           case '=':
                   lh = lh == rh;
                   break;
           case '>':
                   lh = lh > rh;
                   break;
           case '<':
                   lh = lh < rh;
                   break;
           default:
                   return ROFFRULE_DENY;
           }
   out:
           if (not)
                   lh = !lh;
           return lh ? ROFFRULE_ALLOW : ROFFRULE_DENY;
 }  }
   
 /* ARGSUSED */  /* ARGSUSED */

Legend:
Removed from v.1.183  
changed lines
  Added in v.1.184

CVSweb