diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2012-09-25 16:27:58 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2012-09-25 16:27:58 +0000 |
commit | 4ae7d6630c0ef594c40cd99e2edce450077a2a87 (patch) | |
tree | efcca2fb9b988a34cda732381965fbb31c54048e /pcre_printint.c | |
parent | 05d03818ae1cf4196b9316714f0fd199dfb1b1e2 (diff) | |
download | pcre-4ae7d6630c0ef594c40cd99e2edce450077a2a87.tar.gz |
All the remaining changes for handling characters with more than one other
case.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1046 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre_printint.c')
-rw-r--r-- | pcre_printint.c | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/pcre_printint.c b/pcre_printint.c index 1767172..108d72f 100644 --- a/pcre_printint.c +++ b/pcre_printint.c @@ -120,7 +120,7 @@ int c = *ptr; (void)utf; /* Avoid compiler warning */ if (PRINTABLE(c)) fprintf(f, "%c", c); -else if (c <= 0xff) fprintf(f, "\\x%02x", c); +else if (c <= 0x80) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c); return 0; @@ -233,6 +233,40 @@ return (ptype == pvalue)? "??" : "??"; } +/************************************************* +* Print Unicode property value * +*************************************************/ + +/* "Normal" properties can be printed from tables. The PT_CLIST property is a +pseudo-property that contains a pointer to a list of case-equivalent +characters. This is used only when UCP support is available and UTF mode is +selected. It should never occur otherwise, but just in case it does, have +something ready to print. */ + +static void +print_prop(FILE *f, pcre_uchar *code, const char *before, const char *after) +{ +if (code[1] != PT_CLIST) + { + fprintf(f, "%s%s %s%s", before, priv_OP_names[*code], get_ucpname(code[1], + code[2]), after); + } +else + { + const char *not = (*code == OP_PROP)? "" : "not "; +#ifndef SUPPORT_UCP + fprintf(f, "%s%sclist %d%s", before, not, code[2], after); +#else + const pcre_uint32 *p = PRIV(ucd_caseless_sets) + code[2]; + fprintf (f, "%s%sclist", before, not); + while (*p < NOTACHAR) fprintf(f, " %04x", *p++); + fprintf(f, "%s", after); +#endif + } +} + + + /************************************************* * Print compiled regex * @@ -427,12 +461,12 @@ for(;;) fprintf(f, " %s ", flag); if (*code >= OP_TYPESTAR) { - fprintf(f, "%s", priv_OP_names[code[1]]); if (code[1] == OP_PROP || code[1] == OP_NOTPROP) { - fprintf(f, " %s ", get_ucpname(code[2], code[3])); + print_prop(f, code + 1, "", " "); extra = 2; } + else fprintf(f, "%s", priv_OP_names[code[1]]); } else extra = print_char(f, code+1, utf); fprintf(f, "%s", priv_OP_names[*code]); @@ -461,13 +495,12 @@ for(;;) case OP_TYPEUPTO: case OP_TYPEMINUPTO: case OP_TYPEPOSUPTO: - fprintf(f, " %s", priv_OP_names[code[1 + IMM2_SIZE]]); if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP) { - fprintf(f, " %s ", get_ucpname(code[1 + IMM2_SIZE + 1], - code[1 + IMM2_SIZE + 2])); + print_prop(f, code + IMM2_SIZE + 1, " ", " "); extra = 2; } + else fprintf(f, " %s", priv_OP_names[code[1 + IMM2_SIZE]]); fprintf(f, "{"); if (*code != OP_TYPEEXACT) fprintf(f, "0,"); fprintf(f, "%d}", GET2(code,1)); @@ -552,7 +585,7 @@ for(;;) case OP_PROP: case OP_NOTPROP: - fprintf(f, " %s %s", priv_OP_names[*code], get_ucpname(code[1], code[2])); + print_prop(f, code, " ", ""); break; /* OP_XCLASS can only occur in UTF or PCRE16 modes. However, there's no |