/[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 848 by ph10, Wed Jan 4 16:34:01 2012 UTC revision 905 by zherczeg, Mon Jan 23 19:26:03 2012 UTC
# Line 488  static const char error_texts[] = Line 488  static const char error_texts[] =
488    "\\N is not supported in a class\0"    "\\N is not supported in a class\0"
489    "too many forward references\0"    "too many forward references\0"
490    "disallowed Unicode code point (>= 0xd800 && <= 0xdfff)\0"    "disallowed Unicode code point (>= 0xd800 && <= 0xdfff)\0"
491    "invalid UTF-16 string\0"    "invalid UTF-16 string\0"
492    ;    ;
493    
494  /* Table to identify digits and hex digits. This is used when compiling  /* Table to identify digits and hex digits. This is used when compiling
# Line 991  else Line 991  else
991      /* \0 always starts an octal number, but we may drop through to here with a      /* \0 always starts an octal number, but we may drop through to here with a
992      larger first octal digit. The original code used just to take the least      larger first octal digit. The original code used just to take the least
993      significant 8 bits of octal numbers (I think this is what early Perls used      significant 8 bits of octal numbers (I think this is what early Perls used
994      to do). Nowadays we allow for larger numbers in UTF-8 mode, but no more      to do). Nowadays we allow for larger numbers in UTF-8 mode and 16-bit mode,
995      than 3 octal digits. */      but no more than 3 octal digits. */
996    
997      case CHAR_0:      case CHAR_0:
998      c -= CHAR_0;      c -= CHAR_0;
999      while(i++ < 2 && ptr[1] >= CHAR_0 && ptr[1] <= CHAR_7)      while(i++ < 2 && ptr[1] >= CHAR_0 && ptr[1] <= CHAR_7)
1000          c = c * 8 + *(++ptr) - CHAR_0;          c = c * 8 + *(++ptr) - CHAR_0;
1001    #ifdef COMPILE_PCRE8
1002      if (!utf && c > 0xff) *errorcodeptr = ERR51;      if (!utf && c > 0xff) *errorcodeptr = ERR51;
1003    #endif
1004      break;      break;
1005    
1006      /* \x is complicated. \x{ddd} is a character number which can be greater      /* \x is complicated. \x{ddd} is a character number which can be greater
# Line 3065  if (next >= 0) switch(op_code) Line 3067  if (next >= 0) switch(op_code)
3067      }      }
3068    else    else
3069  #endif  /* SUPPORT_UTF */  #endif  /* SUPPORT_UTF */
3070    return (c != TABLE_GET(next, cd->fcc, next));  /* Non-UTF-8 mode */    return (c != TABLE_GET((unsigned int)next, cd->fcc, next));  /* Non-UTF-8 mode */
3071    
3072    /* For OP_NOT and OP_NOTI, the data is always a single-byte character. These    /* For OP_NOT and OP_NOTI, the data is always a single-byte character. These
3073    opcodes are not used for multi-byte characters, because they are coded using    opcodes are not used for multi-byte characters, because they are coded using
# Line 3090  if (next >= 0) switch(op_code) Line 3092  if (next >= 0) switch(op_code)
3092      }      }
3093    else    else
3094  #endif  /* SUPPORT_UTF */  #endif  /* SUPPORT_UTF */
3095    return (c == TABLE_GET(next, cd->fcc, next));  /* Non-UTF-8 mode */    return (c == (int)(TABLE_GET((unsigned int)next, cd->fcc, next)));  /* Non-UTF-8 mode */
3096    
3097    /* Note that OP_DIGIT etc. are generated only when PCRE_UCP is *not* set.    /* Note that OP_DIGIT etc. are generated only when PCRE_UCP is *not* set.
3098    When it is set, \d etc. are converted into OP_(NOT_)PROP codes. */    When it is set, \d etc. are converted into OP_(NOT_)PROP codes. */
# Line 4569  for (;; ptr++) Line 4571  for (;; ptr++)
4571  #endif  #endif
4572            {            {
4573            unsigned int othercase;            unsigned int othercase;
4574            if ((othercase = UCD_OTHERCASE(c)) != c)            if ((int)(othercase = UCD_OTHERCASE(c)) != c)
4575              {              {
4576              *class_uchardata++ = XCL_SINGLE;              *class_uchardata++ = XCL_SINGLE;
4577              class_uchardata += PRIV(ord2utf)(othercase, class_uchardata);              class_uchardata += PRIV(ord2utf)(othercase, class_uchardata);
# Line 7561  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTIO Line 7563  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTIO
7563  pcre_compile(const char *pattern, int options, const char **errorptr,  pcre_compile(const char *pattern, int options, const char **errorptr,
7564    int *erroroffset, const unsigned char *tables)    int *erroroffset, const unsigned char *tables)
7565  #else  #else
7566  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION
7567  pcre16_compile(PCRE_SPTR16 pattern, int options, const char **errorptr,  pcre16_compile(PCRE_SPTR16 pattern, int options, const char **errorptr,
7568    int *erroroffset, const unsigned char *tables)    int *erroroffset, const unsigned char *tables)
7569  #endif  #endif
# Line 7579  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTIO Line 7581  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTIO
7581  pcre_compile2(const char *pattern, int options, int *errorcodeptr,  pcre_compile2(const char *pattern, int options, int *errorcodeptr,
7582    const char **errorptr, int *erroroffset, const unsigned char *tables)    const char **errorptr, int *erroroffset, const unsigned char *tables)
7583  #else  #else
7584  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION
7585  pcre16_compile2(PCRE_SPTR16 pattern, int options, int *errorcodeptr,  pcre16_compile2(PCRE_SPTR16 pattern, int options, int *errorcodeptr,
7586    const char **errorptr, int *erroroffset, const unsigned char *tables)    const char **errorptr, int *erroroffset, const unsigned char *tables)
7587  #endif  #endif
7588  {  {
7589  real_pcre *re;  REAL_PCRE *re;
7590  int length = 1;  /* For final END opcode */  int length = 1;  /* For final END opcode */
7591  pcre_int32 firstchar, reqchar;  pcre_int32 firstchar, reqchar;
7592  int newline;  int newline;
# Line 7707  not used here. */ Line 7709  not used here. */
7709  if (utf && (options & PCRE_NO_UTF8_CHECK) == 0 &&  if (utf && (options & PCRE_NO_UTF8_CHECK) == 0 &&
7710       (errorcode = PRIV(valid_utf)((PCRE_PUCHAR)pattern, -1, erroroffset)) != 0)       (errorcode = PRIV(valid_utf)((PCRE_PUCHAR)pattern, -1, erroroffset)) != 0)
7711    {    {
7712  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
7713    errorcode = ERR44;    errorcode = ERR44;
7714  #else  #else
7715    errorcode = ERR74;    errorcode = ERR74;
7716  #endif  #endif
7717    goto PCRE_EARLY_ERROR_RETURN2;    goto PCRE_EARLY_ERROR_RETURN2;
7718    }    }
7719  #else  #else
# Line 7846  externally provided function. Integer ov Line 7848  externally provided function. Integer ov
7848  because nowadays we limit the maximum value of cd->names_found and  because nowadays we limit the maximum value of cd->names_found and
7849  cd->name_entry_size. */  cd->name_entry_size. */
7850    
7851  size = sizeof(real_pcre) + (length + cd->names_found * cd->name_entry_size) * sizeof(pcre_uchar);  size = sizeof(REAL_PCRE) + (length + cd->names_found * cd->name_entry_size) * sizeof(pcre_uchar);
7852  re = (real_pcre *)(PUBL(malloc))(size);  re = (REAL_PCRE *)(PUBL(malloc))(size);
7853    
7854  if (re == NULL)  if (re == NULL)
7855    {    {
# Line 7868  re->flags = cd->external_flags; Line 7870  re->flags = cd->external_flags;
7870  re->dummy1 = 0;  re->dummy1 = 0;
7871  re->first_char = 0;  re->first_char = 0;
7872  re->req_char = 0;  re->req_char = 0;
7873  re->name_table_offset = sizeof(real_pcre) / sizeof(pcre_uchar);  re->name_table_offset = sizeof(REAL_PCRE) / sizeof(pcre_uchar);
7874  re->name_entry_size = cd->name_entry_size;  re->name_entry_size = cd->name_entry_size;
7875  re->name_count = cd->names_found;  re->name_count = cd->names_found;
7876  re->ref_count = 0;  re->ref_count = 0;
# Line 8132  if ((re->flags & PCRE_REQCHSET) != 0) Line 8134  if ((re->flags & PCRE_REQCHSET) != 0)
8134    }    }
8135    
8136  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
8137  pcre_printint(re, stdout, TRUE);  pcre_printint((pcre *)re, stdout, TRUE);
8138  #else  #else
8139  pcre16_printint(re, stdout, TRUE);  pcre16_printint((pcre *)re, stdout, TRUE);
8140  #endif  #endif
8141    
8142  /* This check is done here in the debugging case so that the code that  /* This check is done here in the debugging case so that the code that
# Line 8150  if (code - codestart > length) Line 8152  if (code - codestart > length)
8152    }    }
8153  #endif   /* PCRE_DEBUG */  #endif   /* PCRE_DEBUG */
8154    
8155    #ifdef COMPILE_PCRE8
8156  return (pcre *)re;  return (pcre *)re;
8157    #else
8158    return (pcre16 *)re;
8159    #endif
8160  }  }
8161    
8162  /* End of pcre_compile.c */  /* End of pcre_compile.c */

Legend:
Removed from v.848  
changed lines
  Added in v.905

  ViewVC Help
Powered by ViewVC 1.1.5