patch for style file reader crash

Hi Gerd, please find attached a small patch for preventing a crash when two regular expressions are used but the 'and' or 'or' separating them is missing, for example: landuse=meadow & (name~'[Mm]eadow' name~'[Ff]ield') {delete name;} The existing code crashes with the following trace: java.lang.AssertionError at uk.me.parabola.mkgmap.osmstyle.eval.RegexOp.setSecond(RegexOp.java:49) at uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader.runOp(ExpressionReader. java:180) at uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader.saveOp(ExpressionReader .java:143) at uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader.readConditions(Expressi onReader.java:62) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.loadFile(RuleFileReader.java:1 15) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.load(RuleFileReader.java:86) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.readRules(StyleImpl.java:302) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.<init>(StyleImpl.java:160) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.readStyle(StyleImpl.java:554) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.createConverter(OsmMapData Source.java:289) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.setupHandler(OsmMapDataSou rce.java:187) at uk.me.parabola.mkgmap.reader.osm.o5m.O5mBinMapDataSource.load(O5mBinMapDataS ource.java:43) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.load(OsmMapDataSource.java :138) at uk.me.parabola.mkgmap.main.MapMaker.loadFromFile(MapMaker.java:154) at uk.me.parabola.mkgmap.main.MapMaker.makeMap(MapMaker.java:52) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:265) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:261) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) With the patch, I get an error message as follows: Error in style: Error: (points:76): Invalid arguments to REGEX: FUNCTION ($[Mm]eadow) and REGEX (($name~'[Ff]ield')) (Actually I get the message 4 times, but that is a minor issue.) I have moved 3 lines of code from before various syntax checks to after the checks. Please try the patch and commit if happy. Thanks, Mike

Hi Mike, thanks for the patch, looks good to me. Regarding the number of messages: I guess that depends on the max-jobs option. It is quite difficult to change that. If I hear no complains I'll commit it next thursday. Gerd ________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Mike Baggaley <mike@tvage.co.uk> Gesendet: Sonntag, 5. Februar 2017 23:08:30 An: 'Development list for mkgmap' Betreff: [mkgmap-dev] patch for style file reader crash Hi Gerd, please find attached a small patch for preventing a crash when two regular expressions are used but the 'and' or 'or' separating them is missing, for example: landuse=meadow & (name~'[Mm]eadow' name~'[Ff]ield') {delete name;} The existing code crashes with the following trace: java.lang.AssertionError at uk.me.parabola.mkgmap.osmstyle.eval.RegexOp.setSecond(RegexOp.java:49) at uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader.runOp(ExpressionReader. java:180) at uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader.saveOp(ExpressionReader .java:143) at uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader.readConditions(Expressi onReader.java:62) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.loadFile(RuleFileReader.java:1 15) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.load(RuleFileReader.java:86) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.readRules(StyleImpl.java:302) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.<init>(StyleImpl.java:160) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.readStyle(StyleImpl.java:554) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.createConverter(OsmMapData Source.java:289) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.setupHandler(OsmMapDataSou rce.java:187) at uk.me.parabola.mkgmap.reader.osm.o5m.O5mBinMapDataSource.load(O5mBinMapDataS ource.java:43) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.load(OsmMapDataSource.java :138) at uk.me.parabola.mkgmap.main.MapMaker.loadFromFile(MapMaker.java:154) at uk.me.parabola.mkgmap.main.MapMaker.makeMap(MapMaker.java:52) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:265) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:261) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) With the patch, I get an error message as follows: Error in style: Error: (points:76): Invalid arguments to REGEX: FUNCTION ($[Mm]eadow) and REGEX (($name~'[Ff]ield')) (Actually I get the message 4 times, but that is a minor issue.) I have moved 3 lines of code from before various syntax checks to after the checks. Please try the patch and commit if happy. Thanks, Mike
participants (2)
-
Gerd Petermann
-
Mike Baggaley