/[pcre]/code/trunk/pcre_byte_order.c
ViewVC logotype

Diff of /code/trunk/pcre_byte_order.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 852 by zherczeg, Thu Jan 5 19:18:12 2012 UTC revision 1055 by chpe, Tue Oct 16 15:53:30 2012 UTC
# Line 95  Arguments: Line 95  Arguments:
95  Returns:          0 if the swap is successful, negative on error  Returns:          0 if the swap is successful, negative on error
96  */  */
97    
98  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
99  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,
100    pcre_extra *extra_data, const unsigned char *tables)    pcre_extra *extra_data, const unsigned char *tables)
101  #else  #elif defined COMPILE_PCRE16
102  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,
103    pcre16_extra *extra_data, const unsigned char *tables)    pcre16_extra *extra_data, const unsigned char *tables)
104    #elif defined COMPILE_PCRE32
105    PCRE_EXP_DECL int pcre32_pattern_to_host_byte_order(pcre32 *argument_re,
106      pcre32_extra *extra_data, const unsigned char *tables)
107  #endif  #endif
108  {  {
109  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;
111  #ifndef COMPILE_PCRE8  #ifndef COMPILE_PCRE8
112  pcre_uchar *ptr;  pcre_uchar *ptr;
113  int length;  int length;
114  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && defined COMPILE_PCRE16
115  BOOL utf;  BOOL utf;
116  BOOL utf16_char;  BOOL utf16_char;
117  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF && COMPILE_PCRE16 */
118  #endif /* !COMPILE_PCRE8 */  #endif /* !COMPILE_PCRE8 */
119    
120  if (re == NULL) return PCRE_ERROR_NULL;  if (re == NULL) return PCRE_ERROR_NULL;
# Line 131  re->options = swap_uint32(re->options); Line 134  re->options = swap_uint32(re->options);
134  re->flags = swap_uint16(re->flags);  re->flags = swap_uint16(re->flags);
135  re->top_bracket = swap_uint16(re->top_bracket);  re->top_bracket = swap_uint16(re->top_bracket);
136  re->top_backref = swap_uint16(re->top_backref);  re->top_backref = swap_uint16(re->top_backref);
137    #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
138  re->first_char = swap_uint16(re->first_char);  re->first_char = swap_uint16(re->first_char);
139  re->req_char = swap_uint16(re->req_char);  re->req_char = swap_uint16(re->req_char);
140    #elif defined COMPILE_PCRE32
141    re->first_char = swap_uint32(re->first_char);
142    re->req_char = swap_uint32(re->req_char);
143    #endif
144  re->name_table_offset = swap_uint16(re->name_table_offset);  re->name_table_offset = swap_uint16(re->name_table_offset);
145  re->name_entry_size = swap_uint16(re->name_entry_size);  re->name_entry_size = swap_uint16(re->name_entry_size);
146  re->name_count = swap_uint16(re->name_count);  re->name_count = swap_uint16(re->name_count);
147  re->ref_count = swap_uint16(re->ref_count);  re->ref_count = swap_uint16(re->ref_count);
148  re->tables = tables;  re->tables = tables;
149    #ifdef COMPILE_PCRE32
150    re->dummy1 = swap_uint16(re->dummy1);
151    re->dummy2 = swap_uint16(re->dummy2);
152    #endif
153    
154  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)
155    {    {
# Line 150  if (extra_data != NULL && (extra_data->f Line 162  if (extra_data != NULL && (extra_data->f
162  #ifndef COMPILE_PCRE8  #ifndef COMPILE_PCRE8
163  ptr = (pcre_uchar *)re + re->name_table_offset;  ptr = (pcre_uchar *)re + re->name_table_offset;
164  length = re->name_count * re->name_entry_size;  length = re->name_count * re->name_entry_size;
165  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && defined COMPILE_PCRE16
166  utf = (re->options & PCRE_UTF16) != 0;  utf = (re->options & PCRE_UTF16) != 0;
167  utf16_char = FALSE;  utf16_char = FALSE;
168  #endif  #endif /* SUPPORT_UTF && COMPILE_PCRE16 */
169    
170  while(TRUE)  while(TRUE)
171    {    {
172    /* Swap previous characters. */    /* Swap previous characters. */
173    while (length-- > 0)    while (length-- > 0)
174      {      {
175    #if defined COMPILE_PCRE16
176      *ptr = swap_uint16(*ptr);      *ptr = swap_uint16(*ptr);
177    #elif defined COMPILE_PCRE32
178        *ptr = swap_uint32(*ptr);
179    #endif
180      ptr++;      ptr++;
181      }      }
182  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && defined COMPILE_PCRE16
183    if (utf16_char)    if (utf16_char)
184      {      {
185      if (HAS_EXTRALEN(ptr[-1]))      if (HAS_EXTRALEN(ptr[-1]))
# Line 178  while(TRUE) Line 194  while(TRUE)
194    
195    /* Get next opcode. */    /* Get next opcode. */
196    length = 0;    length = 0;
197    #if defined COMPILE_PCRE16
198    *ptr = swap_uint16(*ptr);    *ptr = swap_uint16(*ptr);
199    #elif defined COMPILE_PCRE32
200      *ptr = swap_uint32(*ptr);
201    #endif
202    switch (*ptr)    switch (*ptr)
203      {      {
204      case OP_END:      case OP_END:
205      return 0;      return 0;
206    
207  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && defined COMPILE_PCRE16
208      case OP_CHAR:      case OP_CHAR:
209      case OP_CHARI:      case OP_CHARI:
210      case OP_NOT:      case OP_NOT:
# Line 259  while(TRUE) Line 279  while(TRUE)
279      case OP_XCLASS:      case OP_XCLASS:
280      /* Reverse the size of the XCLASS instance. */      /* Reverse the size of the XCLASS instance. */
281      ptr++;      ptr++;
282    #if defined COMPILE_PCRE16
283      *ptr = swap_uint16(*ptr);      *ptr = swap_uint16(*ptr);
284    #elif defined COMPILE_PCRE32
285        *ptr = swap_uint32(*ptr);
286    #endif
287    #ifndef COMPILE_PCRE32
288      if (LINK_SIZE > 1)      if (LINK_SIZE > 1)
289        {        {
290        /* LINK_SIZE can be 1 or 2 in 16 bit mode. */        /* LINK_SIZE can be 1 or 2 in 16 bit mode. */
291        ptr++;        ptr++;
292        *ptr = swap_uint16(*ptr);        *ptr = swap_uint16(*ptr);
293        }        }
294    #endif
295      ptr++;      ptr++;
296      length = (GET(ptr, -LINK_SIZE)) - (1 + LINK_SIZE + 1);      length = (GET(ptr, -LINK_SIZE)) - (1 + LINK_SIZE + 1);
297    #if defined COMPILE_PCRE16
298      *ptr = swap_uint16(*ptr);      *ptr = swap_uint16(*ptr);
299    #elif defined COMPILE_PCRE32
300        *ptr = swap_uint32(*ptr);
301    #endif
302      if ((*ptr & XCL_MAP) != 0)      if ((*ptr & XCL_MAP) != 0)
303        {        {
304        /* Skip the character bit map. */        /* Skip the character bit map. */
# Line 279  while(TRUE) Line 309  while(TRUE)
309      }      }
310    ptr++;    ptr++;
311    }    }
312  /* Control should never reach here in 16 bit mode. */  /* Control should never reach here in 16/32 bit mode. */
313  #endif /* !COMPILE_PCRE8 */  #endif /* !COMPILE_PCRE8 */
314    
315  return 0;  return 0;

Legend:
Removed from v.852  
changed lines
  Added in v.1055

  ViewVC Help
Powered by ViewVC 1.1.5