History

regexp: Dump character class definitions in -DTEST build.

Tor Andersson committed 5 years ago

Commit 7ebc5701 parent 94000c61 file · +17 −2Browse files

Unified · Split

regexp.c+17−2
@@ -809,6 +809,21 @@ static void dumpnode(Renode *node) · 808 unmodified lines
809809 }
810810 }
811811
812+static void dumpcclass(Reclass *cc) {
813+ Rune *p;
814+ for (p = cc->spans; p < cc->end; p += 2) {
815+ if (p[0] > 32 && p[0] < 127)
816+ printf(" %c", p[0]);
817+ else
818+ printf(" \\x%02x", p[0]);
819+ if (p[1] > 32 && p[1] < 127)
820+ printf("-%c", p[1]);
821+ else
822+ printf("-\\x%02x", p[1]);
823+ }
824+ putchar('\n');
825+}
826+
812827 static void dumpprog(Reprog *prog)
813828 {
814829 Reinst *inst;
@@ -824,8 +839,8 @@ static void dumpprog(Reprog *prog) · 9 unmodified lines
824839 case I_ANY: puts("any"); break;
825840 case I_ANYNL: puts("anynl"); break;
826841 case I_CHAR: printf(inst->c >= 32 && inst->c < 127 ? "char '%c'\n" : "char U+%04X\n", inst->c); break;
827− case I_CCLASS: puts("cclass"); break;
828− case I_NCCLASS: puts("ncclass"); break;
842+ case I_CCLASS: printf("cclass"); dumpcclass(inst->cc); break;
843+ case I_NCCLASS: printf("ncclass"); dumpcclass(inst->cc); break;
829844 case I_REF: printf("ref %d\n", inst->n); break;
830845 case I_BOL: puts("bol"); break;
831846 case I_EOL: puts("eol"); break;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t