diff --git a/compiler/util-io/src/org/jetbrains/kotlin/konan/properties/Properties.kt b/compiler/util-io/src/org/jetbrains/kotlin/konan/properties/Properties.kt index b81ef17c54c..f8a88cfe804 100644 --- a/compiler/util-io/src/org/jetbrains/kotlin/konan/properties/Properties.kt +++ b/compiler/util-io/src/org/jetbrains/kotlin/konan/properties/Properties.kt @@ -39,14 +39,16 @@ fun Properties.propertyString(key: String, suffix: String? = null): String? = ge /** * TODO: this method working with suffixes should be replaced with - * functionality borrowed from def file parser and unified for interop tool - * and kotlin compiler. + * functionality borrowed from def file parser and unified for interop tool + * and kotlin compiler. */ fun Properties.propertyList(key: String, suffix: String? = null, escapeInQuotes: Boolean = false): List { - val value = this.getProperty(key.suffix(suffix)) ?: this.getProperty(key) - if (value?.isBlank() == true) return emptyList() - return if (escapeInQuotes) value?.let { parseSpaceSeparatedArgs(it) } ?: emptyList() - else value?.split(Regex("\\s+")) ?: emptyList() + val value: String? = (getProperty(key.suffix(suffix)) ?: getProperty(key))?.trim(Char::isWhitespace) + return when { + value.isNullOrEmpty() -> emptyList() + escapeInQuotes -> parseSpaceSeparatedArgs(value) + else -> value.split(Regex("\\s+")) + } } fun Properties.hasProperty(key: String, suffix: String? = null): Boolean diff --git a/compiler/util-io/src/org/jetbrains/kotlin/util/Util.kt b/compiler/util-io/src/org/jetbrains/kotlin/util/Util.kt index 536cae2e13b..800ca061f6e 100644 --- a/compiler/util-io/src/org/jetbrains/kotlin/util/Util.kt +++ b/compiler/util-io/src/org/jetbrains/kotlin/util/Util.kt @@ -52,8 +52,8 @@ fun parseSpaceSeparatedArgs(argsString: String): List { val parsedArgs = mutableListOf() var inQuotes = false var currentCharSequence = StringBuilder() - fun saveArg() { - if (!currentCharSequence.isEmpty()) { + fun saveArg(wasInQuotes: Boolean) { + if (wasInQuotes || currentCharSequence.isNotBlank()) { parsedArgs.add(currentCharSequence.toString()) currentCharSequence = StringBuilder() } @@ -63,11 +63,11 @@ fun parseSpaceSeparatedArgs(argsString: String): List { inQuotes = !inQuotes // Save value which was in quotes. if (!inQuotes) { - saveArg() + saveArg(true) } - } else if (char == ' ' && !inQuotes) { + } else if (char.isWhitespace() && !inQuotes) { // Space is separator. - saveArg() + saveArg(false) } else { currentCharSequence.append(char) } @@ -75,6 +75,6 @@ fun parseSpaceSeparatedArgs(argsString: String): List { if (inQuotes) { error("No close-quote was found in $currentCharSequence.") } - saveArg() + saveArg(false) return parsedArgs -} \ No newline at end of file +} diff --git a/compiler/util-klib/src/org/jetbrains/kotlin/library/KotlinLibrary.kt b/compiler/util-klib/src/org/jetbrains/kotlin/library/KotlinLibrary.kt index 2322e855dc9..751de418cc1 100644 --- a/compiler/util-klib/src/org/jetbrains/kotlin/library/KotlinLibrary.kt +++ b/compiler/util-klib/src/org/jetbrains/kotlin/library/KotlinLibrary.kt @@ -67,7 +67,3 @@ val KotlinLibrary.packageFqName: String? val KotlinLibrary.exportForwardDeclarations get() = manifestProperties.propertyList(KLIB_PROPERTY_EXPORT_FORWARD_DECLARATIONS, escapeInQuotes = true) - .asSequence() - .map { it.trim() } - .filter { it.isNotEmpty() } - .toList()