/[pcre]/code/branches/pcre16/pcre_printint.src
ViewVC logotype

Diff of /code/branches/pcre16/pcre_printint.src

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

code/trunk/pcre_printint.src revision 117 by ph10, Fri Mar 9 15:59:06 2007 UTC code/branches/pcre16/pcre_printint.src revision 785 by zherczeg, Mon Dec 5 20:12:24 2011 UTC
# Line 6  Line 6 
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.
7    
8                         Written by Philip Hazel                         Written by Philip Hazel
9             Copyright (c) 1997-2007 University of Cambridge             Copyright (c) 1997-2010 University of Cambridge
10    
11  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
12  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# Line 43  internal form of a compiled regular expr Line 43  internal form of a compiled regular expr
43  local functions. This source file is used in two places:  local functions. This source file is used in two places:
44    
45  (1) It is #included by pcre_compile.c when it is compiled in debugging mode  (1) It is #included by pcre_compile.c when it is compiled in debugging mode
46  (DEBUG defined in pcre_internal.h). It is not included in production compiles.  (PCRE_DEBUG defined in pcre_internal.h). It is not included in production
47    compiles.
48    
49  (2) It is always #included by pcretest.c, which can be asked to print out a  (2) It is always #included by pcretest.c, which can be asked to print out a
50  compiled regex for debugging purposes. */  compiled regex for debugging purposes. */
# Line 54  hexadecimal. We don't use isprint() beca Line 55  hexadecimal. We don't use isprint() beca
55  (even without the use of locales) and we want the output always to be the same,  (even without the use of locales) and we want the output always to be the same,
56  for testing purposes. This macro is used in pcretest as well as in this file. */  for testing purposes. This macro is used in pcretest as well as in this file. */
57    
58    #ifdef EBCDIC
59    #define PRINTABLE(c) ((c) >= 64 && (c) < 255)
60    #else
61  #define PRINTABLE(c) ((c) >= 32 && (c) < 127)  #define PRINTABLE(c) ((c) >= 32 && (c) < 127)
62    #endif
63    
64  /* The table of operator names. */  /* The table of operator names. */
65    
# Line 67  static const char *OP_names[] = { OP_NAM Line 72  static const char *OP_names[] = { OP_NAM
72  *************************************************/  *************************************************/
73    
74  static int  static int
75  print_char(FILE *f, uschar *ptr, BOOL utf8)  print_char(FILE *f, pcre_uchar *ptr, BOOL utf)
76  {  {
77  int c = *ptr;  int c = *ptr;
78    
79  #ifndef SUPPORT_UTF8  #ifndef SUPPORT_UTF
80  utf8 = utf8;  /* Avoid compiler warning */  (void)utf;  /* Avoid compiler warning */
81  if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);  if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);
82  return 0;  return 0;
83    
84  #else  #else
85  if (!utf8 || (c & 0xc0) != 0xc0)  
86    #ifdef COMPILE_PCRE8
87    
88    if (!utf || (c & 0xc0) != 0xc0)
89    {    {
90    if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);    if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);
91    return 0;    return 0;
# Line 85  if (!utf8 || (c & 0xc0) != 0xc0) Line 93  if (!utf8 || (c & 0xc0) != 0xc0)
93  else  else
94    {    {
95    int i;    int i;
96    int a = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */    int a = PRIV(utf8_table4)[c & 0x3f];  /* Number of additional bytes */
97    int s = 6*a;    int s = 6*a;
98    c = (c & _pcre_utf8_table3[a]) << s;    c = (c & PRIV(utf8_table3)[a]) << s;
99    for (i = 1; i <= a; i++)    for (i = 1; i <= a; i++)
100      {      {
101      /* This is a check for malformed UTF-8; it should only occur if the sanity      /* This is a check for malformed UTF-8; it should only occur if the sanity
# Line 105  else Line 113  else
113      s -= 6;      s -= 6;
114      c |= (ptr[i] & 0x3f) << s;      c |= (ptr[i] & 0x3f) << s;
115      }      }
116    if (c < 128) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c);    fprintf(f, "\\x{%x}", c);
117    return a;    return a;
118    }    }
119  #endif  
120    #else
121    
122    #ifdef COMPILE_PCRE16
123    
124    if (!utf || (c & 0xfc00) != 0xd800)
125      {
126      if (PRINTABLE(c)) fprintf(f, "%c", c);
127      else if (c <= 0xff) fprintf(f, "\\x%02x", c);
128      else fprintf(f, "\\x{%x}", c);
129      return 0;
130      }
131    else
132      {
133      /* This is a check for malformed UTF-16; it should only occur if the sanity
134      check has been turned off. Rather than swallow a low surrogate, just stop if
135      we hit a bad one. Print it with \X instead of \x as an indication. */
136    
137      if ((ptr[1] & 0xfc00) != 0xdc00)
138        {
139        fprintf(f, "\\X{%x}", c);
140        return 0;
141        }
142    
143      c = (((c & 0x3ff) << 10) | (ptr[1] & 0x3ff)) + 0x10000;
144      fprintf(f, "\\x{%x}", c);
145      return 1;
146      }
147    
148    #endif /* COMPILE_PCRE16 */
149    
150    #endif /* COMPILE_PCRE8 */
151    
152    #endif /* SUPPORT_UTF */
153  }  }
154    
155    /*************************************************
156    *  Print uchar string (regardless of utf)        *
157    *************************************************/
158    
159    static void
160    print_puchar(FILE *f, PCRE_PUCHAR ptr)
161    {
162    while (*ptr != '\0')
163      {
164      register int c = *ptr++;
165      if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x{%x}", c);
166      }
167    }
168    
169  /*************************************************  /*************************************************
170  *          Find Unicode property name            *  *          Find Unicode property name            *
# Line 122  get_ucpname(int ptype, int pvalue) Line 175  get_ucpname(int ptype, int pvalue)
175  {  {
176  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
177  int i;  int i;
178  for (i = _pcre_utt_size; i >= 0; i--)  for (i = PRIV(utt_size) - 1; i >= 0; i--)
179    {    {
180    if (ptype == _pcre_utt[i].type && pvalue == _pcre_utt[i].value) break;    if (ptype == PRIV(utt)[i].type && pvalue == PRIV(utt)[i].value) break;
181    }    }
182  return (i >= 0)? _pcre_utt[i].name : "??";  return (i >= 0)? PRIV(utt_names) + PRIV(utt)[i].name_offset : "??";
183  #else  #else
184  /* It gets harder and harder to shut off unwanted compiler warnings. */  /* It gets harder and harder to shut off unwanted compiler warnings. */
185  ptype = ptype * pvalue;  ptype = ptype * pvalue;
# Line 142  return (ptype == pvalue)? "??" : "??"; Line 195  return (ptype == pvalue)? "??" : "??";
195    
196  /* Make this function work for a regex with integers either byte order.  /* Make this function work for a regex with integers either byte order.
197  However, we assume that what we are passed is a compiled regex. The  However, we assume that what we are passed is a compiled regex. The
198  print_lengths flag controls whether offsets and lengths of items are printed.  print_lengths flag controls whether offsets and lengths of items are printed.
199  They can be turned off from pcretest so that automatic tests on bytecode can be  They can be turned off from pcretest so that automatic tests on bytecode can be
200  written that do not depend on the value of LINK_SIZE. */  written that do not depend on the value of LINK_SIZE. */
201    
# Line 150  static void Line 203  static void
203  pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)  pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)
204  {  {
205  real_pcre *re = (real_pcre *)external_re;  real_pcre *re = (real_pcre *)external_re;
206  uschar *codestart, *code;  pcre_uchar *codestart, *code;
207  BOOL utf8;  BOOL utf;
208    
209  unsigned int options = re->options;  unsigned int options = re->options;
210  int offset = re->name_table_offset;  int offset = re->name_table_offset;
# Line 169  if (re->magic_number != MAGIC_NUMBER) Line 222  if (re->magic_number != MAGIC_NUMBER)
222              ((options >> 24) & 0x000000ff);              ((options >> 24) & 0x000000ff);
223    }    }
224    
225  code = codestart = (uschar *)re + offset + count * size;  code = codestart = (pcre_uchar *)re + offset + count * size;
226  utf8 = (options & PCRE_UTF8) != 0;  /* PCRE_UTF16 has the same value as PCRE_UTF8. */
227    utf = (options & PCRE_UTF8) != 0;
228    
229  for(;;)  for(;;)
230    {    {
231    uschar *ccode;    pcre_uchar *ccode;
232      const char *flag = "  ";
233    int c;    int c;
234    int extra = 0;    int extra = 0;
235    
236    if (print_lengths)    if (print_lengths)
237      fprintf(f, "%3d ", (int)(code - codestart));      fprintf(f, "%3d ", (int)(code - codestart));
238    else    else
239      fprintf(f, "    ");      fprintf(f, "    ");
240    
241    switch(*code)    switch(*code)
242      {      {
243    /* ========================================================================== */
244          /* These cases are never obeyed. This is a fudge that causes a compile-
245          time error if the vectors OP_names or PRIV(OP_lengths), which are indexed
246          by opcode, are not the correct length. It seems to be the only way to do
247          such a check at compile time, as the sizeof() operator does not work in
248          the C preprocessor. We do this while compiling pcretest, because that
249          #includes pcre_tables.c, which holds PRIV(OP_lengths). We can't do this
250          when building pcre_compile.c with PCRE_DEBUG set, because it doesn't then
251          know the size of PRIV(OP_lengths). */
252    
253    #ifdef COMPILING_PCRETEST
254          case OP_TABLE_LENGTH:
255          case OP_TABLE_LENGTH +
256            ((sizeof(OP_names)/sizeof(const char *) == OP_TABLE_LENGTH) &&
257            (sizeof(PRIV(OP_lengths)) == OP_TABLE_LENGTH)):
258          break;
259    #endif
260    /* ========================================================================== */
261    
262      case OP_END:      case OP_END:
263      fprintf(f, "    %s\n", OP_names[*code]);      fprintf(f, "    %s\n", OP_names[*code]);
264      fprintf(f, "------------------------------------------------------------------\n");      fprintf(f, "------------------------------------------------------------------\n");
265      return;      return;
266    
     case OP_OPT:  
     fprintf(f, " %.2x %s", code[1], OP_names[*code]);  
     break;  
   
267      case OP_CHAR:      case OP_CHAR:
268      fprintf(f, "    ");      fprintf(f, "    ");
269      do      do
270        {        {
271        code++;        code++;
272        code += 1 + print_char(f, code, utf8);        code += 1 + print_char(f, code, utf);
273        }        }
274      while (*code == OP_CHAR);      while (*code == OP_CHAR);
275      fprintf(f, "\n");      fprintf(f, "\n");
276      continue;      continue;
277    
278      case OP_CHARNC:      case OP_CHARI:
279      fprintf(f, " NC ");      fprintf(f, " /i ");
280      do      do
281        {        {
282        code++;        code++;
283        code += 1 + print_char(f, code, utf8);        code += 1 + print_char(f, code, utf);
284        }        }
285      while (*code == OP_CHARNC);      while (*code == OP_CHARI);
286      fprintf(f, "\n");      fprintf(f, "\n");
287      continue;      continue;
288    
289      case OP_CBRA:      case OP_CBRA:
290        case OP_CBRAPOS:
291      case OP_SCBRA:      case OP_SCBRA:
292        case OP_SCBRAPOS:
293      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
294        else fprintf(f, "    ");        else fprintf(f, "    ");
295      fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE));      fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE));
296      break;      break;
297    
298      case OP_BRA:      case OP_BRA:
299        case OP_BRAPOS:
300      case OP_SBRA:      case OP_SBRA:
301        case OP_SBRAPOS:
302      case OP_KETRMAX:      case OP_KETRMAX:
303      case OP_KETRMIN:      case OP_KETRMIN:
304        case OP_KETRPOS:
305      case OP_ALT:      case OP_ALT:
306      case OP_KET:      case OP_KET:
307      case OP_ASSERT:      case OP_ASSERT:
# Line 234  for(;;) Line 309  for(;;)
309      case OP_ASSERTBACK:      case OP_ASSERTBACK:
310      case OP_ASSERTBACK_NOT:      case OP_ASSERTBACK_NOT:
311      case OP_ONCE:      case OP_ONCE:
312        case OP_ONCE_NC:
313      case OP_COND:      case OP_COND:
314      case OP_SCOND:      case OP_SCOND:
315      case OP_REVERSE:      case OP_REVERSE:
316      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
317        else fprintf(f, "    ");        else fprintf(f, "    ");
318      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", OP_names[*code]);
319      break;      break;
320    
321        case OP_CLOSE:
322        fprintf(f, "    %s %d", OP_names[*code], GET2(code, 1));
323        break;
324    
325      case OP_CREF:      case OP_CREF:
326        case OP_NCREF:
327      fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);      fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);
328      break;      break;
329    
# Line 254  for(;;) Line 335  for(;;)
335        fprintf(f, "    Cond recurse %d", c);        fprintf(f, "    Cond recurse %d", c);
336      break;      break;
337    
338        case OP_NRREF:
339        c = GET2(code, 1);
340        if (c == RREF_ANY)
341          fprintf(f, "    Cond nrecurse any");
342        else
343          fprintf(f, "    Cond nrecurse %d", c);
344        break;
345    
346      case OP_DEF:      case OP_DEF:
347      fprintf(f, "    Cond def");      fprintf(f, "    Cond def");
348      break;      break;
349    
350        case OP_STARI:
351        case OP_MINSTARI:
352        case OP_POSSTARI:
353        case OP_PLUSI:
354        case OP_MINPLUSI:
355        case OP_POSPLUSI:
356        case OP_QUERYI:
357        case OP_MINQUERYI:
358        case OP_POSQUERYI:
359        flag = "/i";
360        /* Fall through */
361      case OP_STAR:      case OP_STAR:
362      case OP_MINSTAR:      case OP_MINSTAR:
363      case OP_POSSTAR:      case OP_POSSTAR:
# Line 276  for(;;) Line 376  for(;;)
376      case OP_TYPEQUERY:      case OP_TYPEQUERY:
377      case OP_TYPEMINQUERY:      case OP_TYPEMINQUERY:
378      case OP_TYPEPOSQUERY:      case OP_TYPEPOSQUERY:
379      fprintf(f, "    ");      fprintf(f, " %s ", flag);
380      if (*code >= OP_TYPESTAR)      if (*code >= OP_TYPESTAR)
381        {        {
382        fprintf(f, "%s", OP_names[code[1]]);        fprintf(f, "%s", OP_names[code[1]]);
# Line 286  for(;;) Line 386  for(;;)
386          extra = 2;          extra = 2;
387          }          }
388        }        }
389      else extra = print_char(f, code+1, utf8);      else extra = print_char(f, code+1, utf);
390      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", OP_names[*code]);
391      break;      break;
392    
393        case OP_EXACTI:
394        case OP_UPTOI:
395        case OP_MINUPTOI:
396        case OP_POSUPTOI:
397        flag = "/i";
398        /* Fall through */
399      case OP_EXACT:      case OP_EXACT:
400      case OP_UPTO:      case OP_UPTO:
401      case OP_MINUPTO:      case OP_MINUPTO:
402      case OP_POSUPTO:      case OP_POSUPTO:
403      fprintf(f, "    ");      fprintf(f, " %s ", flag);
404      extra = print_char(f, code+3, utf8);      extra = print_char(f, code + 1 + IMM2_SIZE, utf);
405      fprintf(f, "{");      fprintf(f, "{");
406      if (*code != OP_EXACT) fprintf(f, "0,");      if (*code != OP_EXACT && *code != OP_EXACTI) fprintf(f, "0,");
407      fprintf(f, "%d}", GET2(code,1));      fprintf(f, "%d}", GET2(code,1));
408      if (*code == OP_MINUPTO) fprintf(f, "?");      if (*code == OP_MINUPTO || *code == OP_MINUPTOI) fprintf(f, "?");
409        else if (*code == OP_POSUPTO) fprintf(f, "+");        else if (*code == OP_POSUPTO || *code == OP_POSUPTOI) fprintf(f, "+");
410      break;      break;
411    
412      case OP_TYPEEXACT:      case OP_TYPEEXACT:
413      case OP_TYPEUPTO:      case OP_TYPEUPTO:
414      case OP_TYPEMINUPTO:      case OP_TYPEMINUPTO:
415      case OP_TYPEPOSUPTO:      case OP_TYPEPOSUPTO:
416      fprintf(f, "    %s", OP_names[code[3]]);      fprintf(f, "    %s", OP_names[code[1 + IMM2_SIZE]]);
417      if (code[3] == OP_PROP || code[3] == OP_NOTPROP)      if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
418        {        {
419        fprintf(f, " %s ", get_ucpname(code[4], code[5]));        fprintf(f, " %s ", get_ucpname(code[1 + IMM2_SIZE + 1],
420            code[1 + IMM2_SIZE + 2]));
421        extra = 2;        extra = 2;
422        }        }
423      fprintf(f, "{");      fprintf(f, "{");
# Line 320  for(;;) Line 427  for(;;)
427        else if (*code == OP_TYPEPOSUPTO) fprintf(f, "+");        else if (*code == OP_TYPEPOSUPTO) fprintf(f, "+");
428      break;      break;
429    
430        case OP_NOTI:
431        flag = "/i";
432        /* Fall through */
433      case OP_NOT:      case OP_NOT:
434      c = code[1];      c = code[1];
435      if (PRINTABLE(c)) fprintf(f, "    [^%c]", c);      if (PRINTABLE(c)) fprintf(f, " %s [^%c]", flag, c);
436        else fprintf(f, "    [^\\x%02x]", c);        else fprintf(f, " %s [^\\x%02x]", flag, c);
437      break;      break;
438    
439        case OP_NOTSTARI:
440        case OP_NOTMINSTARI:
441        case OP_NOTPOSSTARI:
442        case OP_NOTPLUSI:
443        case OP_NOTMINPLUSI:
444        case OP_NOTPOSPLUSI:
445        case OP_NOTQUERYI:
446        case OP_NOTMINQUERYI:
447        case OP_NOTPOSQUERYI:
448        flag = "/i";
449        /* Fall through */
450    
451      case OP_NOTSTAR:      case OP_NOTSTAR:
452      case OP_NOTMINSTAR:      case OP_NOTMINSTAR:
453      case OP_NOTPOSSTAR:      case OP_NOTPOSSTAR:
# Line 336  for(;;) Line 458  for(;;)
458      case OP_NOTMINQUERY:      case OP_NOTMINQUERY:
459      case OP_NOTPOSQUERY:      case OP_NOTPOSQUERY:
460      c = code[1];      c = code[1];
461      if (PRINTABLE(c)) fprintf(f, "    [^%c]", c);      if (PRINTABLE(c)) fprintf(f, " %s [^%c]", flag, c);
462        else fprintf(f, "    [^\\x%02x]", c);        else fprintf(f, " %s [^\\x%02x]", flag, c);
463      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", OP_names[*code]);
464      break;      break;
465    
466        case OP_NOTEXACTI:
467        case OP_NOTUPTOI:
468        case OP_NOTMINUPTOI:
469        case OP_NOTPOSUPTOI:
470        flag = "/i";
471        /* Fall through */
472    
473      case OP_NOTEXACT:      case OP_NOTEXACT:
474      case OP_NOTUPTO:      case OP_NOTUPTO:
475      case OP_NOTMINUPTO:      case OP_NOTMINUPTO:
476      case OP_NOTPOSUPTO:      case OP_NOTPOSUPTO:
477      c = code[3];      c = code[1 + IMM2_SIZE];
478      if (PRINTABLE(c)) fprintf(f, "    [^%c]{", c);      if (PRINTABLE(c)) fprintf(f, " %s [^%c]{", flag, c);
479        else fprintf(f, "    [^\\x%02x]{", c);        else fprintf(f, " %s [^\\x%02x]{", flag, c);
480      if (*code != OP_NOTEXACT) fprintf(f, "0,");      if (*code != OP_NOTEXACT && *code != OP_NOTEXACTI) fprintf(f, "0,");
481      fprintf(f, "%d}", GET2(code,1));      fprintf(f, "%d}", GET2(code,1));
482      if (*code == OP_NOTMINUPTO) fprintf(f, "?");      if (*code == OP_NOTMINUPTO || *code == OP_NOTMINUPTOI) fprintf(f, "?");
483        else if (*code == OP_NOTPOSUPTO) fprintf(f, "+");        else
484        if (*code == OP_NOTPOSUPTO || *code == OP_NOTPOSUPTOI) fprintf(f, "+");
485      break;      break;
486    
487      case OP_RECURSE:      case OP_RECURSE:
488      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
489        else fprintf(f, "    ");        else fprintf(f, "    ");
490      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", OP_names[*code]);
491      break;      break;
492    
493        case OP_REFI:
494        flag = "/i";
495        /* Fall through */
496      case OP_REF:      case OP_REF:
497      fprintf(f, "    \\%d", GET2(code,1));      fprintf(f, " %s \\%d", flag, GET2(code,1));
498      ccode = code + _pcre_OP_lengths[*code];      ccode = code + PRIV(OP_lengths)[*code];
499      goto CLASS_REF_REPEAT;      goto CLASS_REF_REPEAT;
500    
501      case OP_CALLOUT:      case OP_CALLOUT:
# Line 375  for(;;) Line 508  for(;;)
508      fprintf(f, "    %s %s", OP_names[*code], get_ucpname(code[1], code[2]));      fprintf(f, "    %s %s", OP_names[*code], get_ucpname(code[1], code[2]));
509      break;      break;
510    
511      /* OP_XCLASS can only occur in UTF-8 mode. However, there's no harm in      /* OP_XCLASS can only occur in UTF or PCRE16 modes. However, there's no
512      having this code always here, and it makes it less messy without all those      harm in having this code always here, and it makes it less messy without
513      #ifdefs. */      all those #ifdefs. */
514    
515      case OP_CLASS:      case OP_CLASS:
516      case OP_NCLASS:      case OP_NCLASS:
# Line 385  for(;;) Line 518  for(;;)
518        {        {
519        int i, min, max;        int i, min, max;
520        BOOL printmap;        BOOL printmap;
521          pcre_uint8 *map;
522    
523        fprintf(f, "    [");        fprintf(f, "    [");
524    
# Line 405  for(;;) Line 539  for(;;)
539    
540        if (printmap)        if (printmap)
541          {          {
542            map = (pcre_uint8 *)ccode;
543          for (i = 0; i < 256; i++)          for (i = 0; i < 256; i++)
544            {            {
545            if ((ccode[i/8] & (1 << (i&7))) != 0)            if ((map[i/8] & (1 << (i&7))) != 0)
546              {              {
547              int j;              int j;
548              for (j = i+1; j < 256; j++)              for (j = i+1; j < 256; j++)
549                if ((ccode[j/8] & (1 << (j&7))) == 0) break;                if ((map[j/8] & (1 << (j&7))) == 0) break;
550              if (i == '-' || i == ']') fprintf(f, "\\");              if (i == '-' || i == ']') fprintf(f, "\\");
551              if (PRINTABLE(i)) fprintf(f, "%c", i);              if (PRINTABLE(i)) fprintf(f, "%c", i);
552                else fprintf(f, "\\x%02x", i);                else fprintf(f, "\\x%02x", i);
# Line 425  for(;;) Line 560  for(;;)
560              i = j;              i = j;
561              }              }
562            }            }
563          ccode += 32;          ccode += 32 / sizeof(pcre_uchar);
564          }          }
565    
566        /* For an XCLASS there is always some additional data */        /* For an XCLASS there is always some additional data */
# Line 459  for(;;) Line 594  for(;;)
594            }            }
595          }          }
596    
597        /* Indicate a non-UTF8 class which was created by negation */        /* Indicate a non-UTF class which was created by negation */
598    
599        fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : "");        fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : "");
600    
# Line 475  for(;;) Line 610  for(;;)
610          case OP_CRQUERY:          case OP_CRQUERY:
611          case OP_CRMINQUERY:          case OP_CRMINQUERY:
612          fprintf(f, "%s", OP_names[*ccode]);          fprintf(f, "%s", OP_names[*ccode]);
613          extra += _pcre_OP_lengths[*ccode];          extra += PRIV(OP_lengths)[*ccode];
614          break;          break;
615    
616          case OP_CRRANGE:          case OP_CRRANGE:
617          case OP_CRMINRANGE:          case OP_CRMINRANGE:
618          min = GET2(ccode,1);          min = GET2(ccode,1);
619          max = GET2(ccode,3);          max = GET2(ccode,1 + IMM2_SIZE);
620          if (max == 0) fprintf(f, "{%d,}", min);          if (max == 0) fprintf(f, "{%d,}", min);
621          else fprintf(f, "{%d,%d}", min, max);          else fprintf(f, "{%d,%d}", min, max);
622          if (*ccode == OP_CRMINRANGE) fprintf(f, "?");          if (*ccode == OP_CRMINRANGE) fprintf(f, "?");
623          extra += _pcre_OP_lengths[*ccode];          extra += PRIV(OP_lengths)[*ccode];
624          break;          break;
625    
626          /* Do nothing if it's not a repeat; this code stops picky compilers          /* Do nothing if it's not a repeat; this code stops picky compilers
# Line 497  for(;;) Line 632  for(;;)
632        }        }
633      break;      break;
634    
635      /* Anything else is just an item with no data*/      case OP_MARK:
636        case OP_PRUNE_ARG:
637        case OP_SKIP_ARG:
638        case OP_THEN_ARG:
639        fprintf(f, "    %s ", OP_names[*code]);
640        print_puchar(f, code + 2);
641        extra += code[1];
642        break;
643    
644      default:      case OP_THEN:
645      fprintf(f, "    %s", OP_names[*code]);      fprintf(f, "    %s", OP_names[*code]);
646      break;      break;
647    
648        case OP_CIRCM:
649        case OP_DOLLM:
650        flag = "/m";
651        /* Fall through */
652    
653        /* Anything else is just an item with no data, but possibly a flag. */
654    
655        default:
656        fprintf(f, " %s %s", flag, OP_names[*code]);
657        break;
658      }      }
659    
660    code += _pcre_OP_lengths[*code] + extra;    code += PRIV(OP_lengths)[*code] + extra;
661    fprintf(f, "\n");    fprintf(f, "\n");
662    }    }
663  }  }

Legend:
Removed from v.117  
changed lines
  Added in v.785

  ViewVC Help
Powered by ViewVC 1.1.5