diff --git a/cobalt/debug/console/command_manager.cc b/cobalt/debug/console/command_manager.cc index 3c30ae38912e..f87ea66e2c35 100644 --- a/cobalt/debug/console/command_manager.cc +++ b/cobalt/debug/console/command_manager.cc @@ -50,9 +50,15 @@ ConsoleCommandManager::CommandHandler::~CommandHandler() { // static bool ConsoleCommandManager::CommandHandler::IsOnEnableOrTrue( const std::string& message) { + #if SB_API_VERSION < 16 return (SbStringCompareNoCase("on", message.c_str()) == 0) || (SbStringCompareNoCase("enable", message.c_str()) == 0) || (SbStringCompareNoCase("true", message.c_str()) == 0); + #else + return (strcasecmp("on", message.c_str()) == 0) || + (strcasecmp("enable", message.c_str()) == 0) || + (strcasecmp("true", message.c_str()) == 0); + #endif // SB_API_VERSION < 16 } diff --git a/cobalt/dom/on_screen_keyboard.cc b/cobalt/dom/on_screen_keyboard.cc index ec41ff409b62..07a3c9704262 100644 --- a/cobalt/dom/on_screen_keyboard.cc +++ b/cobalt/dom/on_screen_keyboard.cc @@ -51,8 +51,12 @@ bool ParseColor(const char* color_str, int& r, int& g, int& b) { } // Handle rgb color notation rgb(R, G, B) - if (!is_hex && len >= 10 && - SbStringCompareNoCaseN("rgb(", color_str, 4) == 0) { + #if SB_API_VERSION < 16 + bool strcmp = SbStringCompareNoCaseN("rgb(", color_str, 4) == 0; + #else + bool strcmp = strncasecmp("rgb(", color_str, 4) == 0; + #endif //SB_API_VERSION < 16 + if (!is_hex && len >= 10 && strcmp) { int rgb_tmp[3] = {-1, -1, -1}; const char* ptr = color_str + 4; int i = 0; diff --git a/cobalt/loader/cors_preflight.cc b/cobalt/loader/cors_preflight.cc index 980f4d971f1b..718a2cc438aa 100644 --- a/cobalt/loader/cors_preflight.cc +++ b/cobalt/loader/cors_preflight.cc @@ -117,9 +117,15 @@ bool IsInArray(const char* input_str, const char* array[], size_t size) { return false; } for (size_t i = 0; i < size; ++i) { + #if SB_API_VERSION < 16 if (SbStringCompareNoCase(input_str, array[i]) == 0) { return true; } + #else + if (strcasecmp(input_str, array[i]) == 0) { + return true; + } + #endif // SB_API_VERSION < 16 } return false; } @@ -132,10 +138,18 @@ bool HasFieldValue(const std::vector& field_values, if (field_values[i].empty()) { continue; } + #if SB_API_VERSION < 16 if (SbStringCompareNoCase(field_values[i].c_str(), find_value_name.c_str()) == 0) { return true; } + #else + if (strcasecmp(field_values[i].c_str(), + find_value_name.c_str()) == 0) { + return true; + } + #endif // SB_API_VERSION < 16 + } return false; } @@ -220,10 +234,17 @@ bool CORSPreflight::IsSafeResponseHeader( } for (size_t i = 0; i < CORS_exposed_header_name_list.size(); i++) { + #if SB_API_VERSION < 16 if (SbStringCompareNoCase(CORS_exposed_header_name_list.at(i).c_str(), name.c_str()) == 0) { return true; } + #else + if (strcasecmp(CORS_exposed_header_name_list.at(i).c_str(), + name.c_str()) == 0) { + return true; + } + #endif //SB_API_VERSION < 16 } return false; } @@ -381,12 +402,22 @@ void CORSPreflight::OnURLFetchComplete(const net::URLFetcher* source) { if (HasFieldValue(headernames_vec, it.name())) { continue; } + #if SB_API_VERSION < 16 if (SbStringCompareNoCase(it.name().c_str(), kAuthorization) == 0 || (!HasFieldValue(headernames_vec, "*") && !IsSafeRequestHeader(it.name(), it.value()))) { error_callback_.Run(); return; } + #else + if (strcasecmp(it.name().c_str(), kAuthorization) == 0 || + (!HasFieldValue(headernames_vec, "*") && + !IsSafeRequestHeader(it.name(), it.value()))) { + error_callback_.Run(); + return; + } + #endif //SB_API_VERSION < 16 + } // step 10-18 for adding entry to preflight cache. std::string max_age_str; diff --git a/cobalt/loader/cors_preflight_cache.cc b/cobalt/loader/cors_preflight_cache.cc index c16d31339679..6d09a4127ab1 100644 --- a/cobalt/loader/cors_preflight_cache.cc +++ b/cobalt/loader/cors_preflight_cache.cc @@ -127,10 +127,17 @@ bool CORSPreflightCache::HaveEntry( if (entry_ptr->allow_all_headers_except_non_wildcard) { bool has_auth_header = false; for (const auto& header : unsafe_headernames) { + #if SB_API_VERSION < 16 if (SbStringCompareNoCase(header.c_str(), kAuthorization)) { has_auth_header = true; break; } + #else + if (strcasecmp(header.c_str(), kAuthorization)) { + has_auth_header = true; + break; + } + #endif //SB_API_VERSION < 16 } // wildcard header is allowed if entry's allowed headers include it. return !has_auth_header || diff --git a/cobalt/loader/cors_preflight_cache.h b/cobalt/loader/cors_preflight_cache.h index 6e063d5b18a2..48cdb7aeb9fe 100644 --- a/cobalt/loader/cors_preflight_cache.h +++ b/cobalt/loader/cors_preflight_cache.h @@ -54,7 +54,11 @@ class CORSPreflightCache : public base::RefCounted { // Case-insensitive comparator. struct CaseInsensitiveCompare { bool operator()(const std::string& lhs, const std::string& rhs) const { + #if SB_API_VERSION < 16 return SbStringCompareNoCase(lhs.c_str(), rhs.c_str()) < 0; + #else + return strcasecmp(lhs.c_str(), rhs.c_str()) < 0; + #endif //SB_API_VERSION < 16 } }; diff --git a/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontMgr_cobalt.cc b/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontMgr_cobalt.cc index b64037dd062d..b4e3197d18fa 100644 --- a/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontMgr_cobalt.cc +++ b/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontMgr_cobalt.cc @@ -307,9 +307,15 @@ void SkFontMgr_Cobalt::LoadLocaleDefault() { std::string script = icu::Locale::createCanonical(base::GetSystemLanguageScript().c_str()) .getScript(); + #if SB_API_VERSION < 16 if (SbStringCompareNoCase(script.c_str(), ROBOTO_SCRIPT) == 0) { return; } + #else + if (strcasecmp(script.c_str(), ROBOTO_SCRIPT) == 0) { + return; + } + #endif // SB_API_VERSION < 16 default_fonts_loaded_event_.Reset(); for (int i = 0; i < families_.count(); i++) { @@ -515,9 +521,15 @@ bool SkFontMgr_Cobalt::CheckIfFamilyMatchesLocaleScript( } std::string family_script = icu::Locale::createCanonical(family_tag.c_str()).getScript(); + #if SB_API_VERSION < 16 if (SbStringCompareNoCase(script, family_script.c_str()) != 0) { return false; } + #else + if (strcasecmp(script, family_script.c_str()) != 0) { + return false; + } + #endif //SB_API_VERSION < 16 sk_sp check_typeface( new_family->MatchStyleWithoutLocking(SkFontStyle())); diff --git a/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontStyleSet_cobalt.cc b/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontStyleSet_cobalt.cc index 136b2e31bce3..c3d5b34e0367 100644 --- a/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontStyleSet_cobalt.cc +++ b/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontStyleSet_cobalt.cc @@ -232,6 +232,7 @@ SkFontStyleSet_Cobalt::SkFontStyleSet_Cobalt( ++extension; // Only add font formats that match the format setting. + #if SB_API_VERSION < 16 if (font_format_setting == kTtf) { if (SbStringCompareNoCase("ttf", extension) != 0 && SbStringCompareNoCase(extension, "ttc") != 0) { @@ -241,6 +242,17 @@ SkFontStyleSet_Cobalt::SkFontStyleSet_Cobalt( SbStringCompareNoCase("woff2", extension) != 0) { continue; } + #else + if (font_format_setting == kTtf) { + if (strcasecmp("ttf", extension) != 0 && + strcasecmp(extension, "ttc") != 0) { + continue; + } + } else if (font_format_setting == kWoff2 && + strcasecmp("woff2", extension) != 0) { + continue; + } + #endif //SB_API_VERSION < 16 SkFontStyle style(font_file.weight, SkFontStyle::kNormal_Width, font_file.style == FontFileInfo::kItalic_FontStyle @@ -272,6 +284,7 @@ SkFontStyleSet_Cobalt::SkFontStyleSet_Cobalt( int* index = styles_index_map.find(font_name); if (index != nullptr) { // If style with name already exists in family, replace it. + #if SB_API_VERSION < 16 if (font_format_setting == kTtfPreferred && SbStringCompareNoCase("ttf", extension) == 0) { styles_[*index].reset(font); @@ -279,6 +292,15 @@ SkFontStyleSet_Cobalt::SkFontStyleSet_Cobalt( SbStringCompareNoCase("woff2", extension) == 0) { styles_[*index].reset(font); } + #else + if (font_format_setting == kTtfPreferred && + strcasecmp("ttf", extension) == 0) { + styles_[*index].reset(font); + } else if (font_format_setting == kWoff2Preferred && + strcasecmp("woff2", extension) == 0) { + styles_[*index].reset(font); + } + #endif //SB_API_VERSION < 16 } else { int count = styles_.count(); styles_index_map.set(font_name, count); diff --git a/starboard/client_porting/poem/strings_poem.h b/starboard/client_porting/poem/strings_poem.h index 7cab608fb3b2..7d7be2884962 100644 --- a/starboard/client_porting/poem/strings_poem.h +++ b/starboard/client_porting/poem/strings_poem.h @@ -23,10 +23,12 @@ #include "starboard/string.h" +#if SB_API_VERSION < 16 #undef strcasecmp #define strcasecmp(s1, s2) SbStringCompareNoCase(s1, s2) #undef strncasecmp #define strncasecmp(s1, s2) SbStringCompareNoCaseN(s1, s2) +#endif // SB_API_VERSION < 16 #endif // POEM_NO_EMULATION diff --git a/starboard/elf_loader/exported_symbols.cc b/starboard/elf_loader/exported_symbols.cc index d3bb80696d95..c0134d22a875 100644 --- a/starboard/elf_loader/exported_symbols.cc +++ b/starboard/elf_loader/exported_symbols.cc @@ -303,13 +303,11 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbStorageOpenRecord); REGISTER_SYMBOL(SbStorageReadRecord); REGISTER_SYMBOL(SbStorageWriteRecord); +#if SB_API_VERSION < 16 REGISTER_SYMBOL(SbStringCompareNoCase); REGISTER_SYMBOL(SbStringCompareNoCaseN); - -#if SB_API_VERSION < 16 REGISTER_SYMBOL(SbStringDuplicate); -#endif // #if SB_API_VERSION < 16 - +#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbStringFormat); REGISTER_SYMBOL(SbStringFormatWide); REGISTER_SYMBOL(SbStringScan); diff --git a/starboard/shared/posix/string_compare_no_case.cc b/starboard/shared/posix/string_compare_no_case.cc index 4837d888b2a9..79479e7eebe1 100644 --- a/starboard/shared/posix/string_compare_no_case.cc +++ b/starboard/shared/posix/string_compare_no_case.cc @@ -17,6 +17,8 @@ #include // Non-standard, required for some platforms. #include +#if SB_API_VERSION < 16 int SbStringCompareNoCase(const char* string1, const char* string2) { return strcasecmp(string1, string2); } +#endif diff --git a/starboard/shared/posix/string_compare_no_case_n.cc b/starboard/shared/posix/string_compare_no_case_n.cc index 75c9141a1afb..e56c4fb7ebce 100644 --- a/starboard/shared/posix/string_compare_no_case_n.cc +++ b/starboard/shared/posix/string_compare_no_case_n.cc @@ -17,8 +17,10 @@ #include // Non-standard, required for some platforms. #include +#if SB_API_VERSION < 16 int SbStringCompareNoCaseN(const char* string1, const char* string2, size_t count) { return ::strncasecmp(string1, string2, count); } +#endif diff --git a/starboard/shared/starboard/media/mime_type.cc b/starboard/shared/starboard/media/mime_type.cc index 4954ceeb318e..80b25f78f834 100644 --- a/starboard/shared/starboard/media/mime_type.cc +++ b/starboard/shared/starboard/media/mime_type.cc @@ -196,9 +196,15 @@ const std::string& MimeType::GetParamName(int index) const { int MimeType::GetParamIndexByName(const char* name) const { for (size_t i = 0; i < params_.size(); ++i) { + #if SB_API_VERSION < 16 if (SbStringCompareNoCase(params_[i].name.c_str(), name) == 0) { return static_cast(i); } + #else + if (strcasecmp(params_[i].name.c_str(), name) == 0) { + return static_cast(i); + } + #endif // SB_API_VERSION < 16 } return kInvalidParamIndex; } diff --git a/starboard/shared/stub/string_compare_no_case.cc b/starboard/shared/stub/string_compare_no_case.cc index 3434800b2d63..aa767bdb86be 100644 --- a/starboard/shared/stub/string_compare_no_case.cc +++ b/starboard/shared/stub/string_compare_no_case.cc @@ -14,6 +14,8 @@ #include "starboard/common/string.h" +#if SB_API_VERSION < 16 int SbStringCompareNoCase(const char* string1, const char* string2) { return 0; } +#endif diff --git a/starboard/shared/stub/string_compare_no_case_n.cc b/starboard/shared/stub/string_compare_no_case_n.cc index e04639e26939..aa7ae6323c75 100644 --- a/starboard/shared/stub/string_compare_no_case_n.cc +++ b/starboard/shared/stub/string_compare_no_case_n.cc @@ -14,8 +14,10 @@ #include "starboard/common/string.h" +#if SB_API_VERSION < 16 int SbStringCompareNoCaseN(const char* string1, const char* string2, size_t count) { return 0; } +#endif diff --git a/starboard/shared/win32/string_compare_no_case.cc b/starboard/shared/win32/string_compare_no_case.cc index 6021bf7d0ae1..85862f19f9ab 100644 --- a/starboard/shared/win32/string_compare_no_case.cc +++ b/starboard/shared/win32/string_compare_no_case.cc @@ -16,6 +16,8 @@ #include +#if SB_API_VERSION < 16 int SbStringCompareNoCase(const char* string1, const char* string2) { return _stricmp(string1, string2); } +#endif diff --git a/starboard/shared/win32/string_compare_no_case_n.cc b/starboard/shared/win32/string_compare_no_case_n.cc index 7490d3d9c7ce..3ac38d73a953 100644 --- a/starboard/shared/win32/string_compare_no_case_n.cc +++ b/starboard/shared/win32/string_compare_no_case_n.cc @@ -16,8 +16,10 @@ #include +#if SB_API_VERSION < 16 int SbStringCompareNoCaseN(const char* string1, const char* string2, size_t count) { return _strnicmp(string1, string2, count); } +#endif diff --git a/third_party/musl/BUILD.gn b/third_party/musl/BUILD.gn index 0c7d0578f439..3886d776441c 100644 --- a/third_party/musl/BUILD.gn +++ b/third_party/musl/BUILD.gn @@ -433,6 +433,7 @@ static_library("c_internal") { "src/string/rindex.c", "src/string/stpcpy.c", "src/string/stpncpy.c", + "src/string/strcasecmp.c", "src/string/strcat.c", "src/string/strchr.c", "src/string/strchrnul.c", @@ -444,6 +445,7 @@ static_library("c_internal") { "src/string/strlcat.c", "src/string/strlcpy.c", "src/string/strlen.c", + "src/string/strncasecmp.c", "src/string/strncat.c", "src/string/strncmp.c", "src/string/strncpy.c",