Support single quotation marks in argfiles
#KT-26122 Fixed
This commit is contained in:
+5
-4
@@ -12,7 +12,8 @@ import java.io.Reader
|
||||
|
||||
private const val EXPERIMENTAL_ARGFILE_ARGUMENT = "-Xargfile"
|
||||
|
||||
private const val QUOTATION_MARK = '"'
|
||||
private const val SINGLE_QUOTE = '\''
|
||||
private const val DOUBLE_QUOTE = '"'
|
||||
private const val BACKSLASH = '\\'
|
||||
private const val WHITESPACE = ' '
|
||||
private const val NEWLINE = '\n'
|
||||
@@ -56,7 +57,7 @@ private fun Reader.parseNextArgument(): String? {
|
||||
loop@ while (r != null) {
|
||||
when (r) {
|
||||
WHITESPACE, NEWLINE -> break@loop
|
||||
QUOTATION_MARK -> consumeRestOfEscapedSequence(sb)
|
||||
DOUBLE_QUOTE, SINGLE_QUOTE -> consumeRestOfEscapedSequence(sb, r)
|
||||
BACKSLASH -> nextChar()?.apply(sb::append)
|
||||
else -> sb.append(r)
|
||||
}
|
||||
@@ -67,9 +68,9 @@ private fun Reader.parseNextArgument(): String? {
|
||||
return sb.toString().takeIf { it.isNotEmpty() }
|
||||
}
|
||||
|
||||
private fun Reader.consumeRestOfEscapedSequence(sb: StringBuilder) {
|
||||
private fun Reader.consumeRestOfEscapedSequence(sb: StringBuilder, quote: Char) {
|
||||
var ch = nextChar()
|
||||
while (ch != null && ch != QUOTATION_MARK) {
|
||||
while (ch != null && ch != quote) {
|
||||
if (ch == BACKSLASH) nextChar()?.apply(sb::append) else sb.append(ch)
|
||||
ch = nextChar()
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
-X"some escaped \" sequence \\"
|
||||
-X"double \' quote ' escaped \" sequence \\"
|
||||
-X'single \" quote " escaped \' sequence \\'
|
||||
$TESTDATA_DIR$/apiVersion.kt
|
||||
-d
|
||||
$TEMP_DIR$ -api-version 1.2 -language-version 1.3
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
warning: flag is not supported by this version of the compiler: -Xsome escaped " sequence /
|
||||
warning: flag is not supported by this version of the compiler: -Xdouble ' quote ' escaped " sequence /
|
||||
warning: flag is not supported by this version of the compiler: -Xsingle " quote " escaped ' sequence /
|
||||
compiler/testData/cli/jvm/apiVersion.kt:2:15: error: unresolved reference: sealedSubclasses
|
||||
""::class.sealedSubclasses
|
||||
^
|
||||
|
||||
Reference in New Issue
Block a user