X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/d52120f2b5b5464091a61a47fe881a6e8f6ec09f..64f2600a56e0201f23dd3496a499fff6ef22c0c0:/src/src/pcre/pcre_printint.src diff --git a/src/src/pcre/pcre_printint.src b/src/src/pcre/pcre_printint.src index e5407f81b..7e2837b72 100644 --- a/src/src/pcre/pcre_printint.src +++ b/src/src/pcre/pcre_printint.src @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/pcre/pcre_printint.src,v 1.2 2007/01/23 15:08:45 ph10 Exp $ */ +/* $Cambridge: exim/src/src/pcre/pcre_printint.src,v 1.3 2007/06/26 11:16:54 ph10 Exp $ */ /************************************************* * Perl-Compatible Regular Expressions * @@ -8,7 +8,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel - Copyright (c) 1997-2005 University of Cambridge + Copyright (c) 1997-2007 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -73,6 +73,12 @@ print_char(FILE *f, uschar *ptr, BOOL utf8) { int c = *ptr; +#ifndef SUPPORT_UTF8 +utf8 = utf8; /* Avoid compiler warning */ +if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c); +return 0; + +#else if (!utf8 || (c & 0xc0) != 0xc0) { if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c); @@ -104,6 +110,7 @@ else if (c < 128) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c); return a; } +#endif } @@ -136,10 +143,13 @@ return (ptype == pvalue)? "??" : "??"; *************************************************/ /* Make this function work for a regex with integers either byte order. -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 +print_lengths flag controls whether offsets and lengths of items are printed. +They can be turned off from pcretest so that automatic tests on bytecode can be +written that do not depend on the value of LINK_SIZE. */ static void -pcre_printint(pcre *external_re, FILE *f) +pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths) { real_pcre *re = (real_pcre *)external_re; uschar *codestart, *code; @@ -170,7 +180,10 @@ for(;;) int c; int extra = 0; - fprintf(f, "%3d ", (int)(code - codestart)); + if (print_lengths) + fprintf(f, "%3d ", (int)(code - codestart)); + else + fprintf(f, " "); switch(*code) { @@ -207,8 +220,9 @@ for(;;) case OP_CBRA: case OP_SCBRA: - fprintf(f, "%3d %s %d", GET(code, 1), OP_names[*code], - GET2(code, 1+LINK_SIZE)); + if (print_lengths) fprintf(f, "%3d ", GET(code, 1)); + else fprintf(f, " "); + fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE)); break; case OP_BRA: @@ -225,7 +239,9 @@ for(;;) case OP_COND: case OP_SCOND: case OP_REVERSE: - fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]); + if (print_lengths) fprintf(f, "%3d ", GET(code, 1)); + else fprintf(f, " "); + fprintf(f, "%s", OP_names[*code]); break; case OP_CREF: @@ -341,7 +357,9 @@ for(;;) break; case OP_RECURSE: - fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]); + if (print_lengths) fprintf(f, "%3d ", GET(code, 1)); + else fprintf(f, " "); + fprintf(f, "%s", OP_names[*code]); break; case OP_REF: