/[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 1413 by ph10, Sun Dec 15 17:01:46 2013 UTC revision 1414 by zherczeg, Sun Dec 22 16:27:35 2013 UTC
# Line 4105  add_to_class(pcre_uint8 *classbits, pcre Line 4105  add_to_class(pcre_uint8 *classbits, pcre
4105    compile_data *cd, pcre_uint32 start, pcre_uint32 end)    compile_data *cd, pcre_uint32 start, pcre_uint32 end)
4106  {  {
4107  pcre_uint32 c;  pcre_uint32 c;
4108    pcre_uint32 classbits_end = (end <= 0xff ? end : 0xff);
4109  int n8 = 0;  int n8 = 0;
4110    
4111  /* If caseless matching is required, scan the range and process alternate  /* If caseless matching is required, scan the range and process alternate
# Line 4148  if ((options & PCRE_CASELESS) != 0) Line 4149  if ((options & PCRE_CASELESS) != 0)
4149    
4150    /* Not UTF-mode, or no UCP */    /* Not UTF-mode, or no UCP */
4151    
4152    for (c = start; c <= end && c < 256; c++)    for (c = start; c <= classbits_end; c++)
4153      {      {
4154      SETBIT(classbits, cd->fcc[c]);      SETBIT(classbits, cd->fcc[c]);
4155      n8++;      n8++;
# Line 4173  in all cases. */ Line 4174  in all cases. */
4174    
4175  #endif /* COMPILE_PCRE[8|16] */  #endif /* COMPILE_PCRE[8|16] */
4176    
4177  /* If all characters are less than 256, use the bit map. Otherwise use extra  /* Use the bitmap for characters < 256. Otherwise use extra data.*/
 data. */  
4178    
4179  if (end < 0x100)  for (c = start; c <= classbits_end; c++)
4180    {    {
4181    for (c = start; c <= end; c++)    /* Regardless of start, c will always be <= 255. */
4182      {    SETBIT(classbits, c);
4183      n8++;    n8++;
     SETBIT(classbits, c);  
     }  
4184    }    }
4185    
4186  else  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
4187    {  if (start <= 0xff) start = 0xff + 1;
4188    
4189    if (end >= start) {
4190    pcre_uchar *uchardata = *uchardptr;    pcre_uchar *uchardata = *uchardptr;
4191    
4192  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
# Line 4228  else Line 4228  else
4228    
4229    *uchardptr = uchardata;   /* Updata extra data pointer */    *uchardptr = uchardata;   /* Updata extra data pointer */
4230    }    }
4231    #endif /* SUPPORT_UTF || !COMPILE_PCRE8 */
4232    
4233  return n8;    /* Number of 8-bit characters */  return n8;    /* Number of 8-bit characters */
4234  }  }
# Line 4449  for (;; ptr++) Line 4450  for (;; ptr++)
4450    BOOL reset_bracount;    BOOL reset_bracount;
4451    int class_has_8bitchar;    int class_has_8bitchar;
4452    int class_one_char;    int class_one_char;
4453    #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
4454      BOOL xclass_has_prop;
4455    #endif
4456    int newoptions;    int newoptions;
4457    int recno;    int recno;
4458    int refsign;    int refsign;
# Line 4783  for (;; ptr++) Line 4787  for (;; ptr++)
4787    
4788      should_flip_negation = FALSE;      should_flip_negation = FALSE;
4789    
4790        /* Extended class (xclass) will be used when characters > 255
4791        might match. */
4792    
4793    #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
4794        xclass = FALSE;
4795        class_uchardata = code + LINK_SIZE + 2;   /* For XCLASS items */
4796        class_uchardata_base = class_uchardata;   /* Save the start */
4797    #endif
4798    
4799      /* For optimization purposes, we track some properties of the class:      /* For optimization purposes, we track some properties of the class:
4800      class_has_8bitchar will be non-zero if the class contains at least one <      class_has_8bitchar will be non-zero if the class contains at least one <
4801      256 character; class_one_char will be 1 if the class contains just one      256 character; class_one_char will be 1 if the class contains just one
4802      character. */      character; xclass_has_prop will be TRUE if unicode property checks
4803        are present in the class. */
4804    
4805      class_has_8bitchar = 0;      class_has_8bitchar = 0;
4806      class_one_char = 0;      class_one_char = 0;
4807    #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
4808        xclass_has_prop = FALSE;
4809    #endif
4810    
4811      /* Initialize the 32-char bit map to all zeros. We build the map in a      /* Initialize the 32-char bit map to all zeros. We build the map in a
4812      temporary bit of memory, in case the class contains fewer than two      temporary bit of memory, in case the class contains fewer than two
# Line 4798  for (;; ptr++) Line 4815  for (;; ptr++)
4815    
4816      memset(classbits, 0, 32 * sizeof(pcre_uint8));      memset(classbits, 0, 32 * sizeof(pcre_uint8));
4817    
 #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  
     xclass = FALSE;  
     class_uchardata = code + LINK_SIZE + 2;   /* For XCLASS items */  
     class_uchardata_base = class_uchardata;   /* Save the start */  
 #endif  
   
4818      /* Process characters until ] is reached. By writing this as a "do" it      /* Process characters until ] is reached. By writing this as a "do" it
4819      means that an initial ] is taken as a data character. At the start of the      means that an initial ] is taken as a data character. At the start of the
4820      loop, c contains the first byte of the character. */      loop, c contains the first byte of the character. */
# Line 4927  for (;; ptr++) Line 4938  for (;; ptr++)
4938              *class_uchardata++ = local_negate? XCL_NOTPROP : XCL_PROP;              *class_uchardata++ = local_negate? XCL_NOTPROP : XCL_PROP;
4939              *class_uchardata++ = ptype;              *class_uchardata++ = ptype;
4940              *class_uchardata++ = 0;              *class_uchardata++ = 0;
4941                xclass_has_prop = TRUE;
4942              ptr = tempptr + 1;              ptr = tempptr + 1;
4943              continue;              continue;
4944    
# Line 5109  for (;; ptr++) Line 5121  for (;; ptr++)
5121                  XCL_PROP : XCL_NOTPROP;                  XCL_PROP : XCL_NOTPROP;
5122                *class_uchardata++ = ptype;                *class_uchardata++ = ptype;
5123                *class_uchardata++ = pdata;                *class_uchardata++ = pdata;
5124                  xclass_has_prop = TRUE;
5125                class_has_8bitchar--;                /* Undo! */                class_has_8bitchar--;                /* Undo! */
5126                continue;                continue;
5127                }                }
# Line 5403  for (;; ptr++) Line 5416  for (;; ptr++)
5416        *code++ = OP_XCLASS;        *code++ = OP_XCLASS;
5417        code += LINK_SIZE;        code += LINK_SIZE;
5418        *code = negate_class? XCL_NOT:0;        *code = negate_class? XCL_NOT:0;
5419          if (xclass_has_prop) *code |= XCL_HASPROP;
5420    
5421        /* If the map is required, move up the extra data to make room for it;        /* If the map is required, move up the extra data to make room for it;
5422        otherwise just move the code pointer to the end of the extra data. */        otherwise just move the code pointer to the end of the extra data. */
# Line 5412  for (;; ptr++) Line 5426  for (;; ptr++)
5426          *code++ |= XCL_MAP;          *code++ |= XCL_MAP;
5427          memmove(code + (32 / sizeof(pcre_uchar)), code,          memmove(code + (32 / sizeof(pcre_uchar)), code,
5428            IN_UCHARS(class_uchardata - code));            IN_UCHARS(class_uchardata - code));
5429            if (negate_class && !xclass_has_prop)
5430              for (c = 0; c < 32; c++) classbits[c] = ~classbits[c];
5431          memcpy(code, classbits, 32);          memcpy(code, classbits, 32);
5432          code = class_uchardata + (32 / sizeof(pcre_uchar));          code = class_uchardata + (32 / sizeof(pcre_uchar));
5433          }          }

Legend:
Removed from v.1413  
changed lines
  Added in v.1414

  ViewVC Help
Powered by ViewVC 1.1.5