shithub: libmujs

Download patch

ref: 11bcefd541160e6021347086251cea384a215d61
parent: 45e3a319501f29c7a1c52fe062bb0a9ba37c7137
author: Tor Andersson <tor@ccxvii.net>
date: Tue Feb 25 08:40:24 EST 2014

Don't recurse on second branch of "split" instruction.

--- a/regex.c
+++ b/regex.c
@@ -896,22 +896,21 @@
 			continue;
 		case I_SPLIT:
 #if 0
-			// TODO: use I_PROGRESS instead?
 			if (match(g, pc->x, s))
 				return 1;
 			pc = pc->y;
 			continue;
-#else
-			if (pc->p == s) return 0;
+#endif
+			if (pc->p == s)
+				return 0;
 			p = pc->p;
 			pc->p = s;
-			if (match(g, pc->x, s) || match(g, pc->y, s)) {
-				pc->p = p;
-				return 1;
-			}
+			v = match(g, pc->x, s);
 			pc->p = p;
-			return 0;
-#endif
+			if (v)
+				return 1;
+			pc = pc->y;
+			continue;
 		case I_PLA:
 			if (!match(g, pc->x, s))
 				return 0;