shithub: libmujs

Download patch

ref: 7ebc570d01d2f503ad42e5b77d46fd47db3aeb95
parent: 94000c669a17a1888d2cdff66116340f0cb3386e
author: Tor Andersson <tor.andersson@artifex.com>
date: Tue Mar 23 10:34:02 EDT 2021

regexp: Dump character class definitions in -DTEST build.

--- a/regexp.c
+++ b/regexp.c
@@ -809,6 +809,21 @@
 	}
 }
 
+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 @@
 		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;