regexp: Dump character class definitions in -DTEST build.

This commit is contained in:
Tor Andersson
2021-03-23 14:34:02 +01:00
parent 94000c669a
commit 7ebc570d01

View File

@@ -809,6 +809,21 @@ static void dumpnode(Renode *node)
}
}
static void dumpcclass(Reclass *cc) {
Rune *p;
for (p = cc->spans; p < cc->end; p += 2) {
if (p[0] > 32 && p[0] < 127)
printf(" %c", p[0]);
else
printf(" \\x%02x", p[0]);
if (p[1] > 32 && p[1] < 127)
printf("-%c", p[1]);
else
printf("-\\x%02x", p[1]);
}
putchar('\n');
}
static void dumpprog(Reprog *prog)
{
Reinst *inst;
@@ -824,8 +839,8 @@ static void dumpprog(Reprog *prog)
case I_ANY: puts("any"); break;
case I_ANYNL: puts("anynl"); break;
case I_CHAR: printf(inst->c >= 32 && inst->c < 127 ? "char '%c'\n" : "char U+%04X\n", inst->c); break;
case I_CCLASS: puts("cclass"); break;
case I_NCCLASS: puts("ncclass"); break;
case I_CCLASS: printf("cclass"); dumpcclass(inst->cc); break;
case I_NCCLASS: printf("ncclass"); dumpcclass(inst->cc); break;
case I_REF: printf("ref %d\n", inst->n); break;
case I_BOL: puts("bol"); break;
case I_EOL: puts("eol"); break;