diff --git a/src/settings.cpp b/src/settings.cpp index 19a2b88..206fa6b 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -70,12 +70,11 @@ const char* Settings::get(const StringView& _name) const FilePath uri(_name); const StringView path = strTrim(uri.getPath(), "/"); const StringView& fileName = uri.getFileName(); - int32_t section = INI_GLOBAL_SECTION; if (!path.isEmpty() ) { - section = ini_find_section(ini, path.getPtr(), path.getLength()-1); + section = ini_find_section(ini, path.getPtr(), path.getLength() ); if (INI_NOT_FOUND == section) { section = INI_GLOBAL_SECTION; @@ -103,10 +102,10 @@ void Settings::set(const StringView& _name, const StringView& _value) if (!path.isEmpty() ) { - section = ini_find_section(ini, path.getPtr(), path.getLength()-1); + section = ini_find_section(ini, path.getPtr(), path.getLength() ); if (INI_NOT_FOUND == section) { - section = ini_section_add(ini, path.getPtr(), path.getLength()-1); + section = ini_section_add(ini, path.getPtr(), path.getLength() ); } } @@ -146,7 +145,7 @@ void Settings::remove(const StringView& _name) const if (!path.isEmpty() ) { - section = ini_find_section(ini, path.getPtr(), path.getLength()-1); + section = ini_find_section(ini, path.getPtr(), path.getLength() ); if (INI_NOT_FOUND == section) { section = INI_GLOBAL_SECTION; diff --git a/src/string.cpp b/src/string.cpp index c294bd2..ccfc019 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -466,7 +466,7 @@ namespace bx { if (NULL == strFindUnsafe(chars, charsLen, ptr[ii]) ) { - return StringView(ptr, ii); + return StringView(ptr, ii+1); } } diff --git a/tests/string_test.cpp b/tests/string_test.cpp index 653b494..3bbbb53 100644 --- a/tests/string_test.cpp +++ b/tests/string_test.cpp @@ -4,12 +4,11 @@ */ #include "test.h" +#include #include #include #include -#include - bx::AllocatorI* g_allocator; TEST_CASE("chars", "") @@ -72,6 +71,11 @@ TEST_CASE("strCat", "") REQUIRE(0 == bx::strCmp(dst, "copycat-cat") ); } +TEST_CASE("strCmp", "") +{ + REQUIRE(0 != bx::strCmp("meh", "meh/") ); +} + TEST_CASE("strCmpI", "") { REQUIRE(0 == bx::strCmpI("test", "test") ); @@ -381,4 +385,7 @@ TEST_CASE("Trim", "") REQUIRE(0 == bx::strCmp(bx::strTrim("abvgd", ""), "abvgd") ); REQUIRE(0 == bx::strCmp(bx::strTrim(" \t a b\tv g d \t ", " \t"), "a b\tv g d") ); + + bx::FilePath uri("/555333/podmac/"); + REQUIRE(0 == bx::strCmp(bx::strTrim(uri.getPath(), "/"), "555333/podmac") ); }