Skip to content

Commit b5451a8

Browse files
committed
allow spaces before # in dot file comments
Signed-off-by: Stefan Niederhauser <[email protected]>
1 parent b2c265b commit b5451a8

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

graphviz-java/src/main/java/guru/nidi/graphviz/parse/Lexer.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,23 +218,25 @@ private char readRawChar() throws IOException {
218218
doReadRawChar();
219219
if (ch == '\n') {
220220
pos.newLine();
221-
final char next = doReadRawChar();
222-
if (next == '#') {
221+
do {
222+
doReadRawChar();
223+
} while (ch <= ' ');
224+
if (ch == '#') {
223225
do {
224226
doReadRawChar();
225227
} while (ch != '\n' && ch != CH_EOF);
226228
pos.newChar();
227229
} else {
228-
unread('\n', next);
230+
unread('\n', ch);
229231
}
230232
}
231233
}
232234
return ch;
233235
}
234236

235-
private char doReadRawChar() throws IOException {
237+
private void doReadRawChar() throws IOException {
236238
pos.newChar();
237-
return ch = (char) in.read();
239+
ch = (char) in.read();
238240
}
239241

240242
private void unread(char before, char next) throws IOException {

graphviz-java/src/test/java/guru/nidi/graphviz/parse/LexerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void multilineComment() throws IOException {
4646

4747
@Test
4848
void hashComment() throws IOException {
49-
assertTokens("=\n#{} \n=", token(EQUAL, "="), token(EQUAL, "="));
49+
assertTokens("=\n #{} \n=", token(EQUAL, "="), token(EQUAL, "="));
5050
}
5151

5252
@Test

0 commit comments

Comments
 (0)