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-2005 University of Cambridge |
Copyright (c) 1997-2007 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 |
108 |
if (c < 128) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c); |
if (c < 128) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c); |
109 |
return a; |
return a; |
110 |
} |
} |
111 |
#endif |
#endif |
112 |
} |
} |
113 |
|
|
114 |
|
|
141 |
*************************************************/ |
*************************************************/ |
142 |
|
|
143 |
/* Make this function work for a regex with integers either byte order. |
/* Make this function work for a regex with integers either byte order. |
144 |
However, we assume that what we are passed is a compiled regex. */ |
However, we assume that what we are passed is a compiled regex. The |
145 |
|
print_lengths flag controls whether offsets and lengths of items are printed. |
146 |
|
They can be turned off from pcretest so that automatic tests on bytecode can be |
147 |
|
written that do not depend on the value of LINK_SIZE. */ |
148 |
|
|
149 |
static void |
static void |
150 |
pcre_printint(pcre *external_re, FILE *f) |
pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths) |
151 |
{ |
{ |
152 |
real_pcre *re = (real_pcre *)external_re; |
real_pcre *re = (real_pcre *)external_re; |
153 |
uschar *codestart, *code; |
uschar *codestart, *code; |
178 |
int c; |
int c; |
179 |
int extra = 0; |
int extra = 0; |
180 |
|
|
181 |
fprintf(f, "%3d ", (int)(code - codestart)); |
if (print_lengths) |
182 |
|
fprintf(f, "%3d ", (int)(code - codestart)); |
183 |
|
else |
184 |
|
fprintf(f, " "); |
185 |
|
|
186 |
switch(*code) |
switch(*code) |
187 |
{ |
{ |
218 |
|
|
219 |
case OP_CBRA: |
case OP_CBRA: |
220 |
case OP_SCBRA: |
case OP_SCBRA: |
221 |
fprintf(f, "%3d %s %d", GET(code, 1), OP_names[*code], |
if (print_lengths) fprintf(f, "%3d ", GET(code, 1)); |
222 |
GET2(code, 1+LINK_SIZE)); |
else fprintf(f, " "); |
223 |
|
fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE)); |
224 |
break; |
break; |
225 |
|
|
226 |
case OP_BRA: |
case OP_BRA: |
237 |
case OP_COND: |
case OP_COND: |
238 |
case OP_SCOND: |
case OP_SCOND: |
239 |
case OP_REVERSE: |
case OP_REVERSE: |
240 |
fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]); |
if (print_lengths) fprintf(f, "%3d ", GET(code, 1)); |
241 |
|
else fprintf(f, " "); |
242 |
|
fprintf(f, "%s", OP_names[*code]); |
243 |
break; |
break; |
244 |
|
|
245 |
case OP_CREF: |
case OP_CREF: |
355 |
break; |
break; |
356 |
|
|
357 |
case OP_RECURSE: |
case OP_RECURSE: |
358 |
fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]); |
if (print_lengths) fprintf(f, "%3d ", GET(code, 1)); |
359 |
|
else fprintf(f, " "); |
360 |
|
fprintf(f, "%s", OP_names[*code]); |
361 |
break; |
break; |
362 |
|
|
363 |
case OP_REF: |
case OP_REF: |