Hi

I've found a fix, attached, and which I shall commit shortly.

Thanks again for reporting this.

..Steve

Index: src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java	(revision 3670)
+++ src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java	(revision )
@@ -272,6 +272,9 @@
 		if (isFinished(op))
 			return op;
 
+		if (op.getFirst().isType(OR))
+			op = distribute(op.getFirst(), op.getSecond());
+
 		if (op.isType(AND)) {
 			// Recursively re-arrange the child nodes
 			rearrangeExpression(op.getFirst());
@@ -352,7 +355,7 @@
 			// Transform ((first | second) & topSecond)
 			// into (first & topSecond) | (second & topSecond)
 
-			return distrubute(op1, top.getSecond());
+			return distribute(op1, top.getSecond());
 		} else {
 			// This shouldn't happen
 			throw new SyntaxException("X3:" + op1.getType());
@@ -360,7 +363,7 @@
 		return top;
 	}
 
-	private static OrOp distrubute(Op op1, Op topSecond) {
+	private static OrOp distribute(Op op1, Op topSecond) {
 		Op first = op1.getFirst();
 		OrOp orOp = new OrOp();
 
@@ -371,7 +374,7 @@
 		BinaryOp and2 = new AndOp();
 		Op second = rearrangeExpression(op1.getSecond());
 		if (second.isType(OR)) {
-			and2 = distrubute(second, topSecond);
+			and2 = distribute(second, topSecond);
 		} else {
 			and2.setFirst(second);
 			and2.setSecond(topSecond);
Index: test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java	(revision 3670)
+++ test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java	(revision )
@@ -1133,6 +1133,27 @@
 		assertNotNull(type);
 	}
 
+	@Test
+	public void testBugOrWithAndOnLeft() {
+		RuleSet rs = makeRuleSet("((a=1&b=2) | a=2) & c!=4 [0x2]");
+		Way w = new Way(1);
+		w.addTag("a", "2");
+
+		GType type = getFirstType(rs, w);
+		assertNotNull(type);
+	}
+
+	@Test
+	public void testBugOrWithAndOnLeft2() {
+		RuleSet rs = makeRuleSet("(((a=1 | a=5)&b=2) | a=2) & c!=4 [0x2]");
+		Way w = new Way(1);
+		w.addTag("a", "2");
+
+		GType type = getFirstType(rs, w);
+		assertNotNull(type);
+		assertEquals(type.getType(), 2);
+	}
+
 	/**
 	 * Get a way with a few points for testing length.
 	 *
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to