8318811: Compiler directives parser swallows a character after line comments

Reviewed-by: shade, phh
This commit is contained in:
Volker Simonis 2023-10-27 12:10:55 +00:00
parent 667cca9d7a
commit 141dae8b76
2 changed files with 21 additions and 1 deletions

View File

@ -580,7 +580,7 @@ u_char JSON::skip_line_comment() {
return 0;
}
next();
return next();
return peek();
}
/*

View File

@ -33,6 +33,9 @@
package compiler.compilercontrol.parser;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import compiler.compilercontrol.share.JSONFile;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@ -52,6 +55,7 @@ public class DirectiveParserTest {
emptyFile();
noFile();
directory();
lineCommentTest();
}
private static void simpleTest() {
@ -145,4 +149,20 @@ public class DirectiveParserTest {
Asserts.assertNE(output.getExitValue(), 0, ERROR_MSG + "directory as "
+ "a name");
}
private static void lineCommentTest() {
String fileName = "lineComment.json";
try {
PrintStream out = new PrintStream(fileName);
out.println("[{");
out.println(" match: \"*::*\",");
out.println(" c2: { Exclude: true } // c1 only for startup");
out.println("}]");
out.close();
} catch (FileNotFoundException e) {
throw new Error("TESTBUG: can't open/create file " + fileName, e);
}
OutputAnalyzer output = HugeDirectiveUtil.execute(fileName);
output.shouldHaveExitValue(0);
}
}