/[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 1124 by chpe, Thu Oct 18 18:34:53 2012 UTC revision 1132 by chpe, Thu Oct 18 18:35:22 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 2915  get_othercase_range(pcre_uint32 *cptr, p Line 2918  get_othercase_range(pcre_uint32 *cptr, p
2918    pcre_uint32 *odptr)    pcre_uint32 *odptr)
2919  {  {
2920  pcre_uint32 c, othercase, next;  pcre_uint32 c, othercase, next;
2921  int co;  unsigned int co;
2922    
2923  /* Find the first character that has an other case. If it has multiple other  /* Find the first character that has an other case. If it has multiple other
2924  cases, return its case offset value. */  cases, return its case offset value. */
# Line 2926  for (c = *cptr; c <= d; c++) Line 2929  for (c = *cptr; c <= d; c++)
2929      {      {
2930      *ocptr = c++;   /* Character that has the set */      *ocptr = c++;   /* Character that has the set */
2931      *cptr = c;      /* Rest of input range */      *cptr = c;      /* Rest of input range */
2932      return co;      return (int)co;
2933      }      }
2934    if ((othercase = UCD_OTHERCASE(c)) != c) break;    if ((othercase = UCD_OTHERCASE(c)) != c) break;
2935    }    }
# 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 3152  if (escape == 0) Line 3155  if (escape == 0)
3155  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3156    if (utf && c != NOTACHAR && (options & PCRE_CASELESS) != 0)    if (utf && c != NOTACHAR && (options & PCRE_CASELESS) != 0)
3157      {      {
3158      int ocs = UCD_CASESET(next);      unsigned int ocs = UCD_CASESET(next);
3159      if (ocs > 0) return check_char_prop(c, PT_CLIST, ocs, op_code >= OP_NOT);      if (ocs > 0) return check_char_prop(c, PT_CLIST, ocs, op_code >= OP_NOT);
3160      }      }
3161  #endif  #endif
# Line 3252  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 3338  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 4375  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 5818  for (;; ptr++) Line 5822  for (;; ptr++)
5822            }            }
5823          namelen = (int)(ptr - name);          namelen = (int)(ptr - name);
5824    
5825          if ((terminator > 0 && *ptr++ != terminator) ||          if ((terminator > 0 && *ptr++ != (pcre_uchar)terminator) ||
5826              *ptr++ != CHAR_RIGHT_PARENTHESIS)              *ptr++ != CHAR_RIGHT_PARENTHESIS)
5827            {            {
5828            ptr--;      /* Error offset */            ptr--;      /* Error offset */
# Line 6058  for (;; ptr++) Line 6062  for (;; ptr++)
6062    
6063            if (lengthptr != NULL)            if (lengthptr != NULL)
6064              {              {
6065              if (*ptr != terminator)              if (*ptr != (pcre_uchar)terminator)
6066                {                {
6067                *errorcodeptr = ERR42;                *errorcodeptr = ERR42;
6068                goto FAILED;                goto FAILED;
# Line 6200  for (;; ptr++) Line 6204  for (;; ptr++)
6204              *errorcodeptr = ERR62;              *errorcodeptr = ERR62;
6205              goto FAILED;              goto FAILED;
6206              }              }
6207            if (*ptr != terminator)            if (*ptr != (pcre_uchar)terminator)
6208              {              {
6209              *errorcodeptr = ERR42;              *errorcodeptr = ERR42;
6210              goto FAILED;              goto FAILED;
# Line 6306  for (;; ptr++) Line 6310  for (;; ptr++)
6310            while(IS_DIGIT(*ptr))            while(IS_DIGIT(*ptr))
6311              recno = recno * 10 + *ptr++ - CHAR_0;              recno = recno * 10 + *ptr++ - CHAR_0;
6312    
6313            if (*ptr != terminator)            if (*ptr != (pcre_uchar)terminator)
6314              {              {
6315              *errorcodeptr = ERR29;              *errorcodeptr = ERR29;
6316              goto FAILED;              goto FAILED;
# Line 6786  for (;; ptr++) Line 6790  for (;; ptr++)
6790          if (ptr[1] != CHAR_PLUS && ptr[1] != CHAR_MINUS)          if (ptr[1] != CHAR_PLUS && ptr[1] != CHAR_MINUS)
6791            {            {
6792            BOOL is_a_number = TRUE;            BOOL is_a_number = TRUE;
6793            for (p = ptr + 1; *p != 0 && *p != terminator; p++)            for (p = ptr + 1; *p != 0 && *p != (pcre_uchar)terminator; p++)
6794              {              {
6795              if (!MAX_255(*p)) { is_a_number = FALSE; break; }              if (!MAX_255(*p)) { is_a_number = FALSE; break; }
6796              if ((cd->ctypes[*p] & ctype_digit) == 0) is_a_number = FALSE;              if ((cd->ctypes[*p] & ctype_digit) == 0) is_a_number = FALSE;
6797              if ((cd->ctypes[*p] & ctype_word) == 0) break;              if ((cd->ctypes[*p] & ctype_word) == 0) break;
6798              }              }
6799            if (*p != terminator)            if (*p != (pcre_uchar)terminator)
6800              {              {
6801              *errorcodeptr = ERR57;              *errorcodeptr = ERR57;
6802              break;              break;
# Line 6810  for (;; ptr++) Line 6814  for (;; ptr++)
6814    
6815          p = ptr + 2;          p = ptr + 2;
6816          while (IS_DIGIT(*p)) p++;          while (IS_DIGIT(*p)) p++;
6817          if (*p != terminator)          if (*p != (pcre_uchar)terminator)
6818            {            {
6819            *errorcodeptr = ERR57;            *errorcodeptr = ERR57;
6820            break;            break;
# Line 6874  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;

Legend:
Removed from v.1124  
changed lines
  Added in v.1132

  ViewVC Help
Powered by ViewVC 1.1.5