PhysicalDisk: unifying white space trimming

This commit is contained in:
Carter Li
2025-07-05 08:31:21 +08:00
parent 64910d0781
commit 3a1f0485f4
8 changed files with 61 additions and 7 deletions
+25
View File
@@ -272,6 +272,31 @@ void ffStrbufTrimRight(FFstrbuf* strbuf, char c)
strbuf->chars[strbuf->length] = '\0';
}
void ffStrbufTrimLeftSpace(FFstrbuf* strbuf)
{
if(strbuf->length == 0)
return;
uint32_t index = 0;
while(index < strbuf->length && isspace(strbuf->chars[index]))
++index;
if(index == 0)
return;
if(strbuf->allocated == 0)
{
//static string
strbuf->length -= index;
strbuf->chars += index;
return;
}
memmove(strbuf->chars, strbuf->chars + index, strbuf->length - index);
strbuf->length -= index;
strbuf->chars[strbuf->length] = '\0';
}
void ffStrbufTrimRightSpace(FFstrbuf* strbuf)
{
if (strbuf->length == 0)