/[pcre]/code/trunk/pcre_compile.c
ViewVC logotype

Diff of /code/trunk/pcre_compile.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1380 by ph10, Tue Oct 15 16:49:12 2013 UTC revision 1381 by zherczeg, Wed Oct 16 06:23:00 2013 UTC
# Line 3041  const pcre_uint32* list_ptr; Line 3041  const pcre_uint32* list_ptr;
3041  const pcre_uchar *next_code;  const pcre_uchar *next_code;
3042  const pcre_uint8 *class_bits;  const pcre_uint8 *class_bits;
3043  pcre_uint32 chr;  pcre_uint32 chr;
3044    BOOL accepted;
3045    
3046  /* Note: the base_list[1] contains whether the current opcode has greedy  /* Note: the base_list[1] contains whether the current opcode has greedy
3047  (represented by a non-zero value) quantifier. This is a different from  (represented by a non-zero value) quantifier. This is a different from
# Line 3169  for(;;) Line 3170  for(;;)
3170      {      {
3171      pcre_uint32 leftop, rightop;      pcre_uint32 leftop, rightop;
3172    
     if (list[1] != 0) return FALSE;   /* Must match at least one character */  
3173      leftop = base_list[0];      leftop = base_list[0];
3174      rightop = list[0];      rightop = list[0];
3175    
3176  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3177        accepted = FALSE; /* Always set in non-unicode case. */
3178      if (leftop == OP_PROP || leftop == OP_NOTPROP)      if (leftop == OP_PROP || leftop == OP_NOTPROP)
3179        {        {
3180        if (rightop == OP_EOD) return TRUE;        if (rightop == OP_EOD)
3181        if (rightop == OP_PROP || rightop == OP_NOTPROP)          accepted = TRUE;
3182          else if (rightop == OP_PROP || rightop == OP_NOTPROP)
3183          {          {
3184          int n;          int n;
3185          const pcre_uint8 *p;          const pcre_uint8 *p;
# Line 3198  for(;;) Line 3200  for(;;)
3200          n = propposstab[base_list[2]][list[2]];          n = propposstab[base_list[2]][list[2]];
3201          switch(n)          switch(n)
3202            {            {
3203            case 0: return FALSE;            case 0: break;
3204            case 1: return bothprop;            case 1: accepted = bothprop; break;
3205            case 2: return (base_list[3] == list[3]) != same;            case 2: accepted = (base_list[3] == list[3]) != same; break;
3206            case 3: return !same;            case 3: accepted = !same; break;
3207    
3208            case 4:  /* Left general category, right particular category */            case 4:  /* Left general category, right particular category */
3209            return risprop && catposstab[base_list[3]][list[3]] == same;            accepted = risprop && catposstab[base_list[3]][list[3]] == same;
3210              break;
3211    
3212            case 5:  /* Right general category, left particular category */            case 5:  /* Right general category, left particular category */
3213            return lisprop && catposstab[list[3]][base_list[3]] == same;            accepted = lisprop && catposstab[list[3]][base_list[3]] == same;
3214              break;
3215    
3216            /* This code is logically tricky. Think hard before fiddling with it.            /* This code is logically tricky. Think hard before fiddling with it.
3217            The posspropstab table has four entries per row. Each row relates to            The posspropstab table has four entries per row. Each row relates to
# Line 3232  for(;;) Line 3236  for(;;)
3236            case 7:  /* Left space vs right general category */            case 7:  /* Left space vs right general category */
3237            case 8:  /* Left word vs right general category */            case 8:  /* Left word vs right general category */
3238            p = posspropstab[n-6];            p = posspropstab[n-6];
3239            return risprop && lisprop ==            accepted = risprop && lisprop ==
3240              (list[3] != p[0] &&              (list[3] != p[0] &&
3241               list[3] != p[1] &&               list[3] != p[1] &&
3242              (list[3] != p[2] || !lisprop));              (list[3] != p[2] || !lisprop));
3243              break;
3244    
3245            case 9:   /* Right alphanum vs left general category */            case 9:   /* Right alphanum vs left general category */
3246            case 10:  /* Right space vs left general category */            case 10:  /* Right space vs left general category */
3247            case 11:  /* Right word vs left general category */            case 11:  /* Right word vs left general category */
3248            p = posspropstab[n-9];            p = posspropstab[n-9];
3249            return lisprop && risprop ==            accepted = lisprop && risprop ==
3250              (base_list[3] != p[0] &&              (base_list[3] != p[0] &&
3251               base_list[3] != p[1] &&               base_list[3] != p[1] &&
3252              (base_list[3] != p[2] || !risprop));              (base_list[3] != p[2] || !risprop));
3253              break;
3254    
3255            case 12:  /* Left alphanum vs right particular category */            case 12:  /* Left alphanum vs right particular category */
3256            case 13:  /* Left space vs right particular category */            case 13:  /* Left space vs right particular category */
3257            case 14:  /* Left word vs right particular category */            case 14:  /* Left word vs right particular category */
3258            p = posspropstab[n-12];            p = posspropstab[n-12];
3259            return risprop && lisprop ==            accepted = risprop && lisprop ==
3260              (catposstab[p[0]][list[3]] &&              (catposstab[p[0]][list[3]] &&
3261               catposstab[p[1]][list[3]] &&               catposstab[p[1]][list[3]] &&
3262              (list[3] != p[3] || !lisprop));              (list[3] != p[3] || !lisprop));
3263              break;
3264    
3265            case 15:  /* Right alphanum vs left particular category */            case 15:  /* Right alphanum vs left particular category */
3266            case 16:  /* Right space vs left particular category */            case 16:  /* Right space vs left particular category */
3267            case 17:  /* Right word vs left particular category */            case 17:  /* Right word vs left particular category */
3268            p = posspropstab[n-15];            p = posspropstab[n-15];
3269            return lisprop && risprop ==            accepted = lisprop && risprop ==
3270              (catposstab[p[0]][base_list[3]] &&              (catposstab[p[0]][base_list[3]] &&
3271               catposstab[p[1]][base_list[3]] &&               catposstab[p[1]][base_list[3]] &&
3272              (base_list[3] != p[3] || !risprop));              (base_list[3] != p[3] || !risprop));
3273              break;
3274            }            }
3275          }          }
       return FALSE;  
3276        }        }
3277    
3278      else      else
3279  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
3280    
3281      return leftop >= FIRST_AUTOTAB_OP && leftop <= LAST_AUTOTAB_LEFT_OP &&      accepted = leftop >= FIRST_AUTOTAB_OP && leftop <= LAST_AUTOTAB_LEFT_OP &&
3282             rightop >= FIRST_AUTOTAB_OP && rightop <= LAST_AUTOTAB_RIGHT_OP &&             rightop >= FIRST_AUTOTAB_OP && rightop <= LAST_AUTOTAB_RIGHT_OP &&
3283             autoposstab[leftop - FIRST_AUTOTAB_OP][rightop - FIRST_AUTOTAB_OP];             autoposstab[leftop - FIRST_AUTOTAB_OP][rightop - FIRST_AUTOTAB_OP];
3284    
3285        if (!accepted)
3286          return FALSE;
3287    
3288        if (list[1] == 0) return TRUE;
3289        /* Might be an empty repeat. */
3290        continue;
3291      }      }
3292    
3293    /* Control reaches here only if one of the items is a small character list.    /* Control reaches here only if one of the items is a small character list.
# Line 3449  Returns:      nothing Line 3463  Returns:      nothing
3463  static void  static void
3464  auto_possessify(pcre_uchar *code, BOOL utf, const compile_data *cd)  auto_possessify(pcre_uchar *code, BOOL utf, const compile_data *cd)
3465  {  {
3466  register pcre_uchar c, d;  register pcre_uchar c;
3467  const pcre_uchar *end;  const pcre_uchar *end;
3468  pcre_uchar *repeat_code;  pcre_uchar *repeat_code;
3469  pcre_uint32 list[8];  pcre_uint32 list[8];
# Line 3513  for (;;) Line 3527  for (;;)
3527  #endif  #endif
3528        repeat_code = code + 1 + (32 / sizeof(pcre_uchar));        repeat_code = code + 1 + (32 / sizeof(pcre_uchar));
3529    
3530      d = *repeat_code;      c = *repeat_code;
3531      if (d >= OP_CRSTAR && d <= OP_CRMINRANGE)      if (c >= OP_CRSTAR && c <= OP_CRMINRANGE)
3532        {        {
3533        /* end must not be NULL. */        /* end must not be NULL. */
3534        end = get_chr_property_list(code, utf, cd->fcc, list);        end = get_chr_property_list(code, utf, cd->fcc, list);
3535    
3536        list[1] = d == OP_CRSTAR || d == OP_CRPLUS || d == OP_CRQUERY ||        list[1] = (c & 1) == 0;
         d == OP_CRRANGE;  
3537    
3538        if (compare_opcodes(end, utf, cd, list, end))        if (compare_opcodes(end, utf, cd, list, end))
3539          {          {
3540          switch (d)          switch (c)
3541            {            {
3542            case OP_CRSTAR:            case OP_CRSTAR:
3543            *repeat_code = OP_CRPOSSTAR;            *repeat_code = OP_CRPOSSTAR;
# Line 3544  for (;;) Line 3557  for (;;)
3557            }            }
3558          }          }
3559        }        }
3560        c = *code;
3561      }      }
3562    
3563    switch(c)    switch(c)

Legend:
Removed from v.1380  
changed lines
  Added in v.1381

  ViewVC Help
Powered by ViewVC 1.1.5