Hi Gerd
In ValueBuilder
we receive the string " substring:1:14"
(with the leading blank) and that is not removed, so we don't match
OK, so this works if you quote the argument:
'${rcnname | substring:"1:14"}'
but not with the old syntax.
The attached patch fixes this and I think it is safe against
breaking existing styles. If it does break old styles, then
it will have to be un-applied - in general the old syntax
is ambiguous.
I've added an error check for when an unknown filter is seen,
which should make it obvious when something like this happens.
..Steve
Index: src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java (revision 3352)
+++ src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java (revision )
@@ -24,6 +24,7 @@
import java.util.regex.Pattern;
import uk.me.parabola.mkgmap.reader.osm.Element;
+import uk.me.parabola.mkgmap.scan.SyntaxException;
/**
* Build a value that can have tag values substituted in it.
@@ -37,7 +38,7 @@
Pattern.compile("[ \t]*([^: \\t|]+:'[^']+')[ \t]*"),
// This must be last
- Pattern.compile("([ \t]*[^: \\t|]+:[^|]*)"),
+ Pattern.compile("[ \t]*([^: \\t|]+:[^|]*)"),
};
private final List<ValueItem> items = new ArrayList<>();
@@ -224,6 +225,8 @@
case "part":
item.addFilter(new PartFilter(arg));
break;
+ default:
+ throw new SyntaxException(String.format("Unknown filter '%s'", cmd));
}
}
Index: test/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilderTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilderTest.java (revision 3352)
+++ test/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilderTest.java (revision )
@@ -130,6 +130,20 @@
assertEquals("substitutions in name", "x|y w|w", s);
}
+ /**
+ * Test that you can use a space before the
+ */
+ @Test
+ public void testSpacedArgsOldSyntax() {
+ ValueBuilder vb = new ValueBuilder("{ name '${rcnname | substring:1:14}' }");
+ Element el = new Way(1);
+
+ el.addTag("rcnname", "1234567890123456789");
+
+ String s = vb.build(el, null);
+ assertEquals("value is trimmed", "{ name '2345678901234' }", s);
+ }
+
@Test
public void testQuotedSplitLines() {
String value =
Index: src/uk/me/parabola/mkgmap/osmstyle/actions/SubstringFilter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/actions/SubstringFilter.java (revision 3352)
+++ src/uk/me/parabola/mkgmap/osmstyle/actions/SubstringFilter.java (revision )
@@ -50,7 +50,7 @@
args = 0;
}
} catch (NumberFormatException e) {
- throw new ExitException("Not valid numbers in style substring command: " + arg);
+ throw new ExitException(String.format("Numbers not valid in style substring command: '%s'", arg));
}
}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev