Hi
@Steve: I know that this part in TokenScanner is critical, so I don't dare to change it: if (c == '\n' || c == '\r') { while ((c = readChar()) == '\n' || c == '\r') val.append(c); .. }
The attached patch fixes this, I believe. ..Steve
Index: test/uk/me/parabola/mkgmap/scan/TokenScannerTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- test/uk/me/parabola/mkgmap/scan/TokenScannerTest.java (revision 3122) +++ test/uk/me/parabola/mkgmap/scan/TokenScannerTest.java (revision ) @@ -64,6 +64,20 @@ assertEquals(2, ts.getLinenumber()); } + @Test + public void testLinenumberBlankLines() throws Exception { + String s = "hello world\n\nnext tokens\n"; + TokenScanner ts = new TokenScanner("", new StringReader(s)); + ts.readLine(); + + // still on first line + assertEquals(1, ts.getLinenumber()); + + // now next line, which is line three in the file as blank line is skipped + ts.nextValue(); + assertEquals(3, ts.getLinenumber()); + } + /** * This is a misfeature of skipSpace, but relied on everywhere. */ Index: src/uk/me/parabola/mkgmap/scan/TokenScanner.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- src/uk/me/parabola/mkgmap/scan/TokenScanner.java (revision 3122) +++ src/uk/me/parabola/mkgmap/scan/TokenScanner.java (revision ) @@ -178,13 +178,15 @@ val.append((char) c); TokType tt; - if (c == '\n' || c == '\r') { - while ((c = readChar()) == '\n' || c == '\r') - val.append(c); + if (c == '\r') { + c = readChar(); + if (c != '\n') - pushback = c; + pushback = c; tt = TokType.EOL; + } else if (c == '\n') { + tt = TokType.EOL; } else if (isSpace(c)) { - while (isSpace(c = readChar()) && (c != '\n' && c != '\r')) + while (isSpace(c = readChar()) && c != '\n') val.append((char) c); pushback = c;
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev