mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 16:03:24 +00:00
Common: Fix bug in lastPathComponent.
Prior to this change lastPathComponent would not create a correct result, when the input of lastPathComponent did not contain a single separator. I also added a test case for this in our unit tests. svn-id: r52123
This commit is contained in:
parent
c284e78cc0
commit
7b51537be2
@ -626,7 +626,7 @@ Common::String lastPathComponent(const Common::String &path, const char sep) {
|
||||
|
||||
// Now scan the whole component
|
||||
const char *first = last - 1;
|
||||
while (first >= str && *first != sep)
|
||||
while (first > str && *first != sep)
|
||||
--first;
|
||||
|
||||
if (*first == sep)
|
||||
|
@ -266,6 +266,8 @@ class StringTestSuite : public CxxTest::TestSuite
|
||||
TS_ASSERT_EQUALS(Common::lastPathComponent("foo/./bar", '/'), "bar");
|
||||
TS_ASSERT_EQUALS(Common::lastPathComponent("foo//./bar//", '/'), "bar");
|
||||
TS_ASSERT_EQUALS(Common::lastPathComponent("foo//.bar//", '/'), ".bar");
|
||||
|
||||
TS_ASSERT_EQUALS(Common::lastPathComponent("foo", '/'), "foo");
|
||||
}
|
||||
|
||||
void test_normalizePath() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user