/[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 1078 by chpe, Tue Oct 16 15:55:00 2012 UTC revision 1130 by chpe, Thu Oct 18 18:35:15 2012 UTC
# Line 1203  escape sequence. Line 1203  escape sequence.
1203  Argument:  Argument:
1204    ptrptr         points to the pattern position pointer    ptrptr         points to the pattern position pointer
1205    negptr         points to a boolean that is set TRUE for negation else FALSE    negptr         points to a boolean that is set TRUE for negation else FALSE
1206    dptr           points to an int that is set to the detailed property value    ptypeptr       points to an unsigned int that is set to the type value
1207      pdataptr       points to an unsigned int that is set to the detailed property value
1208    errorcodeptr   points to the error code variable    errorcodeptr   points to the error code variable
1209    
1210  Returns:         type value from ucp_type_table, or -1 for an invalid type  Returns:         TRUE if the type value was found, or FALSE for an invalid type
1211  */  */
1212    
1213  static int  static BOOL
1214  get_ucp(const pcre_uchar **ptrptr, BOOL *negptr, int *dptr, int *errorcodeptr)  get_ucp(const pcre_uchar **ptrptr, BOOL *negptr, unsigned int *ptypeptr,
1215      unsigned int *pdataptr, int *errorcodeptr)
1216  {  {
1217  pcre_uchar c;  pcre_uchar c;
1218  int i, bot, top;  int i, bot, top;
# Line 1265  while (bot < top) Line 1267  while (bot < top)
1267    r = STRCMP_UC_C8(name, PRIV(utt_names) + PRIV(utt)[i].name_offset);    r = STRCMP_UC_C8(name, PRIV(utt_names) + PRIV(utt)[i].name_offset);
1268    if (r == 0)    if (r == 0)
1269      {      {
1270      *dptr = PRIV(utt)[i].value;      *ptypeptr = PRIV(utt)[i].type;
1271      return PRIV(utt)[i].type;      *pdataptr = PRIV(utt)[i].value;
1272        return TRUE;
1273      }      }
1274    if (r > 0) bot = i + 1; else top = i;    if (r > 0) bot = i + 1; else top = i;
1275    }    }
1276    
1277  *errorcodeptr = ERR47;  *errorcodeptr = ERR47;
1278  *ptrptr = ptr;  *ptrptr = ptr;
1279  return -1;  return FALSE;
1280    
1281  ERROR_RETURN:  ERROR_RETURN:
1282  *errorcodeptr = ERR46;  *errorcodeptr = ERR46;
1283  *ptrptr = ptr;  *ptrptr = ptr;
1284  return -1;  return FALSE;
1285  }  }
1286  #endif  #endif
1287    
# Line 1854  for (;;) Line 1857  for (;;)
1857      case OP_NOTI:      case OP_NOTI:
1858      branchlength++;      branchlength++;
1859      cc += 2;      cc += 2;
1860  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
1861      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1862  #endif  #endif
1863      break;      break;
# Line 1868  for (;;) Line 1871  for (;;)
1871      case OP_NOTEXACTI:      case OP_NOTEXACTI:
1872      branchlength += (int)GET2(cc,1);      branchlength += (int)GET2(cc,1);
1873      cc += 2 + IMM2_SIZE;      cc += 2 + IMM2_SIZE;
1874  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
1875      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1876  #endif  #endif
1877      break;      break;
# Line 2966  Returns:       TRUE if auto-possessifyin Line 2969  Returns:       TRUE if auto-possessifyin
2969  */  */
2970    
2971  static BOOL  static BOOL
2972  check_char_prop(pcre_uint32 c, int ptype, int pdata, BOOL negated)  check_char_prop(pcre_uint32 c, unsigned int ptype, unsigned int pdata, BOOL negated)
2973  {  {
2974  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2975  const pcre_uint32 *p;  const pcre_uint32 *p;
# Line 3133  if (*ptr == CHAR_ASTERISK || *ptr == CHA Line 3136  if (*ptr == CHAR_ASTERISK || *ptr == CHA
3136    
3137  if (op_code == OP_CHAR || op_code == OP_CHARI ||  if (op_code == OP_CHAR || op_code == OP_CHARI ||
3138      op_code == OP_NOT || op_code == OP_NOTI)      op_code == OP_NOT || op_code == OP_NOTI)
   //if (escape == 0) switch(op_code)  
3139    {    {
3140  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3141    GETCHARTEST(c, previous);    GETCHARTEST(c, previous);
# Line 3253  if (escape == 0) Line 3255  if (escape == 0)
3255    
3256  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3257      case OP_PROP:      case OP_PROP:
3258      return check_char_prop(next, (int)previous[0], (int)previous[1], FALSE);      return check_char_prop(next, previous[0], previous[1], FALSE);
3259    
3260      case OP_NOTPROP:      case OP_NOTPROP:
3261      return check_char_prop(next, (int)previous[0], (int)previous[1], TRUE);      return check_char_prop(next, previous[0], previous[1], TRUE);
3262  #endif  #endif
3263    
3264      default:      default:
# Line 3339  switch(op_code) Line 3341  switch(op_code)
3341      case ESC_p:      case ESC_p:
3342      case ESC_P:      case ESC_P:
3343        {        {
3344        int ptype, pdata, errorcodeptr;        unsigned int ptype = 0, pdata = 0;
3345          int errorcodeptr;
3346        BOOL negated;        BOOL negated;
3347    
3348        ptr--;      /* Make ptr point at the p or P */        ptr--;      /* Make ptr point at the p or P */
3349        ptype = get_ucp(&ptr, &negated, &pdata, &errorcodeptr);        if (!get_ucp(&ptr, &negated, &ptype, &pdata, &errorcodeptr))
3350        if (ptype < 0) return FALSE;          return FALSE;
3351        ptr++;      /* Point past the final curly ket */        ptr++;      /* Point past the final curly ket */
3352    
3353        /* If the property item is optional, we have to give up. (When generated        /* If the property item is optional, we have to give up. (When generated
# Line 3725  dynamically as we process the pattern. * Line 3728  dynamically as we process the pattern. *
3728  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3729  /* PCRE_UTF[16|32] have the same value as PCRE_UTF8. */  /* PCRE_UTF[16|32] have the same value as PCRE_UTF8. */
3730  BOOL utf = (options & PCRE_UTF8) != 0;  BOOL utf = (options & PCRE_UTF8) != 0;
3731    #ifndef COMPILE_PCRE32
3732  pcre_uchar utf_chars[6];  pcre_uchar utf_chars[6];
3733    #endif
3734  #else  #else
3735  BOOL utf = FALSE;  BOOL utf = FALSE;
3736  #endif  #endif
# Line 4115  for (;; ptr++) Line 4120  for (;; ptr++)
4120        {        {
4121        const pcre_uchar *oldptr;        const pcre_uchar *oldptr;
4122    
4123  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
4124        if (utf && HAS_EXTRALEN(c))        if (utf && HAS_EXTRALEN(c))
4125          {                           /* Braces are required because the */          {                           /* Braces are required because the */
4126          GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */          GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */
# Line 4374  for (;; ptr++) Line 4379  for (;; ptr++)
4379              case ESC_P:              case ESC_P:
4380                {                {
4381                BOOL negated;                BOOL negated;
4382                int pdata;                unsigned int ptype = 0, pdata = 0;
4383                int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);                if (!get_ucp(&ptr, &negated, &ptype, &pdata, errorcodeptr))
4384                if (ptype < 0) goto FAILED;                  goto FAILED;
4385                *class_uchardata++ = ((escape == ESC_p) != negated)?                *class_uchardata++ = ((escape == ESC_p) != negated)?
4386                  XCL_PROP : XCL_NOTPROP;                  XCL_PROP : XCL_NOTPROP;
4387                *class_uchardata++ = ptype;                *class_uchardata++ = ptype;
# Line 5505  for (;; ptr++) Line 5510  for (;; ptr++)
5510        else if (*tempcode == OP_EXACT || *tempcode == OP_NOTEXACT)        else if (*tempcode == OP_EXACT || *tempcode == OP_NOTEXACT)
5511          {          {
5512          tempcode += PRIV(OP_lengths)[*tempcode];          tempcode += PRIV(OP_lengths)[*tempcode];
5513  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
5514          if (utf && HAS_EXTRALEN(tempcode[-1]))          if (utf && HAS_EXTRALEN(tempcode[-1]))
5515            tempcode += GET_EXTRALEN(tempcode[-1]);            tempcode += GET_EXTRALEN(tempcode[-1]);
5516  #endif  #endif
# Line 6873  for (;; ptr++) Line 6878  for (;; ptr++)
6878        else if (escape == ESC_P || escape == ESC_p)        else if (escape == ESC_P || escape == ESC_p)
6879          {          {
6880          BOOL negated;          BOOL negated;
6881          int pdata;          unsigned int ptype = 0, pdata = 0;
6882          int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);          if (!get_ucp(&ptr, &negated, &ptype, &pdata, errorcodeptr))
6883          if (ptype < 0) goto FAILED;            goto FAILED;
6884          previous = code;          previous = code;
6885          *code++ = ((escape == ESC_p) != negated)? OP_PROP : OP_NOTPROP;          *code++ = ((escape == ESC_p) != negated)? OP_PROP : OP_NOTPROP;
6886          *code++ = ptype;          *code++ = ptype;
# Line 6949  for (;; ptr++) Line 6954  for (;; ptr++)
6954      mclength = 1;      mclength = 1;
6955      mcbuffer[0] = c;      mcbuffer[0] = c;
6956    
6957  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
6958      if (utf && HAS_EXTRALEN(c))      if (utf && HAS_EXTRALEN(c))
6959        ACROSSCHAR(TRUE, ptr[1], mcbuffer[mclength++] = *(++ptr));        ACROSSCHAR(TRUE, ptr[1], mcbuffer[mclength++] = *(++ptr));
6960  #endif  #endif
# Line 7643  do { Line 7648  do {
7648               *code == OP_CBRAPOS || *code == OP_SCBRAPOS)? IMM2_SIZE:0;               *code == OP_CBRAPOS || *code == OP_SCBRAPOS)? IMM2_SIZE:0;
7649     const pcre_uchar *scode = first_significant_code(code + 1+LINK_SIZE + xl,     const pcre_uchar *scode = first_significant_code(code + 1+LINK_SIZE + xl,
7650       TRUE);       TRUE);
7651     register int op = *scode;     register pcre_uchar op = *scode;
7652    
7653     switch(op)     switch(op)
7654       {       {

Legend:
Removed from v.1078  
changed lines
  Added in v.1130

  ViewVC Help
Powered by ViewVC 1.1.5