shithub: mc

Download patch

ref: f468624badf571a70dcab63d905a5f0182a2a313
parent: 8a46d62744d2969ba9c3488672027509f00fdb4b
author: Ori Bernstein <[email protected]>
date: Wed Oct 23 10:59:00 EDT 2013

Use correct percent specifiers

--- a/interp.myr
+++ b/interp.myr
@@ -62,7 +62,7 @@
 	match re.prog[thr.ip]
 	/* Char matching. Consume exactly one byte from the string. */
 	`Ibyte b:
-		trace(re, "\t%i:\tByte %b\n", thr.ip, b)
+		trace(re, "\t%z:\tByte %b\n", thr.ip, b)
 		if !in(re, str)
 			kill(re, tid, "end of string")
 		elif b != str[re.strp]
@@ -73,7 +73,7 @@
 		;;
 		;;
 	`Irange (start, end):
-		trace(re, "\t%i:\tRange (%b, %b)\t", thr.ip, start, end)
+		trace(re, "\t%z:\tRange (%b, %b)\t", thr.ip, start, end)
 		if !in(re, str) || start > str[re.strp] || end < str[re.strp]
 			kill(re, tid, "bad range")
 		else
@@ -81,7 +81,7 @@
 		;;
 		;;
 	`Idot:
-		trace(re, "\t%i:\tDot\n", thr.ip)
+		trace(re, "\t%z:\tDot\n", thr.ip)
 		if in(re, str)
 			kill(re, tid, "past end")
 		else
@@ -93,7 +93,7 @@
 	  exactly one byte is consumed from the string.
 	 */
 	`Ibol:
-		trace(re, "\t%i:\tBol\n", thr.ip)
+		trace(re, "\t%z:\tBol\n", thr.ip)
 		if re.strp == 0 || str[re.strp -1] == 0x10
 			thr.ip++
 			step(re, tid)
@@ -102,7 +102,7 @@
 		;;
 		;;
 	`Ieol:
-		trace(re, "\t%i:\tEol\n", thr.ip)
+		trace(re, "\t%z:\tEol\n", thr.ip)
 		if re.strp == str.len || str[re.strp] == 0x10
 			step(re, tid)
 		else
@@ -110,7 +110,7 @@
 		;;
 		;;
 	`Ilbra	m:
-		trace(re, "\t%i:\tLbra %z\n", thr.ip, m)
+		trace(re, "\t%z:\tLbra %z\n", thr.ip, m)
 		trace(re, "\t\tmatch start = %z\n", re.strp)
 		thr.mstart[m] = re.strp
 		thr.ip++
@@ -117,13 +117,13 @@
 		step(re, tid)
 		;;
 	`Irbra	m:
-		trace(re, "\t%i:\tRbra %z\n", thr.ip, m)
+		trace(re, "\t%z:\tRbra %z\n", thr.ip, m)
 		thr.mend[m] = re.strp
 		thr.ip++
 		step(re, tid)
 		;;
 	`Ifork	(lip, rip):
-		trace(re, "\t%i:\tFork (%z, %z)\n", thr.ip, rip, lip)
+		trace(re, "\t%z:\tFork (%z, %z)\n", thr.ip, rip, lip)
 		mstart = std.sldup(thr.mstart)
 		mend = std.sldup(thr.mend)
 		jmp(re, tid, rip)
@@ -130,11 +130,11 @@
 		fork(re, thr, lip, mstart, mend)
 		;;
 	`Ijmp ip:
-		trace(re, "\t%i:\tJmp %z\n", thr.ip, ip)
+		trace(re, "\t%z:\tJmp %z\n", thr.ip, ip)
 		jmp(re, tid, ip)
 		;;
 	`Imatch:
-		trace(re, "\t%i:\tMatch\n", thr.ip)
+		trace(re, "\t%z:\tMatch\n", thr.ip)
 		finish(re, tid)
 		;;
 	;;
--- a/main.myr
+++ b/main.myr
@@ -3,7 +3,7 @@
 
 const main = {
 	var found
-	match regex.compile(".*^a*")
+	match regex.compile("b*\n^a*")
 	`std.Success re:
 		found = regex.exec(re, "b\naaa")
 		std.put("Found = %t: len = %z\n", found, re.strp)