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

Diff of /code/trunk/pcre_printint.c

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

revision 1046 by ph10, Tue Sep 25 16:27:58 2012 UTC revision 1055 by chpe, Tue Oct 16 15:53:30 2012 UTC
# Line 78  having a separate .h file just for this. Line 78  having a separate .h file just for this.
78  #ifdef PCRE_INCLUDED  #ifdef PCRE_INCLUDED
79  static /* Keep the following function as private. */  static /* Keep the following function as private. */
80  #endif  #endif
81  #ifdef COMPILE_PCRE8  
82    #if defined COMPILE_PCRE8
83  void pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths);  void pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths);
84  #else  #elif defined COMPILE_PCRE16
85  void pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths);  void pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths);
86    #elif defined COMPILE_PCRE32
87    void pcre32_printint(pcre *external_re, FILE *f, BOOL print_lengths);
88  #endif  #endif
89    
90  /* Macro that decides whether a character should be output as a literal or in  /* Macro that decides whether a character should be output as a literal or in
# Line 114  static const pcre_uint8 priv_OP_lengths[ Line 117  static const pcre_uint8 priv_OP_lengths[
117  static int  static int
118  print_char(FILE *f, pcre_uchar *ptr, BOOL utf)  print_char(FILE *f, pcre_uchar *ptr, BOOL utf)
119  {  {
120  int c = *ptr;  pcre_uint32 c = *ptr;
121    
122  #ifndef SUPPORT_UTF  #ifndef SUPPORT_UTF
123    
124  (void)utf;  /* Avoid compiler warning */  (void)utf;  /* Avoid compiler warning */
125  if (PRINTABLE(c)) fprintf(f, "%c", c);  if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
126  else if (c <= 0x80) fprintf(f, "\\x%02x", c);  else if (c <= 0x80) fprintf(f, "\\x%02x", c);
127  else fprintf(f, "\\x{%x}", c);  else fprintf(f, "\\x{%x}", c);
128  return 0;  return 0;
129    
130  #else  #else
131    
132  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
133    
134  if (!utf || (c & 0xc0) != 0xc0)  if (!utf || (c & 0xc0) != 0xc0)
135    {    {
136    if (PRINTABLE(c)) fprintf(f, "%c", c);    if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
137    else if (c < 0x80) fprintf(f, "\\x%02x", c);    else if (c < 0x80) fprintf(f, "\\x%02x", c);
138    else fprintf(f, "\\x{%02x}", c);    else fprintf(f, "\\x{%02x}", c);
139    return 0;    return 0;
# Line 162  else Line 165  else
165    return a;    return a;
166    }    }
167    
168  #else  #elif defined COMPILE_PCRE16
   
 #ifdef COMPILE_PCRE16  
169    
170  if (!utf || (c & 0xfc00) != 0xd800)  if (!utf || (c & 0xfc00) != 0xd800)
171    {    {
172    if (PRINTABLE(c)) fprintf(f, "%c", c);    if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
173    else if (c <= 0x80) fprintf(f, "\\x%02x", c);    else if (c <= 0x80) fprintf(f, "\\x%02x", c);
174    else fprintf(f, "\\x{%02x}", c);    else fprintf(f, "\\x{%02x}", c);
175    return 0;    return 0;
# Line 190  else Line 191  else
191    return 1;    return 1;
192    }    }
193    
194  #endif /* COMPILE_PCRE16 */  #elif defined COMPILE_PCRE32
195    
196  #endif /* COMPILE_PCRE8 */  if (!utf || (c & 0xfffff800u) != 0xd800u)
197      {
198      if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
199      else if (c <= 0x80) fprintf(f, "\\x%02x", c);
200      else fprintf(f, "\\x{%x}", c);
201      return 0;
202      }
203    else
204      {
205      /* This is a check for malformed UTF-32; it should only occur if the sanity
206      check has been turned off. Rather than swallow a surrogate, just stop if
207      we hit one. Print it with \X instead of \x as an indication. */
208      fprintf(f, "\\X{%x}", c);
209      return 0;
210      }
211    
212    #endif /* COMPILE_PCRE[8|16|32] */
213    
214  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
215  }  }
# Line 281  written that do not depend on the value Line 298  written that do not depend on the value
298  #ifdef PCRE_INCLUDED  #ifdef PCRE_INCLUDED
299  static /* Keep the following function as private. */  static /* Keep the following function as private. */
300  #endif  #endif
301  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
302  void  void
303  pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)  pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)
304  #else  #elif defined COMPILE_PCRE16
305  void  void
306  pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths)  pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths)
307    #elif defined COMPILE_PCRE32
308    void
309    pcre32_printint(pcre *external_re, FILE *f, BOOL print_lengths)
310  #endif  #endif
311  {  {
312  REAL_PCRE *re = (REAL_PCRE *)external_re;  REAL_PCRE *re = (REAL_PCRE *)external_re;
# Line 310  if (re->magic_number != MAGIC_NUMBER) Line 330  if (re->magic_number != MAGIC_NUMBER)
330    }    }
331    
332  code = codestart = (pcre_uchar *)re + offset + count * size;  code = codestart = (pcre_uchar *)re + offset + count * size;
333  /* PCRE_UTF16 has the same value as PCRE_UTF8. */  /* PCRE_UTF(16|32) have the same value as PCRE_UTF8. */
334  utf = (options & PCRE_UTF8) != 0;  utf = (options & PCRE_UTF8) != 0;
335    
336  for(;;)  for(;;)

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

  ViewVC Help
Powered by ViewVC 1.1.5