Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/common/impl/FFstrbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,13 @@ void ffStrbufAppendDouble(FFstrbuf* strbuf, double value, int8_t precision, bool

void ffStrbufUpperCase(FFstrbuf* strbuf) {
for (uint32_t i = 0; i < strbuf->length; ++i) {
strbuf->chars[i] = (char) toupper(strbuf->chars[i]);
strbuf->chars[i] = (char) toupper((unsigned char) strbuf->chars[i]);
}
}

void ffStrbufLowerCase(FFstrbuf* strbuf) {
for (uint32_t i = 0; i < strbuf->length; ++i) {
strbuf->chars[i] = (char) tolower(strbuf->chars[i]);
strbuf->chars[i] = (char) tolower((unsigned char) strbuf->chars[i]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/impl/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void ffFontInitQt(FFfont* font, const char* data) {
goto exit;
}
data++;
if (isalpha(*data)) {
if (isalpha((unsigned char) *data)) {
do {
FFstrbuf* style = FF_LIST_ADD(FFstrbuf, font->styles);
ffStrbufInit(style);
Expand Down
2 changes: 1 addition & 1 deletion src/common/impl/properties.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool ffParsePropLinePointer(const char** line, const char* start, FFstrbuf* buff
}

// Line doesn't match start, skip it
if (tolower(**line) != tolower(*start) || **line == '\0') {
if (tolower((unsigned char) **line) != tolower((unsigned char) *start) || **line == '\0') {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/detection/chassis/chassis_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const char* ffDetectChassis(FFChassisResult* result) {
}
} else if (ffReadFileBuffer("/sys/firmware/devicetree/base/chassis-type", &result->type) && result->type.length > 0) {
ffStrbufTrimRight(&result->type, '\0');
result->type.chars[0] = (char) toupper(result->type.chars[0]);
result->type.chars[0] = (char) toupper((unsigned char) result->type.chars[0]);
}
}
return nullptr;
Expand Down
8 changes: 4 additions & 4 deletions src/detection/cpu/cpu_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ static void detectAndroid(FFCPUResult* cpu) {
} else if (ffStrbufIgnCaseEqualS(&cpu->vendor, "MediaTek")) { // sometimes "Mediatek"
ffStrbufSetStatic(&cpu->vendor, "MediaTek");
} else if (cpu->vendor.length > 0) {
cpu->vendor.chars[0] = (char) toupper(cpu->vendor.chars[0]);
cpu->vendor.chars[0] = (char) toupper((unsigned char) cpu->vendor.chars[0]);
}

if (ffStrbufEqualS(&cpu->vendor, "Qualcomm") && ffStrbufStartsWithS(&cpu->name, "SM")) {
Expand Down Expand Up @@ -1032,18 +1032,18 @@ static const char* detectPhysicalCores(FFCPUResult* cpu) {
// Raspberry Pi
ffStrbufSetStatic(&cpu->vendor, "Broadcom");
for (const char* p = model; *p; ++p) {
ffStrbufAppendC(&cpu->name, (char) toupper(*p));
ffStrbufAppendC(&cpu->name, (char) toupper((unsigned char) *p));
}
} else if (ffStrEquals(vendor, "thead")) {
// Lichee Pi?
ffStrbufSetStatic(&cpu->vendor, "T-Head");
for (const char* p = model; *p; ++p) {
ffStrbufAppendC(&cpu->name, (char) toupper(*p));
ffStrbufAppendC(&cpu->name, (char) toupper((unsigned char) *p));
}
} else {
ffStrbufSetS(&cpu->name, model);
ffStrbufSetS(&cpu->vendor, vendor);
cpu->vendor.chars[0] = (char) toupper(vendor[0]);
cpu->vendor.chars[0] = (char) toupper((unsigned char) vendor[0]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/detection/wm/wm_apple.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
}

ffStrbufAppendS(pluginName, comm);
pluginName->chars[0] = (char) toupper(pluginName->chars[0]);
pluginName->chars[0] = (char) toupper((unsigned char) pluginName->chars[0]);
break;
}

Expand Down
4 changes: 2 additions & 2 deletions src/detection/wmtheme/wmtheme_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError) {
if (ffRegReadStrbuf(hKey, L"CurrentTheme", &theme, nullptr)) {
ffStrbufSubstrBeforeLastC(&theme, '.');
ffStrbufSubstrAfterLastC(&theme, '\\');
if (isalpha(theme.chars[0])) {
theme.chars[0] = (char) toupper(theme.chars[0]);
if (isalpha((unsigned char) theme.chars[0])) {
theme.chars[0] = (char) toupper((unsigned char) theme.chars[0]);
}

ffStrbufAppend(themeOrError, &theme);
Expand Down
4 changes: 2 additions & 2 deletions src/logo/logo.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,11 @@ static bool logoHasName(const FFlogo* logo, const FFstrbuf* name, bool small) {
}

static const FFlogo* logoGetBuiltin(const FFstrbuf* name, FFLogoSize size) {
if (name->length == 0 || !isalpha(name->chars[0])) {
if (name->length == 0 || !isalpha((unsigned char) name->chars[0])) {
return nullptr;
}

for (const FFlogo* logo = ffLogoBuiltins[toupper(name->chars[0]) - 'A']; *logo->names; ++logo) {
for (const FFlogo* logo = ffLogoBuiltins[toupper((unsigned char) name->chars[0]) - 'A']; *logo->names; ++logo) {
switch (size) {
// Never use alternate logos
case FF_LOGO_SIZE_NORMAL:
Expand Down
4 changes: 2 additions & 2 deletions src/modules/media/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <ctype.h>

static inline bool shouldIgnoreChar(char c) {
return isblank(c) || c == '-' || c == '.';
return isblank((unsigned char) c) || c == '-' || c == '.';
}

static bool artistInSongTitle(const FFstrbuf* song, const FFstrbuf* artist) {
Expand All @@ -31,7 +31,7 @@ static bool artistInSongTitle(const FFstrbuf* song, const FFstrbuf* artist) {
return false;
}

if (tolower(song->chars[songIndex]) != tolower(artist->chars[artistIndex])) {
if (tolower((unsigned char) song->chars[songIndex]) != tolower((unsigned char) artist->chars[artistIndex])) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/packages/packages.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module) {
else if (ffStrEqualsIgnCase(flag, #name)) { \
options->disabled |= FF_PACKAGES_FLAG_##name##_BIT; \
}
switch (toupper(flag[0])) {
switch (toupper((unsigned char) flag[0])) {
case 'A':
if (false)
;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/player/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool ffPrintPlayer(FFPlayerOptions* options) {

// If we don't have subdomains, it is usually more pretty to capitalize the first letter.
if (playerPrettyIsCustom && ffStrbufFirstIndexC(&playerPretty, '.') == playerPretty.length) {
playerPretty.chars[0] = (char) toupper(playerPretty.chars[0]);
playerPretty.chars[0] = (char) toupper((unsigned char) playerPretty.chars[0]);
}

if (playerPrettyIsCustom) {
Expand Down
8 changes: 8 additions & 0 deletions tests/strbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,14 @@ int main(void) {
VERIFY(ffStrbufEqualS(&strbuf, "TEST"));
ffStrbufDestroy(&strbuf);

// ffStrbufUpperCase & ffStrbufLowerCase
ffStrbufInitS(&strbuf, "Hello, World! \x80\xff");
ffStrbufUpperCase(&strbuf);
VERIFY(ffStrbufEqualS(&strbuf, "HELLO, WORLD! \x80\xff"));
ffStrbufLowerCase(&strbuf);
VERIFY(ffStrbufEqualS(&strbuf, "hello, world! \x80\xff"));
ffStrbufDestroy(&strbuf);

// ffStrbufEnsureFixedLengthFree / empty buffer
ffStrbufInit(&strbuf);
ffStrbufEnsureFixedLengthFree(&strbuf, 10);
Expand Down
Loading