mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8357862: Java argument file is parsed unexpectedly with trailing comment
Co-authored-by: Stuart Marks <smarks@openjdk.org> Reviewed-by: vromero
This commit is contained in:
parent
51877f568b
commit
21b72dea78
@ -149,6 +149,19 @@ static void checkArg(const char *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
static char *computeToken(JLI_List *parts, const char *anchor, const char *nextc) {
|
||||
char *token;
|
||||
if ((*parts)->size == 0) {
|
||||
token = clone_substring(anchor, nextc - anchor);
|
||||
} else {
|
||||
JLI_List_addSubstring(*parts, anchor, nextc - anchor);
|
||||
token = JLI_List_combine(*parts);
|
||||
JLI_List_free(*parts);
|
||||
*parts = JLI_List_new(4);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
/*
|
||||
[\n\r] +------------+ +------------+ [\n\r]
|
||||
+---------+ IN_COMMENT +<------+ | IN_ESCAPE +---------+
|
||||
@ -246,14 +259,7 @@ static char* nextToken(__ctx_args *pctx) {
|
||||
// fall through
|
||||
case '\n':
|
||||
case '\r':
|
||||
if (pctx->parts->size == 0) {
|
||||
token = clone_substring(anchor, nextc - anchor);
|
||||
} else {
|
||||
JLI_List_addSubstring(pctx->parts, anchor, nextc - anchor);
|
||||
token = JLI_List_combine(pctx->parts);
|
||||
JLI_List_free(pctx->parts);
|
||||
pctx->parts = JLI_List_new(4);
|
||||
}
|
||||
token = computeToken(&pctx->parts, anchor, nextc);
|
||||
pctx->cptr = nextc + 1;
|
||||
pctx->state = FIND_NEXT;
|
||||
return token;
|
||||
@ -262,6 +268,13 @@ static char* nextToken(__ctx_args *pctx) {
|
||||
continue;
|
||||
}
|
||||
pctx->state = IN_COMMENT;
|
||||
// return non-zero length token, terminated by the number sign
|
||||
if (nextc - anchor > 0) {
|
||||
token = computeToken(&pctx->parts, anchor, nextc);
|
||||
pctx->cptr = nextc + 1;
|
||||
return token;
|
||||
}
|
||||
// anchor after number sign
|
||||
anchor = nextc + 1;
|
||||
break;
|
||||
case '\\':
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -21,9 +21,9 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 8027634 8210810 8240629
|
||||
* @bug 8027634 8210810 8240629 8357862
|
||||
* @summary Verify syntax of argument file
|
||||
* @build TestHelper
|
||||
* @run main ArgFileSyntax
|
||||
@ -172,6 +172,15 @@ public class ArgFileSyntax extends TestHelper {
|
||||
"-version",
|
||||
"-Dcontinue.with.leadingws=Line1continue with \f<ff> and \t<tab>"
|
||||
}
|
||||
},
|
||||
{ // multiple args in one line and comments without preceding whitespace
|
||||
{ "-Xmx32m -XshowSettings#COMMENT 1",
|
||||
"-version#COMMENT 2"
|
||||
},
|
||||
{ "-Xmx32m",
|
||||
"-XshowSettings",
|
||||
"-version"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user