xtool/safesplit:properly handle consecutive short flags

This commit is contained in:
luoliwoshang
2025-08-27 19:36:46 +08:00
parent cf2d1ef9ca
commit 0935d10edf
3 changed files with 22 additions and 3 deletions

View File

@@ -49,6 +49,13 @@ func SplitPkgConfigFlags(s string) []string {
for i < len(s) && (s[i] == ' ' || s[i] == '\t') {
i++
}
// Check if next character is another flag (short flag with no argument)
if i < len(s) && s[i] == '-' {
// This is a short flag with no argument, finish current flag
continue
}
// Read content until next space
for i < len(s) {
if s[i] == '\\' && i+1 < len(s) && (s[i+1] == ' ' || s[i+1] == '\t') {