/[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 782 by zherczeg, Sat Dec 3 23:58:37 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); else fprintf(f, "\\x%02x", c);
127      return 0;
128      }
129    else
130      {
131      /* This is a check for malformed UTF-16; it should only occur if the sanity
132      check has been turned off. Rather than swallow a low surrogate, just stop if
133      we hit a bad one. Print it with \X instead of \x as an indication. */
134    
135      if ((ptr[1] & 0xfc00) != 0xdc00)
136        {
137        fprintf(f, "\\X{%x}", c);
138        return 0;
139        }
140    
141      c = (((c & 0x3ff) << 10) | (ptr[1] & 0x3ff)) + 0x10000;
142      fprintf(f, "\\x{%x}", c);
143      return 1;
144      }
145    
146    #endif /* COMPILE_PCRE16 */
147    
148    #endif /* COMPILE_PCRE8 */
149    
150    #endif /* SUPPORT_UTF */
151  }  }
152    
153    /*************************************************
154    *  Print uchar string (regardless of utf)        *
155    *************************************************/
156    
157    static void
158    print_puchar(FILE *f, PCRE_PUCHAR ptr)
159    {
160    while (*ptr != '\0')
161      {
162      register int c = *ptr++;
163      if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x{%x}", c);
164      }
165    }
166    
167  /*************************************************  /*************************************************
168  *          Find Unicode property name            *  *          Find Unicode property name            *
# Line 122  get_ucpname(int ptype, int pvalue) Line 173  get_ucpname(int ptype, int pvalue)
173  {  {
174  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
175  int i;  int i;
176  for (i = _pcre_utt_size; i >= 0; i--)  for (i = PRIV(utt_size) - 1; i >= 0; i--)
177    {    {
178    if (ptype == _pcre_utt[i].type && pvalue == _pcre_utt[i].value) break;    if (ptype == PRIV(utt)[i].type && pvalue == PRIV(utt)[i].value) break;
179    }    }
180  return (i >= 0)? _pcre_utt[i].name : "??";  return (i >= 0)? PRIV(utt_names) + PRIV(utt)[i].name_offset : "??";
181  #else  #else
182  /* It gets harder and harder to shut off unwanted compiler warnings. */  /* It gets harder and harder to shut off unwanted compiler warnings. */
183  ptype = ptype * pvalue;  ptype = ptype * pvalue;
# Line 142  return (ptype == pvalue)? "??" : "??"; Line 193  return (ptype == pvalue)? "??" : "??";
193    
194  /* Make this function work for a regex with integers either byte order.  /* Make this function work for a regex with integers either byte order.
195  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
196  print_lengths flag controls whether offsets and lengths of items are printed.  print_lengths flag controls whether offsets and lengths of items are printed.
197  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
198  written that do not depend on the value of LINK_SIZE. */  written that do not depend on the value of LINK_SIZE. */
199    
# Line 150  static void Line 201  static void
201  pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)  pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)
202  {  {
203  real_pcre *re = (real_pcre *)external_re;  real_pcre *re = (real_pcre *)external_re;
204  uschar *codestart, *code;  pcre_uchar *codestart, *code;
205  BOOL utf8;  BOOL utf;
206    
207  unsigned int options = re->options;  unsigned int options = re->options;
208  int offset = re->name_table_offset;  int offset = re->name_table_offset;
# Line 169  if (re->magic_number != MAGIC_NUMBER) Line 220  if (re->magic_number != MAGIC_NUMBER)
220              ((options >> 24) & 0x000000ff);              ((options >> 24) & 0x000000ff);
221    }    }
222    
223  code = codestart = (uschar *)re + offset + count * size;  code = codestart = (pcre_uchar *)re + offset + count * size;
224  utf8 = (options & PCRE_UTF8) != 0;  /* PCRE_UTF16 has the same value as PCRE_UTF8. */
225    utf = (options & PCRE_UTF8) != 0;
226    
227  for(;;)  for(;;)
228    {    {
229    uschar *ccode;    pcre_uchar *ccode;
230      const char *flag = "  ";
231    int c;    int c;
232    int extra = 0;    int extra = 0;
233    
234    if (print_lengths)    if (print_lengths)
235      fprintf(f, "%3d ", (int)(code - codestart));      fprintf(f, "%3d ", (int)(code - codestart));
236    else    else
237      fprintf(f, "    ");      fprintf(f, "    ");
238    
239    switch(*code)    switch(*code)
240      {      {
241    /* ========================================================================== */
242          /* These cases are never obeyed. This is a fudge that causes a compile-
243          time error if the vectors OP_names or PRIV(OP_lengths), which are indexed
244          by opcode, are not the correct length. It seems to be the only way to do
245          such a check at compile time, as the sizeof() operator does not work in
246          the C preprocessor. We do this while compiling pcretest, because that
247          #includes pcre_tables.c, which holds PRIV(OP_lengths). We can't do this
248          when building pcre_compile.c with PCRE_DEBUG set, because it doesn't then
249          know the size of PRIV(OP_lengths). */
250    
251    #ifdef COMPILING_PCRETEST
252          case OP_TABLE_LENGTH:
253          case OP_TABLE_LENGTH +
254            ((sizeof(OP_names)/sizeof(const char *) == OP_TABLE_LENGTH) &&
255            (sizeof(PRIV(OP_lengths)) == OP_TABLE_LENGTH)):
256          break;
257    #endif
258    /* ========================================================================== */
259    
260      case OP_END:      case OP_END:
261      fprintf(f, "    %s\n", OP_names[*code]);      fprintf(f, "    %s\n", OP_names[*code]);
262      fprintf(f, "------------------------------------------------------------------\n");      fprintf(f, "------------------------------------------------------------------\n");
263      return;      return;
264    
     case OP_OPT:  
     fprintf(f, " %.2x %s", code[1], OP_names[*code]);  
     break;  
   
265      case OP_CHAR:      case OP_CHAR:
266      fprintf(f, "    ");      fprintf(f, "    ");
267      do      do
268        {        {
269        code++;        code++;
270        code += 1 + print_char(f, code, utf8);        code += 1 + print_char(f, code, utf);
271        }        }
272      while (*code == OP_CHAR);      while (*code == OP_CHAR);
273      fprintf(f, "\n");      fprintf(f, "\n");
274      continue;      continue;
275    
276      case OP_CHARNC:      case OP_CHARI:
277      fprintf(f, " NC ");      fprintf(f, " /i ");
278      do      do
279        {        {
280        code++;        code++;
281        code += 1 + print_char(f, code, utf8);        code += 1 + print_char(f, code, utf);
282        }        }
283      while (*code == OP_CHARNC);      while (*code == OP_CHARI);
284      fprintf(f, "\n");      fprintf(f, "\n");
285      continue;      continue;
286    
287      case OP_CBRA:      case OP_CBRA:
288        case OP_CBRAPOS:
289      case OP_SCBRA:      case OP_SCBRA:
290        case OP_SCBRAPOS:
291      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
292        else fprintf(f, "    ");        else fprintf(f, "    ");
293      fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE));      fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE));
294      break;      break;
295    
296      case OP_BRA:      case OP_BRA:
297        case OP_BRAPOS:
298      case OP_SBRA:      case OP_SBRA:
299        case OP_SBRAPOS:
300      case OP_KETRMAX:      case OP_KETRMAX:
301      case OP_KETRMIN:      case OP_KETRMIN:
302        case OP_KETRPOS:
303      case OP_ALT:      case OP_ALT:
304      case OP_KET:      case OP_KET:
305      case OP_ASSERT:      case OP_ASSERT:
# Line 234  for(;;) Line 307  for(;;)
307      case OP_ASSERTBACK:      case OP_ASSERTBACK:
308      case OP_ASSERTBACK_NOT:      case OP_ASSERTBACK_NOT:
309      case OP_ONCE:      case OP_ONCE:
310        case OP_ONCE_NC:
311      case OP_COND:      case OP_COND:
312      case OP_SCOND:      case OP_SCOND:
313      case OP_REVERSE:      case OP_REVERSE:
314      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
315        else fprintf(f, "    ");        else fprintf(f, "    ");
316      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", OP_names[*code]);
317      break;      break;
318    
319        case OP_CLOSE:
320        fprintf(f, "    %s %d", OP_names[*code], GET2(code, 1));
321        break;
322    
323      case OP_CREF:      case OP_CREF:
324        case OP_NCREF:
325      fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);      fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);
326      break;      break;
327    
# Line 254  for(;;) Line 333  for(;;)
333        fprintf(f, "    Cond recurse %d", c);        fprintf(f, "    Cond recurse %d", c);
334      break;      break;
335    
336        case OP_NRREF:
337        c = GET2(code, 1);
338        if (c == RREF_ANY)
339          fprintf(f, "    Cond nrecurse any");
340        else
341          fprintf(f, "    Cond nrecurse %d", c);
342        break;
343    
344      case OP_DEF:      case OP_DEF:
345      fprintf(f, "    Cond def");      fprintf(f, "    Cond def");
346      break;      break;
347    
348        case OP_STARI:
349        case OP_MINSTARI:
350        case OP_POSSTARI:
351        case OP_PLUSI:
352        case OP_MINPLUSI:
353        case OP_POSPLUSI:
354        case OP_QUERYI:
355        case OP_MINQUERYI:
356        case OP_POSQUERYI:
357        flag = "/i";
358        /* Fall through */
359      case OP_STAR:      case OP_STAR:
360      case OP_MINSTAR:      case OP_MINSTAR:
361      case OP_POSSTAR:      case OP_POSSTAR:
# Line 276  for(;;) Line 374  for(;;)
374      case OP_TYPEQUERY:      case OP_TYPEQUERY:
375      case OP_TYPEMINQUERY:      case OP_TYPEMINQUERY:
376      case OP_TYPEPOSQUERY:      case OP_TYPEPOSQUERY:
377      fprintf(f, "    ");      fprintf(f, " %s ", flag);
378      if (*code >= OP_TYPESTAR)      if (*code >= OP_TYPESTAR)
379        {        {
380        fprintf(f, "%s", OP_names[code[1]]);        fprintf(f, "%s", OP_names[code[1]]);
# Line 286  for(;;) Line 384  for(;;)
384          extra = 2;          extra = 2;
385          }          }
386        }        }
387      else extra = print_char(f, code+1, utf8);      else extra = print_char(f, code+1, utf);
388      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", OP_names[*code]);
389      break;      break;
390    
391        case OP_EXACTI:
392        case OP_UPTOI:
393        case OP_MINUPTOI:
394        case OP_POSUPTOI:
395        flag = "/i";
396        /* Fall through */
397      case OP_EXACT:      case OP_EXACT:
398      case OP_UPTO:      case OP_UPTO:
399      case OP_MINUPTO:      case OP_MINUPTO:
400      case OP_POSUPTO:      case OP_POSUPTO:
401      fprintf(f, "    ");      fprintf(f, " %s ", flag);
402      extra = print_char(f, code+3, utf8);      extra = print_char(f, code + 1 + IMM2_SIZE, utf);
403      fprintf(f, "{");      fprintf(f, "{");
404      if (*code != OP_EXACT) fprintf(f, "0,");      if (*code != OP_EXACT && *code != OP_EXACTI) fprintf(f, "0,");
405      fprintf(f, "%d}", GET2(code,1));      fprintf(f, "%d}", GET2(code,1));
406      if (*code == OP_MINUPTO) fprintf(f, "?");      if (*code == OP_MINUPTO || *code == OP_MINUPTOI) fprintf(f, "?");
407        else if (*code == OP_POSUPTO) fprintf(f, "+");        else if (*code == OP_POSUPTO || *code == OP_POSUPTOI) fprintf(f, "+");
408      break;      break;
409    
410      case OP_TYPEEXACT:      case OP_TYPEEXACT:
411      case OP_TYPEUPTO:      case OP_TYPEUPTO:
412      case OP_TYPEMINUPTO:      case OP_TYPEMINUPTO:
413      case OP_TYPEPOSUPTO:      case OP_TYPEPOSUPTO:
414      fprintf(f, "    %s", OP_names[code[3]]);      fprintf(f, "    %s", OP_names[code[1 + IMM2_SIZE]]);
415      if (code[3] == OP_PROP || code[3] == OP_NOTPROP)      if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
416        {        {
417        fprintf(f, " %s ", get_ucpname(code[4], code[5]));        fprintf(f, " %s ", get_ucpname(code[1 + IMM2_SIZE + 1],
418            code[1 + IMM2_SIZE + 2]));
419        extra = 2;        extra = 2;
420        }        }
421      fprintf(f, "{");      fprintf(f, "{");
# Line 320  for(;;) Line 425  for(;;)
425        else if (*code == OP_TYPEPOSUPTO) fprintf(f, "+");        else if (*code == OP_TYPEPOSUPTO) fprintf(f, "+");
426      break;      break;
427    
428        case OP_NOTI:
429        flag = "/i";
430        /* Fall through */
431      case OP_NOT:      case OP_NOT:
432      c = code[1];      c = code[1];
433      if (PRINTABLE(c)) fprintf(f, "    [^%c]", c);      if (PRINTABLE(c)) fprintf(f, " %s [^%c]", flag, c);
434        else fprintf(f, "    [^\\x%02x]", c);        else fprintf(f, " %s [^\\x%02x]", flag, c);
435      break;      break;
436    
437        case OP_NOTSTARI:
438        case OP_NOTMINSTARI:
439        case OP_NOTPOSSTARI:
440        case OP_NOTPLUSI:
441        case OP_NOTMINPLUSI:
442        case OP_NOTPOSPLUSI:
443        case OP_NOTQUERYI:
444        case OP_NOTMINQUERYI:
445        case OP_NOTPOSQUERYI:
446        flag = "/i";
447        /* Fall through */
448    
449      case OP_NOTSTAR:      case OP_NOTSTAR:
450      case OP_NOTMINSTAR:      case OP_NOTMINSTAR:
451      case OP_NOTPOSSTAR:      case OP_NOTPOSSTAR:
# Line 336  for(;;) Line 456  for(;;)
456      case OP_NOTMINQUERY:      case OP_NOTMINQUERY:
457      case OP_NOTPOSQUERY:      case OP_NOTPOSQUERY:
458      c = code[1];      c = code[1];
459      if (PRINTABLE(c)) fprintf(f, "    [^%c]", c);      if (PRINTABLE(c)) fprintf(f, " %s [^%c]", flag, c);
460        else fprintf(f, "    [^\\x%02x]", c);        else fprintf(f, " %s [^\\x%02x]", flag, c);
461      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", OP_names[*code]);
462      break;      break;
463    
464        case OP_NOTEXACTI:
465        case OP_NOTUPTOI:
466        case OP_NOTMINUPTOI:
467        case OP_NOTPOSUPTOI:
468        flag = "/i";
469        /* Fall through */
470    
471      case OP_NOTEXACT:      case OP_NOTEXACT:
472      case OP_NOTUPTO:      case OP_NOTUPTO:
473      case OP_NOTMINUPTO:      case OP_NOTMINUPTO:
474      case OP_NOTPOSUPTO:      case OP_NOTPOSUPTO:
475      c = code[3];      c = code[1 + IMM2_SIZE];
476      if (PRINTABLE(c)) fprintf(f, "    [^%c]{", c);      if (PRINTABLE(c)) fprintf(f, " %s [^%c]{", flag, c);
477        else fprintf(f, "    [^\\x%02x]{", c);        else fprintf(f, " %s [^\\x%02x]{", flag, c);
478      if (*code != OP_NOTEXACT) fprintf(f, "0,");      if (*code != OP_NOTEXACT && *code != OP_NOTEXACTI) fprintf(f, "0,");
479      fprintf(f, "%d}", GET2(code,1));      fprintf(f, "%d}", GET2(code,1));
480      if (*code == OP_NOTMINUPTO) fprintf(f, "?");      if (*code == OP_NOTMINUPTO || *code == OP_NOTMINUPTOI) fprintf(f, "?");
481        else if (*code == OP_NOTPOSUPTO) fprintf(f, "+");        else
482        if (*code == OP_NOTPOSUPTO || *code == OP_NOTPOSUPTOI) fprintf(f, "+");
483      break;      break;
484    
485      case OP_RECURSE:      case OP_RECURSE:
486      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
487        else fprintf(f, "    ");        else fprintf(f, "    ");
488      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", OP_names[*code]);
489      break;      break;
490    
491        case OP_REFI:
492        flag = "/i";
493        /* Fall through */
494      case OP_REF:      case OP_REF:
495      fprintf(f, "    \\%d", GET2(code,1));      fprintf(f, " %s \\%d", flag, GET2(code,1));
496      ccode = code + _pcre_OP_lengths[*code];      ccode = code + PRIV(OP_lengths)[*code];
497      goto CLASS_REF_REPEAT;      goto CLASS_REF_REPEAT;
498    
499      case OP_CALLOUT:      case OP_CALLOUT:
# Line 375  for(;;) Line 506  for(;;)
506      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]));
507      break;      break;
508    
509      /* 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
510      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
511      #ifdefs. */      all those #ifdefs. */
512    
513      case OP_CLASS:      case OP_CLASS:
514      case OP_NCLASS:      case OP_NCLASS:
# Line 385  for(;;) Line 516  for(;;)
516        {        {
517        int i, min, max;        int i, min, max;
518        BOOL printmap;        BOOL printmap;
519          pcre_uint8 *map;
520    
521        fprintf(f, "    [");        fprintf(f, "    [");
522    
# Line 405  for(;;) Line 537  for(;;)
537    
538        if (printmap)        if (printmap)
539          {          {
540            map = (pcre_uint8 *)ccode;
541          for (i = 0; i < 256; i++)          for (i = 0; i < 256; i++)
542            {            {
543            if ((ccode[i/8] & (1 << (i&7))) != 0)            if ((map[i/8] & (1 << (i&7))) != 0)
544              {              {
545              int j;              int j;
546              for (j = i+1; j < 256; j++)              for (j = i+1; j < 256; j++)
547                if ((ccode[j/8] & (1 << (j&7))) == 0) break;                if ((map[j/8] & (1 << (j&7))) == 0) break;
548              if (i == '-' || i == ']') fprintf(f, "\\");              if (i == '-' || i == ']') fprintf(f, "\\");
549              if (PRINTABLE(i)) fprintf(f, "%c", i);              if (PRINTABLE(i)) fprintf(f, "%c", i);
550                else fprintf(f, "\\x%02x", i);                else fprintf(f, "\\x%02x", i);
# Line 425  for(;;) Line 558  for(;;)
558              i = j;              i = j;
559              }              }
560            }            }
561          ccode += 32;          ccode += 32 / sizeof(pcre_uchar);
562          }          }
563    
564        /* For an XCLASS there is always some additional data */        /* For an XCLASS there is always some additional data */
# Line 459  for(;;) Line 592  for(;;)
592            }            }
593          }          }
594    
595        /* Indicate a non-UTF8 class which was created by negation */        /* Indicate a non-UTF class which was created by negation */
596    
597        fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : "");        fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : "");
598    
# Line 475  for(;;) Line 608  for(;;)
608          case OP_CRQUERY:          case OP_CRQUERY:
609          case OP_CRMINQUERY:          case OP_CRMINQUERY:
610          fprintf(f, "%s", OP_names[*ccode]);          fprintf(f, "%s", OP_names[*ccode]);
611          extra += _pcre_OP_lengths[*ccode];          extra += PRIV(OP_lengths)[*ccode];
612          break;          break;
613    
614          case OP_CRRANGE:          case OP_CRRANGE:
615          case OP_CRMINRANGE:          case OP_CRMINRANGE:
616          min = GET2(ccode,1);          min = GET2(ccode,1);
617          max = GET2(ccode,3);          max = GET2(ccode,1 + IMM2_SIZE);
618          if (max == 0) fprintf(f, "{%d,}", min);          if (max == 0) fprintf(f, "{%d,}", min);
619          else fprintf(f, "{%d,%d}", min, max);          else fprintf(f, "{%d,%d}", min, max);
620          if (*ccode == OP_CRMINRANGE) fprintf(f, "?");          if (*ccode == OP_CRMINRANGE) fprintf(f, "?");
621          extra += _pcre_OP_lengths[*ccode];          extra += PRIV(OP_lengths)[*ccode];
622          break;          break;
623    
624          /* 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 630  for(;;)
630        }        }
631      break;      break;
632    
633      /* Anything else is just an item with no data*/      case OP_MARK:
634        case OP_PRUNE_ARG:
635        case OP_SKIP_ARG:
636        case OP_THEN_ARG:
637        fprintf(f, "    %s ", OP_names[*code]);
638        print_puchar(f, code + 2);
639        extra += code[1];
640        break;
641    
642      default:      case OP_THEN:
643      fprintf(f, "    %s", OP_names[*code]);      fprintf(f, "    %s", OP_names[*code]);
644      break;      break;
645    
646        case OP_CIRCM:
647        case OP_DOLLM:
648        flag = "/m";
649        /* Fall through */
650    
651        /* Anything else is just an item with no data, but possibly a flag. */
652    
653        default:
654        fprintf(f, " %s %s", flag, OP_names[*code]);
655        break;
656      }      }
657    
658    code += _pcre_OP_lengths[*code] + extra;    code += PRIV(OP_lengths)[*code] + extra;
659    fprintf(f, "\n");    fprintf(f, "\n");
660    }    }
661  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.5