Diff for /embedaddon/pcre/pcre_byte_order.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 23:50:25 version 1.1.1.2, 2013/07/22 08:25:55
Line 6 Line 6
 and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
   
                        Written by Philip Hazel                         Written by Philip Hazel
           Copyright (c) 1997-2012 University of Cambridge           Copyright (c) 1997-2013 University of Cambridge
   
 -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 95  Arguments: Line 95  Arguments:
 Returns:          0 if the swap is successful, negative on error  Returns:          0 if the swap is successful, negative on error
 */  */
   
#ifdef COMPILE_PCRE8#if defined COMPILE_PCRE8
 PCRE_EXP_DECL int pcre_pattern_to_host_byte_order(pcre *argument_re,  PCRE_EXP_DECL int pcre_pattern_to_host_byte_order(pcre *argument_re,
   pcre_extra *extra_data, const unsigned char *tables)    pcre_extra *extra_data, const unsigned char *tables)
#else#elif defined COMPILE_PCRE16
 PCRE_EXP_DECL int pcre16_pattern_to_host_byte_order(pcre16 *argument_re,  PCRE_EXP_DECL int pcre16_pattern_to_host_byte_order(pcre16 *argument_re,
   pcre16_extra *extra_data, const unsigned char *tables)    pcre16_extra *extra_data, const unsigned char *tables)
   #elif defined COMPILE_PCRE32
   PCRE_EXP_DECL int pcre32_pattern_to_host_byte_order(pcre32 *argument_re,
     pcre32_extra *extra_data, const unsigned char *tables)
 #endif  #endif
 {  {
 REAL_PCRE *re = (REAL_PCRE *)argument_re;  REAL_PCRE *re = (REAL_PCRE *)argument_re;
Line 108  pcre_study_data *study; Line 111  pcre_study_data *study;
 #ifndef COMPILE_PCRE8  #ifndef COMPILE_PCRE8
 pcre_uchar *ptr;  pcre_uchar *ptr;
 int length;  int length;
#ifdef SUPPORT_UTF#if defined SUPPORT_UTF && defined COMPILE_PCRE16
 BOOL utf;  BOOL utf;
 BOOL utf16_char;  BOOL utf16_char;
#endif /* SUPPORT_UTF */#endif /* SUPPORT_UTF && COMPILE_PCRE16 */
 #endif /* !COMPILE_PCRE8 */  #endif /* !COMPILE_PCRE8 */
   
 if (re == NULL) return PCRE_ERROR_NULL;  if (re == NULL) return PCRE_ERROR_NULL;
Line 123  if (re->magic_number == MAGIC_NUMBER) Line 126  if (re->magic_number == MAGIC_NUMBER)
   }    }
   
 if (re->magic_number != REVERSED_MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;  if (re->magic_number != REVERSED_MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;
if ((swap_uint16(re->flags) & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;if ((swap_uint32(re->flags) & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
   
 re->magic_number = MAGIC_NUMBER;  re->magic_number = MAGIC_NUMBER;
 re->size = swap_uint32(re->size);  re->size = swap_uint32(re->size);
 re->options = swap_uint32(re->options);  re->options = swap_uint32(re->options);
re->flags = swap_uint16(re->flags);re->flags = swap_uint32(re->flags);
re->top_bracket = swap_uint16(re->top_bracket);re->limit_match = swap_uint32(re->limit_match);
re->top_backref = swap_uint16(re->top_backref);re->limit_recursion = swap_uint32(re->limit_recursion);
 
 #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
 re->first_char = swap_uint16(re->first_char);  re->first_char = swap_uint16(re->first_char);
 re->req_char = swap_uint16(re->req_char);  re->req_char = swap_uint16(re->req_char);
   #elif defined COMPILE_PCRE32
   re->first_char = swap_uint32(re->first_char);
   re->req_char = swap_uint32(re->req_char);
   #endif
   
   re->max_lookbehind = swap_uint16(re->max_lookbehind);
   re->top_bracket = swap_uint16(re->top_bracket);
   re->top_backref = swap_uint16(re->top_backref);
 re->name_table_offset = swap_uint16(re->name_table_offset);  re->name_table_offset = swap_uint16(re->name_table_offset);
 re->name_entry_size = swap_uint16(re->name_entry_size);  re->name_entry_size = swap_uint16(re->name_entry_size);
 re->name_count = swap_uint16(re->name_count);  re->name_count = swap_uint16(re->name_count);
Line 150  if (extra_data != NULL && (extra_data->flags & PCRE_EX Line 163  if (extra_data != NULL && (extra_data->flags & PCRE_EX
 #ifndef COMPILE_PCRE8  #ifndef COMPILE_PCRE8
 ptr = (pcre_uchar *)re + re->name_table_offset;  ptr = (pcre_uchar *)re + re->name_table_offset;
 length = re->name_count * re->name_entry_size;  length = re->name_count * re->name_entry_size;
#ifdef SUPPORT_UTF#if defined SUPPORT_UTF && defined COMPILE_PCRE16
 utf = (re->options & PCRE_UTF16) != 0;  utf = (re->options & PCRE_UTF16) != 0;
 utf16_char = FALSE;  utf16_char = FALSE;
#endif#endif /* SUPPORT_UTF && COMPILE_PCRE16 */
   
 while(TRUE)  while(TRUE)
   {    {
   /* Swap previous characters. */    /* Swap previous characters. */
   while (length-- > 0)    while (length-- > 0)
     {      {
   #if defined COMPILE_PCRE16
     *ptr = swap_uint16(*ptr);      *ptr = swap_uint16(*ptr);
   #elif defined COMPILE_PCRE32
       *ptr = swap_uint32(*ptr);
   #endif
     ptr++;      ptr++;
     }      }
#ifdef SUPPORT_UTF#if defined SUPPORT_UTF && defined COMPILE_PCRE16
   if (utf16_char)    if (utf16_char)
     {      {
     if (HAS_EXTRALEN(ptr[-1]))      if (HAS_EXTRALEN(ptr[-1]))
Line 178  while(TRUE) Line 195  while(TRUE)
   
   /* Get next opcode. */    /* Get next opcode. */
   length = 0;    length = 0;
   #if defined COMPILE_PCRE16
   *ptr = swap_uint16(*ptr);    *ptr = swap_uint16(*ptr);
   #elif defined COMPILE_PCRE32
     *ptr = swap_uint32(*ptr);
   #endif
   switch (*ptr)    switch (*ptr)
     {      {
     case OP_END:      case OP_END:
     return 0;      return 0;
   
#ifdef SUPPORT_UTF#if defined SUPPORT_UTF && defined COMPILE_PCRE16
     case OP_CHAR:      case OP_CHAR:
     case OP_CHARI:      case OP_CHARI:
     case OP_NOT:      case OP_NOT:
Line 259  while(TRUE) Line 280  while(TRUE)
     case OP_XCLASS:      case OP_XCLASS:
     /* Reverse the size of the XCLASS instance. */      /* Reverse the size of the XCLASS instance. */
     ptr++;      ptr++;
   #if defined COMPILE_PCRE16
     *ptr = swap_uint16(*ptr);      *ptr = swap_uint16(*ptr);
   #elif defined COMPILE_PCRE32
       *ptr = swap_uint32(*ptr);
   #endif
   #ifndef COMPILE_PCRE32
     if (LINK_SIZE > 1)      if (LINK_SIZE > 1)
       {        {
       /* LINK_SIZE can be 1 or 2 in 16 bit mode. */        /* LINK_SIZE can be 1 or 2 in 16 bit mode. */
       ptr++;        ptr++;
       *ptr = swap_uint16(*ptr);        *ptr = swap_uint16(*ptr);
       }        }
   #endif
     ptr++;      ptr++;
     length = (GET(ptr, -LINK_SIZE)) - (1 + LINK_SIZE + 1);      length = (GET(ptr, -LINK_SIZE)) - (1 + LINK_SIZE + 1);
   #if defined COMPILE_PCRE16
     *ptr = swap_uint16(*ptr);      *ptr = swap_uint16(*ptr);
   #elif defined COMPILE_PCRE32
       *ptr = swap_uint32(*ptr);
   #endif
     if ((*ptr & XCL_MAP) != 0)      if ((*ptr & XCL_MAP) != 0)
       {        {
       /* Skip the character bit map. */        /* Skip the character bit map. */
Line 279  while(TRUE) Line 310  while(TRUE)
     }      }
   ptr++;    ptr++;
   }    }
/* Control should never reach here in 16 bit mode. *//* Control should never reach here in 16/32 bit mode. */
 #endif /* !COMPILE_PCRE8 */  #endif /* !COMPILE_PCRE8 */
   
 return 0;  return 0;

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>