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

Contents of /code/trunk/pcre_printint.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1046 - (show annotations)
Tue Sep 25 16:27:58 2012 UTC (7 years ago) by ph10
File MIME type: text/plain
File size: 20842 byte(s)
All the remaining changes for handling characters with more than one other 
case.
1 /*************************************************
2 * Perl-Compatible Regular Expressions *
3 *************************************************/
4
5 /* PCRE is a library of functions to support regular expressions whose syntax
6 and semantics are as close as possible to those of the Perl 5 language.
7
8 Written by Philip Hazel
9 Copyright (c) 1997-2012 University of Cambridge
10
11 -----------------------------------------------------------------------------
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14
15 * Redistributions of source code must retain the above copyright notice,
16 this list of conditions and the following disclaimer.
17
18 * Redistributions in binary form must reproduce the above copyright
19 notice, this list of conditions and the following disclaimer in the
20 documentation and/or other materials provided with the distribution.
21
22 * Neither the name of the University of Cambridge nor the names of its
23 contributors may be used to endorse or promote products derived from
24 this software without specific prior written permission.
25
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37 -----------------------------------------------------------------------------
38 */
39
40
41 /* This module contains a PCRE private debugging function for printing out the
42 internal form of a compiled regular expression, along with some supporting
43 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
46 (PCRE_DEBUG defined in pcre_internal.h). It is not included in production
47 compiles. In this case PCRE_INCLUDED is defined.
48
49 (2) It is also compiled separately and linked with pcretest.c, which can be
50 asked to print out a compiled regex for debugging purposes. */
51
52 #ifndef PCRE_INCLUDED
53
54 #ifdef HAVE_CONFIG_H
55 #include "config.h"
56 #endif
57
58 /* For pcretest program. */
59 #define PRIV(name) name
60
61 /* We have to include pcre_internal.h because we need the internal info for
62 displaying the results of pcre_study() and we also need to know about the
63 internal macros, structures, and other internal data values; pcretest has
64 "inside information" compared to a program that strictly follows the PCRE API.
65
66 Although pcre_internal.h does itself include pcre.h, we explicitly include it
67 here before pcre_internal.h so that the PCRE_EXP_xxx macros get set
68 appropriately for an application, not for building PCRE. */
69
70 #include "pcre.h"
71 #include "pcre_internal.h"
72
73 /* These are the funtions that are contained within. It doesn't seem worth
74 having a separate .h file just for this. */
75
76 #endif /* PCRE_INCLUDED */
77
78 #ifdef PCRE_INCLUDED
79 static /* Keep the following function as private. */
80 #endif
81 #ifdef COMPILE_PCRE8
82 void pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths);
83 #else
84 void pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths);
85 #endif
86
87 /* Macro that decides whether a character should be output as a literal or in
88 hexadecimal. We don't use isprint() because that can vary from system to system
89 (even without the use of locales) and we want the output always to be the same,
90 for testing purposes. */
91
92 #ifdef EBCDIC
93 #define PRINTABLE(c) ((c) >= 64 && (c) < 255)
94 #else
95 #define PRINTABLE(c) ((c) >= 32 && (c) < 127)
96 #endif
97
98 /* The table of operator names. */
99
100 static const char *priv_OP_names[] = { OP_NAME_LIST };
101
102 /* This table of operator lengths is not actually used by the working code,
103 but its size is needed for a check that ensures it is the correct size for the
104 number of opcodes (thus catching update omissions). */
105
106 static const pcre_uint8 priv_OP_lengths[] = { OP_LENGTHS };
107
108
109
110 /*************************************************
111 * Print single- or multi-byte character *
112 *************************************************/
113
114 static int
115 print_char(FILE *f, pcre_uchar *ptr, BOOL utf)
116 {
117 int c = *ptr;
118
119 #ifndef SUPPORT_UTF
120
121 (void)utf; /* Avoid compiler warning */
122 if (PRINTABLE(c)) fprintf(f, "%c", c);
123 else if (c <= 0x80) fprintf(f, "\\x%02x", c);
124 else fprintf(f, "\\x{%x}", c);
125 return 0;
126
127 #else
128
129 #ifdef COMPILE_PCRE8
130
131 if (!utf || (c & 0xc0) != 0xc0)
132 {
133 if (PRINTABLE(c)) fprintf(f, "%c", c);
134 else if (c < 0x80) fprintf(f, "\\x%02x", c);
135 else fprintf(f, "\\x{%02x}", c);
136 return 0;
137 }
138 else
139 {
140 int i;
141 int a = PRIV(utf8_table4)[c & 0x3f]; /* Number of additional bytes */
142 int s = 6*a;
143 c = (c & PRIV(utf8_table3)[a]) << s;
144 for (i = 1; i <= a; i++)
145 {
146 /* This is a check for malformed UTF-8; it should only occur if the sanity
147 check has been turned off. Rather than swallow random bytes, just stop if
148 we hit a bad one. Print it with \X instead of \x as an indication. */
149
150 if ((ptr[i] & 0xc0) != 0x80)
151 {
152 fprintf(f, "\\X{%x}", c);
153 return i - 1;
154 }
155
156 /* The byte is OK */
157
158 s -= 6;
159 c |= (ptr[i] & 0x3f) << s;
160 }
161 fprintf(f, "\\x{%x}", c);
162 return a;
163 }
164
165 #else
166
167 #ifdef COMPILE_PCRE16
168
169 if (!utf || (c & 0xfc00) != 0xd800)
170 {
171 if (PRINTABLE(c)) fprintf(f, "%c", c);
172 else if (c <= 0x80) fprintf(f, "\\x%02x", c);
173 else fprintf(f, "\\x{%02x}", c);
174 return 0;
175 }
176 else
177 {
178 /* This is a check for malformed UTF-16; it should only occur if the sanity
179 check has been turned off. Rather than swallow a low surrogate, just stop if
180 we hit a bad one. Print it with \X instead of \x as an indication. */
181
182 if ((ptr[1] & 0xfc00) != 0xdc00)
183 {
184 fprintf(f, "\\X{%x}", c);
185 return 0;
186 }
187
188 c = (((c & 0x3ff) << 10) | (ptr[1] & 0x3ff)) + 0x10000;
189 fprintf(f, "\\x{%x}", c);
190 return 1;
191 }
192
193 #endif /* COMPILE_PCRE16 */
194
195 #endif /* COMPILE_PCRE8 */
196
197 #endif /* SUPPORT_UTF */
198 }
199
200 /*************************************************
201 * Print uchar string (regardless of utf) *
202 *************************************************/
203
204 static void
205 print_puchar(FILE *f, PCRE_PUCHAR ptr)
206 {
207 while (*ptr != '\0')
208 {
209 register int c = *ptr++;
210 if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x{%x}", c);
211 }
212 }
213
214 /*************************************************
215 * Find Unicode property name *
216 *************************************************/
217
218 static const char *
219 get_ucpname(int ptype, int pvalue)
220 {
221 #ifdef SUPPORT_UCP
222 int i;
223 for (i = PRIV(utt_size) - 1; i >= 0; i--)
224 {
225 if (ptype == PRIV(utt)[i].type && pvalue == PRIV(utt)[i].value) break;
226 }
227 return (i >= 0)? PRIV(utt_names) + PRIV(utt)[i].name_offset : "??";
228 #else
229 /* It gets harder and harder to shut off unwanted compiler warnings. */
230 ptype = ptype * pvalue;
231 return (ptype == pvalue)? "??" : "??";
232 #endif
233 }
234
235
236 /*************************************************
237 * Print Unicode property value *
238 *************************************************/
239
240 /* "Normal" properties can be printed from tables. The PT_CLIST property is a
241 pseudo-property that contains a pointer to a list of case-equivalent
242 characters. This is used only when UCP support is available and UTF mode is
243 selected. It should never occur otherwise, but just in case it does, have
244 something ready to print. */
245
246 static void
247 print_prop(FILE *f, pcre_uchar *code, const char *before, const char *after)
248 {
249 if (code[1] != PT_CLIST)
250 {
251 fprintf(f, "%s%s %s%s", before, priv_OP_names[*code], get_ucpname(code[1],
252 code[2]), after);
253 }
254 else
255 {
256 const char *not = (*code == OP_PROP)? "" : "not ";
257 #ifndef SUPPORT_UCP
258 fprintf(f, "%s%sclist %d%s", before, not, code[2], after);
259 #else
260 const pcre_uint32 *p = PRIV(ucd_caseless_sets) + code[2];
261 fprintf (f, "%s%sclist", before, not);
262 while (*p < NOTACHAR) fprintf(f, " %04x", *p++);
263 fprintf(f, "%s", after);
264 #endif
265 }
266 }
267
268
269
270
271 /*************************************************
272 * Print compiled regex *
273 *************************************************/
274
275 /* Make this function work for a regex with integers either byte order.
276 However, we assume that what we are passed is a compiled regex. The
277 print_lengths flag controls whether offsets and lengths of items are printed.
278 They can be turned off from pcretest so that automatic tests on bytecode can be
279 written that do not depend on the value of LINK_SIZE. */
280
281 #ifdef PCRE_INCLUDED
282 static /* Keep the following function as private. */
283 #endif
284 #ifdef COMPILE_PCRE8
285 void
286 pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)
287 #else
288 void
289 pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths)
290 #endif
291 {
292 REAL_PCRE *re = (REAL_PCRE *)external_re;
293 pcre_uchar *codestart, *code;
294 BOOL utf;
295
296 unsigned int options = re->options;
297 int offset = re->name_table_offset;
298 int count = re->name_count;
299 int size = re->name_entry_size;
300
301 if (re->magic_number != MAGIC_NUMBER)
302 {
303 offset = ((offset << 8) & 0xff00) | ((offset >> 8) & 0xff);
304 count = ((count << 8) & 0xff00) | ((count >> 8) & 0xff);
305 size = ((size << 8) & 0xff00) | ((size >> 8) & 0xff);
306 options = ((options << 24) & 0xff000000) |
307 ((options << 8) & 0x00ff0000) |
308 ((options >> 8) & 0x0000ff00) |
309 ((options >> 24) & 0x000000ff);
310 }
311
312 code = codestart = (pcre_uchar *)re + offset + count * size;
313 /* PCRE_UTF16 has the same value as PCRE_UTF8. */
314 utf = (options & PCRE_UTF8) != 0;
315
316 for(;;)
317 {
318 pcre_uchar *ccode;
319 const char *flag = " ";
320 int c;
321 int extra = 0;
322
323 if (print_lengths)
324 fprintf(f, "%3d ", (int)(code - codestart));
325 else
326 fprintf(f, " ");
327
328 switch(*code)
329 {
330 /* ========================================================================== */
331 /* These cases are never obeyed. This is a fudge that causes a compile-
332 time error if the vectors OP_names or OP_lengths, which are indexed
333 by opcode, are not the correct length. It seems to be the only way to do
334 such a check at compile time, as the sizeof() operator does not work in
335 the C preprocessor. */
336
337 case OP_TABLE_LENGTH:
338 case OP_TABLE_LENGTH +
339 ((sizeof(priv_OP_names)/sizeof(const char *) == OP_TABLE_LENGTH) &&
340 (sizeof(priv_OP_lengths) == OP_TABLE_LENGTH)):
341 break;
342 /* ========================================================================== */
343
344 case OP_END:
345 fprintf(f, " %s\n", priv_OP_names[*code]);
346 fprintf(f, "------------------------------------------------------------------\n");
347 return;
348
349 case OP_CHAR:
350 fprintf(f, " ");
351 do
352 {
353 code++;
354 code += 1 + print_char(f, code, utf);
355 }
356 while (*code == OP_CHAR);
357 fprintf(f, "\n");
358 continue;
359
360 case OP_CHARI:
361 fprintf(f, " /i ");
362 do
363 {
364 code++;
365 code += 1 + print_char(f, code, utf);
366 }
367 while (*code == OP_CHARI);
368 fprintf(f, "\n");
369 continue;
370
371 case OP_CBRA:
372 case OP_CBRAPOS:
373 case OP_SCBRA:
374 case OP_SCBRAPOS:
375 if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
376 else fprintf(f, " ");
377 fprintf(f, "%s %d", priv_OP_names[*code], GET2(code, 1+LINK_SIZE));
378 break;
379
380 case OP_BRA:
381 case OP_BRAPOS:
382 case OP_SBRA:
383 case OP_SBRAPOS:
384 case OP_KETRMAX:
385 case OP_KETRMIN:
386 case OP_KETRPOS:
387 case OP_ALT:
388 case OP_KET:
389 case OP_ASSERT:
390 case OP_ASSERT_NOT:
391 case OP_ASSERTBACK:
392 case OP_ASSERTBACK_NOT:
393 case OP_ONCE:
394 case OP_ONCE_NC:
395 case OP_COND:
396 case OP_SCOND:
397 case OP_REVERSE:
398 if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
399 else fprintf(f, " ");
400 fprintf(f, "%s", priv_OP_names[*code]);
401 break;
402
403 case OP_CLOSE:
404 fprintf(f, " %s %d", priv_OP_names[*code], GET2(code, 1));
405 break;
406
407 case OP_CREF:
408 case OP_NCREF:
409 fprintf(f, "%3d %s", GET2(code,1), priv_OP_names[*code]);
410 break;
411
412 case OP_RREF:
413 c = GET2(code, 1);
414 if (c == RREF_ANY)
415 fprintf(f, " Cond recurse any");
416 else
417 fprintf(f, " Cond recurse %d", c);
418 break;
419
420 case OP_NRREF:
421 c = GET2(code, 1);
422 if (c == RREF_ANY)
423 fprintf(f, " Cond nrecurse any");
424 else
425 fprintf(f, " Cond nrecurse %d", c);
426 break;
427
428 case OP_DEF:
429 fprintf(f, " Cond def");
430 break;
431
432 case OP_STARI:
433 case OP_MINSTARI:
434 case OP_POSSTARI:
435 case OP_PLUSI:
436 case OP_MINPLUSI:
437 case OP_POSPLUSI:
438 case OP_QUERYI:
439 case OP_MINQUERYI:
440 case OP_POSQUERYI:
441 flag = "/i";
442 /* Fall through */
443 case OP_STAR:
444 case OP_MINSTAR:
445 case OP_POSSTAR:
446 case OP_PLUS:
447 case OP_MINPLUS:
448 case OP_POSPLUS:
449 case OP_QUERY:
450 case OP_MINQUERY:
451 case OP_POSQUERY:
452 case OP_TYPESTAR:
453 case OP_TYPEMINSTAR:
454 case OP_TYPEPOSSTAR:
455 case OP_TYPEPLUS:
456 case OP_TYPEMINPLUS:
457 case OP_TYPEPOSPLUS:
458 case OP_TYPEQUERY:
459 case OP_TYPEMINQUERY:
460 case OP_TYPEPOSQUERY:
461 fprintf(f, " %s ", flag);
462 if (*code >= OP_TYPESTAR)
463 {
464 if (code[1] == OP_PROP || code[1] == OP_NOTPROP)
465 {
466 print_prop(f, code + 1, "", " ");
467 extra = 2;
468 }
469 else fprintf(f, "%s", priv_OP_names[code[1]]);
470 }
471 else extra = print_char(f, code+1, utf);
472 fprintf(f, "%s", priv_OP_names[*code]);
473 break;
474
475 case OP_EXACTI:
476 case OP_UPTOI:
477 case OP_MINUPTOI:
478 case OP_POSUPTOI:
479 flag = "/i";
480 /* Fall through */
481 case OP_EXACT:
482 case OP_UPTO:
483 case OP_MINUPTO:
484 case OP_POSUPTO:
485 fprintf(f, " %s ", flag);
486 extra = print_char(f, code + 1 + IMM2_SIZE, utf);
487 fprintf(f, "{");
488 if (*code != OP_EXACT && *code != OP_EXACTI) fprintf(f, "0,");
489 fprintf(f, "%d}", GET2(code,1));
490 if (*code == OP_MINUPTO || *code == OP_MINUPTOI) fprintf(f, "?");
491 else if (*code == OP_POSUPTO || *code == OP_POSUPTOI) fprintf(f, "+");
492 break;
493
494 case OP_TYPEEXACT:
495 case OP_TYPEUPTO:
496 case OP_TYPEMINUPTO:
497 case OP_TYPEPOSUPTO:
498 if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
499 {
500 print_prop(f, code + IMM2_SIZE + 1, " ", " ");
501 extra = 2;
502 }
503 else fprintf(f, " %s", priv_OP_names[code[1 + IMM2_SIZE]]);
504 fprintf(f, "{");
505 if (*code != OP_TYPEEXACT) fprintf(f, "0,");
506 fprintf(f, "%d}", GET2(code,1));
507 if (*code == OP_TYPEMINUPTO) fprintf(f, "?");
508 else if (*code == OP_TYPEPOSUPTO) fprintf(f, "+");
509 break;
510
511 case OP_NOTI:
512 flag = "/i";
513 /* Fall through */
514 case OP_NOT:
515 fprintf(f, " %s [^", flag);
516 extra = print_char(f, code + 1, utf);
517 fprintf(f, "]");
518 break;
519
520 case OP_NOTSTARI:
521 case OP_NOTMINSTARI:
522 case OP_NOTPOSSTARI:
523 case OP_NOTPLUSI:
524 case OP_NOTMINPLUSI:
525 case OP_NOTPOSPLUSI:
526 case OP_NOTQUERYI:
527 case OP_NOTMINQUERYI:
528 case OP_NOTPOSQUERYI:
529 flag = "/i";
530 /* Fall through */
531
532 case OP_NOTSTAR:
533 case OP_NOTMINSTAR:
534 case OP_NOTPOSSTAR:
535 case OP_NOTPLUS:
536 case OP_NOTMINPLUS:
537 case OP_NOTPOSPLUS:
538 case OP_NOTQUERY:
539 case OP_NOTMINQUERY:
540 case OP_NOTPOSQUERY:
541 fprintf(f, " %s [^", flag);
542 extra = print_char(f, code + 1, utf);
543 fprintf(f, "]%s", priv_OP_names[*code]);
544 break;
545
546 case OP_NOTEXACTI:
547 case OP_NOTUPTOI:
548 case OP_NOTMINUPTOI:
549 case OP_NOTPOSUPTOI:
550 flag = "/i";
551 /* Fall through */
552
553 case OP_NOTEXACT:
554 case OP_NOTUPTO:
555 case OP_NOTMINUPTO:
556 case OP_NOTPOSUPTO:
557 fprintf(f, " %s [^", flag);
558 extra = print_char(f, code + 1 + IMM2_SIZE, utf);
559 fprintf(f, "]{");
560 if (*code != OP_NOTEXACT && *code != OP_NOTEXACTI) fprintf(f, "0,");
561 fprintf(f, "%d}", GET2(code,1));
562 if (*code == OP_NOTMINUPTO || *code == OP_NOTMINUPTOI) fprintf(f, "?");
563 else
564 if (*code == OP_NOTPOSUPTO || *code == OP_NOTPOSUPTOI) fprintf(f, "+");
565 break;
566
567 case OP_RECURSE:
568 if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
569 else fprintf(f, " ");
570 fprintf(f, "%s", priv_OP_names[*code]);
571 break;
572
573 case OP_REFI:
574 flag = "/i";
575 /* Fall through */
576 case OP_REF:
577 fprintf(f, " %s \\%d", flag, GET2(code,1));
578 ccode = code + priv_OP_lengths[*code];
579 goto CLASS_REF_REPEAT;
580
581 case OP_CALLOUT:
582 fprintf(f, " %s %d %d %d", priv_OP_names[*code], code[1], GET(code,2),
583 GET(code, 2 + LINK_SIZE));
584 break;
585
586 case OP_PROP:
587 case OP_NOTPROP:
588 print_prop(f, code, " ", "");
589 break;
590
591 /* OP_XCLASS can only occur in UTF or PCRE16 modes. However, there's no
592 harm in having this code always here, and it makes it less messy without
593 all those #ifdefs. */
594
595 case OP_CLASS:
596 case OP_NCLASS:
597 case OP_XCLASS:
598 {
599 int i, min, max;
600 BOOL printmap;
601 pcre_uint8 *map;
602
603 fprintf(f, " [");
604
605 if (*code == OP_XCLASS)
606 {
607 extra = GET(code, 1);
608 ccode = code + LINK_SIZE + 1;
609 printmap = (*ccode & XCL_MAP) != 0;
610 if ((*ccode++ & XCL_NOT) != 0) fprintf(f, "^");
611 }
612 else
613 {
614 printmap = TRUE;
615 ccode = code + 1;
616 }
617
618 /* Print a bit map */
619
620 if (printmap)
621 {
622 map = (pcre_uint8 *)ccode;
623 for (i = 0; i < 256; i++)
624 {
625 if ((map[i/8] & (1 << (i&7))) != 0)
626 {
627 int j;
628 for (j = i+1; j < 256; j++)
629 if ((map[j/8] & (1 << (j&7))) == 0) break;
630 if (i == '-' || i == ']') fprintf(f, "\\");
631 if (PRINTABLE(i)) fprintf(f, "%c", i);
632 else fprintf(f, "\\x%02x", i);
633 if (--j > i)
634 {
635 if (j != i + 1) fprintf(f, "-");
636 if (j == '-' || j == ']') fprintf(f, "\\");
637 if (PRINTABLE(j)) fprintf(f, "%c", j);
638 else fprintf(f, "\\x%02x", j);
639 }
640 i = j;
641 }
642 }
643 ccode += 32 / sizeof(pcre_uchar);
644 }
645
646 /* For an XCLASS there is always some additional data */
647
648 if (*code == OP_XCLASS)
649 {
650 int ch;
651 while ((ch = *ccode++) != XCL_END)
652 {
653 if (ch == XCL_PROP)
654 {
655 int ptype = *ccode++;
656 int pvalue = *ccode++;
657 fprintf(f, "\\p{%s}", get_ucpname(ptype, pvalue));
658 }
659 else if (ch == XCL_NOTPROP)
660 {
661 int ptype = *ccode++;
662 int pvalue = *ccode++;
663 fprintf(f, "\\P{%s}", get_ucpname(ptype, pvalue));
664 }
665 else
666 {
667 ccode += 1 + print_char(f, ccode, utf);
668 if (ch == XCL_RANGE)
669 {
670 fprintf(f, "-");
671 ccode += 1 + print_char(f, ccode, utf);
672 }
673 }
674 }
675 }
676
677 /* Indicate a non-UTF class which was created by negation */
678
679 fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : "");
680
681 /* Handle repeats after a class or a back reference */
682
683 CLASS_REF_REPEAT:
684 switch(*ccode)
685 {
686 case OP_CRSTAR:
687 case OP_CRMINSTAR:
688 case OP_CRPLUS:
689 case OP_CRMINPLUS:
690 case OP_CRQUERY:
691 case OP_CRMINQUERY:
692 fprintf(f, "%s", priv_OP_names[*ccode]);
693 extra += priv_OP_lengths[*ccode];
694 break;
695
696 case OP_CRRANGE:
697 case OP_CRMINRANGE:
698 min = GET2(ccode,1);
699 max = GET2(ccode,1 + IMM2_SIZE);
700 if (max == 0) fprintf(f, "{%d,}", min);
701 else fprintf(f, "{%d,%d}", min, max);
702 if (*ccode == OP_CRMINRANGE) fprintf(f, "?");
703 extra += priv_OP_lengths[*ccode];
704 break;
705
706 /* Do nothing if it's not a repeat; this code stops picky compilers
707 warning about the lack of a default code path. */
708
709 default:
710 break;
711 }
712 }
713 break;
714
715 case OP_MARK:
716 case OP_PRUNE_ARG:
717 case OP_SKIP_ARG:
718 case OP_THEN_ARG:
719 fprintf(f, " %s ", priv_OP_names[*code]);
720 print_puchar(f, code + 2);
721 extra += code[1];
722 break;
723
724 case OP_THEN:
725 fprintf(f, " %s", priv_OP_names[*code]);
726 break;
727
728 case OP_CIRCM:
729 case OP_DOLLM:
730 flag = "/m";
731 /* Fall through */
732
733 /* Anything else is just an item with no data, but possibly a flag. */
734
735 default:
736 fprintf(f, " %s %s", flag, priv_OP_names[*code]);
737 break;
738 }
739
740 code += priv_OP_lengths[*code] + extra;
741 fprintf(f, "\n");
742 }
743 }
744
745 /* End of pcre_printint.src */

  ViewVC Help
Powered by ViewVC 1.1.5