better naming of strbuf methods

This commit is contained in:
Linus Dierheimer
2021-06-26 15:34:01 +02:00
parent 19b71d9ce0
commit 582d5b6473
8 changed files with 57 additions and 47 deletions
+5 -7
View File
@@ -152,25 +152,23 @@ static void detectGTK(FFinstance* instance, const char* version, const char* env
FFstrbuf buffer;
ffStrbufInitA(&buffer, 128);
uint32_t lastIndex;
// From ENV: GTK*_RC_FILES
ffStrbufSetS(&buffer, getenv(envVariable));
lastIndex = 0;
while (lastIndex < buffer.length)
uint32_t startIndex = 0;
while (startIndex < buffer.length)
{
uint32_t colonIndex = ffStrbufFirstIndexAfterC(&buffer, lastIndex, ':');
uint32_t colonIndex = ffStrbufNextIndexC(&buffer, startIndex, ':');
buffer.chars[colonIndex] = '\0';
detectGTKFromConfigFile(buffer.chars + lastIndex, result);
detectGTKFromConfigFile(buffer.chars + startIndex, result);
if(allPropertiesSet(result))
{
ffStrbufDestroy(&buffer);
return;
}
lastIndex = colonIndex + 1;
startIndex = colonIndex + 1;
}
//From DConf / GSettings
+2 -2
View File
@@ -210,7 +210,7 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
}
// fastforward to the end of the if without printing the in between
i = ffStrbufFirstIndexAfterS(formatstr, i, "{?}") + 2; // 2 is the length of "{?}" -1 because the loop will increament it again directly after continue
i = ffStrbufNextIndexS(formatstr, i, "{?}") + 2; // 2 is the length of "{?}" - 1 because the loop will increament it again directly after continue
ffStrbufDestroy(&placeholderValue);
continue;
}
@@ -247,7 +247,7 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
}
// fastforward to the end of the if without printing the in between
i = ffStrbufFirstIndexAfterS(formatstr, i, "{/}") + 2; // 2 is the length of "{/}" -1 because the loop will increament it again directly after continue
i = ffStrbufNextIndexS(formatstr, i, "{/}") + 2; // 2 is the length of "{/}" - 1 because the loop will increament it again directly after continue
ffStrbufDestroy(&placeholderValue);
continue;
}
+8 -6
View File
@@ -22,19 +22,21 @@ static void initConfigDirs(FFstate* state)
}
FFstrbuf xdgConfigDirs;
ffStrbufInitAS(&xdgConfigDirs, 64, getenv("XDG_CONFIG_DIRS"));
uint32_t lastIndex = 0;
while (lastIndex < xdgConfigDirs.length)
ffStrbufInitA(&xdgConfigDirs, 64);
ffStrbufAppendS(&xdgConfigDirs, getenv("XDG_CONFIG_DIRS"));
uint32_t startIndex = 0;
while (startIndex < xdgConfigDirs.length)
{
uint32_t colonIndex = ffStrbufFirstIndexAfterC(&xdgConfigDirs, lastIndex, ':');
uint32_t colonIndex = ffStrbufNextIndexC(&xdgConfigDirs, startIndex, ':');
xdgConfigDirs.chars[colonIndex] = '\0';
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
ffStrbufInitA(buffer, 64);
ffStrbufAppendS(buffer, xdgConfigDirs.chars + lastIndex);
ffStrbufAppendS(buffer, xdgConfigDirs.chars + startIndex);
ffStrbufTrimRight(buffer, '/');
lastIndex = colonIndex + 1;
startIndex = colonIndex + 1;
}
#define FF_ENSURE_ONLY_ONCE_IN_LIST(element) \
+10 -10
View File
@@ -128,14 +128,14 @@ static bool printCachedValue(FFinstance* instance, const char* moduleName, const
uint8_t moduleCounter = 1;
uint32_t lastIndex = 0;
while(lastIndex < content.length)
uint32_t startIndex = 0;
while(startIndex < content.length)
{
uint32_t nullByteIndex = ffStrbufFirstIndexAfterC(&content, lastIndex, '\0');
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
uint8_t moduleIndex = (moduleCounter == 1 && nullByteIndex == content.length) ? 0 : moduleCounter;
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
puts(content.chars + lastIndex);
lastIndex = nullByteIndex + 1;
puts(content.chars + startIndex);
startIndex = nullByteIndex + 1;
++moduleCounter;
}
@@ -160,14 +160,14 @@ static bool printCachedFormat(FFinstance* instance, const char* moduleName, cons
FFformatarg* arguments = calloc(numArgs, sizeof(FFformatarg));
uint32_t argumentCounter = 0;
uint32_t lastIndex = 0;
while(lastIndex < content.length)
uint32_t startIndex = 0;
while(startIndex < content.length)
{
arguments[argumentCounter].type = FF_FORMAT_ARG_TYPE_STRING;
arguments[argumentCounter].value = &content.chars[lastIndex];
arguments[argumentCounter].value = &content.chars[startIndex];
++argumentCounter;
uint32_t nullByteIndex = ffStrbufFirstIndexAfterC(&content, lastIndex, '\0');
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
if(argumentCounter == numArgs)
{
@@ -177,7 +177,7 @@ static bool printCachedFormat(FFinstance* instance, const char* moduleName, cons
argumentCounter = 0;
}
lastIndex = nullByteIndex + 1;
startIndex = nullByteIndex + 1;
}
free(arguments);