summary refs log tree commit diff
path: root/src/bltin/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bltin/test.c')
-rw-r--r--src/bltin/test.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/bltin/test.c b/src/bltin/test.c
index 89d8d86..32a12fe 100644
--- a/src/bltin/test.c
+++ b/src/bltin/test.c
@@ -232,24 +232,31 @@ syntax(const char *op, const char *msg)
 static int
 oexpr(enum token n)
 {
-	int res;
-
-	res = aexpr(n);
-	if (t_lex(*++t_wp) == BOR)
-		return oexpr(t_lex(*++t_wp)) || res;
-	t_wp--;
+	int res = 0;
+
+	for (;;) {
+		res |= aexpr(n);
+		n = t_lex(t_wp[1]);
+		if (n != BOR)
+			break;
+		n = t_lex(*(t_wp += 2));
+	}
 	return res;
 }
 
 static int
 aexpr(enum token n)
 {
-	int res;
-
-	res = nexpr(n);
-	if (t_lex(*++t_wp) == BAND)
-		return aexpr(t_lex(*++t_wp)) && res;
-	t_wp--;
+	int res = 1;
+
+	for (;;) {
+		if (!nexpr(n))
+			res = 0;
+		n = t_lex(t_wp[1]);
+		if (n != BAND)
+			break;
+		n = t_lex(*(t_wp += 2));
+	}
 	return res;
 }