mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Cleanup.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -466,7 +466,7 @@ namespace bx
|
||||
{
|
||||
if (NULL == strFindUnsafe(chars, charsLen, ptr[ii]) )
|
||||
{
|
||||
return StringView(ptr, ii);
|
||||
return StringView(ptr, ii+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
#include <bx/filepath.h>
|
||||
#include <bx/string.h>
|
||||
#include <bx/handlealloc.h>
|
||||
#include <bx/sort.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
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") );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user