diff --git a/src/cmdline.cc b/src/cmdline.cc index b5728e35e4..efb09d884a 100644 --- a/src/cmdline.cc +++ b/src/cmdline.cc @@ -422,15 +422,13 @@ static std::vector split_by_comma_or_colon(std::string_view str) { std::vector vec; - while (!str.empty()) { + for (;;) { i64 pos = str.find_first_of(",:"); if (pos == str.npos) { vec.push_back(str); break; } - if (pos > 0) { - vec.push_back(str.substr(0, pos)); - } + vec.push_back(str.substr(0, pos)); str = str.substr(pos + 1); } return vec; diff --git a/test/exclude-libs.sh b/test/exclude-libs.sh index eb3903101c..3924399123 100755 --- a/test/exclude-libs.sh +++ b/test/exclude-libs.sh @@ -48,6 +48,12 @@ readelf --dyn-syms $t/f.so > $t/log ! grep -Fq bar $t/log || false grep -Fq baz $t/log +$CC -B. -shared -o $t/f.so $t/e.o $t/c.a $t/d.a -Wl,-exclude-libs=c.a:d.a +readelf --dyn-syms $t/f.so > $t/log +! grep -Fq foo $t/log || false +! grep -Fq bar $t/log || false +grep -Fq baz $t/log + $CC -B. -shared -o $t/f.so $t/e.o $t/c.a $t/d.a -Wl,-exclude-libs=ALL readelf --dyn-syms $t/f.so > $t/log ! grep -Fq foo $t/log || false