From 4d626c294c4783d454e27ea4e5614037dac8576e Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 1 Nov 2025 20:24:25 -0700 Subject: Use CompareStringOrdinal() instead of CompareString() case-insensitive This commit moves to the modern CompareStringOrdinal() for all case-insensitve uses of CompareString() with the invariant locale. Partially resolves 6947 --- .../Bal/stdbas/WixStandardBootstrapperApplication.cpp | 4 ++-- .../Bal/test/examples/TestEngine/ExampleTestEngine.cpp | 6 +++--- src/ext/Iis/ca/scaapppool.cpp | 18 +++++++++--------- src/ext/Iis/ca/scaexecIIS7.cpp | 18 +++++++++--------- src/ext/Iis/ca/scawebappext.cpp | 2 +- src/ext/NetFx/netcoresearch/netcoresearch.cpp | 8 ++++---- src/ext/VisualStudio/ca/vsca.cpp | 4 ++-- 7 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src/ext') diff --git a/src/ext/Bal/stdbas/WixStandardBootstrapperApplication.cpp b/src/ext/Bal/stdbas/WixStandardBootstrapperApplication.cpp index 59b2d8de..9ddab7c0 100644 --- a/src/ext/Bal/stdbas/WixStandardBootstrapperApplication.cpp +++ b/src/ext/Bal/stdbas/WixStandardBootstrapperApplication.cpp @@ -2928,7 +2928,7 @@ private: if (argv[i][0] == L'-' || argv[i][0] == L'/') { - if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"lang", -1)) + if (CSTR_EQUAL == ::CompareStringOrdinal(&argv[i][1], -1, L"lang", -1, TRUE)) { if (i + 1 >= argc) { @@ -2941,7 +2941,7 @@ private: hr = StrAllocString(psczLanguage, &argv[i][0], 0); BalExitOnFailure(hr, "Failed to copy language."); } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"cache", -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(&argv[i][1], -1, L"cache", -1, TRUE)) { m_fRequestedCacheOnly = TRUE; } diff --git a/src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp b/src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp index fc1938fe..9ad4e91f 100644 --- a/src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp +++ b/src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp @@ -19,15 +19,15 @@ int __cdecl wmain(int argc, LPWSTR argv[]) { fShowUsage = TRUE; } - else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"reload", -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(argv[1], -1, L"reload", -1, TRUE)) { hr = RunReloadEngine(argv[2], argv[3]); } - else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"shutdown", -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(argv[1], -1, L"shutdown", -1, TRUE)) { hr = RunShutdownEngine(argv[2], argv[3]); } - else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"waitforquit", -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(argv[1], -1, L"waitforquit", -1, TRUE)) { hr = RunWaitForQuitEngine(argv[2], argv[3]); } diff --git a/src/ext/Iis/ca/scaapppool.cpp b/src/ext/Iis/ca/scaapppool.cpp index 781c55ca..951f2d4b 100644 --- a/src/ext/Iis/ca/scaapppool.cpp +++ b/src/ext/Iis/ca/scaapppool.cpp @@ -80,7 +80,7 @@ HRESULT ScaAppPoolRead( WcaLog(LOGMSG_VERBOSE, "Skipping ScaAppPoolRead() - required table not present"); ExitFunction1(hr = S_FALSE); } - + hr = WcaBeginUnwrapQuery(&hComponentQuery, ppwzCustomActionData); ExitOnFailure(hr, "Failed to unwrap query for ScaAppPoolRead"); @@ -478,17 +478,17 @@ HRESULT ScaWriteAppPool( } else if (psap->iAttributes & APATTR_OTHERUSER) { - if (!*psap->suUser.wzDomain || CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, psap->suUser.wzDomain, -1, L".", -1)) + if (!*psap->suUser.wzDomain || CSTR_EQUAL == ::CompareStringOrdinal(psap->suUser.wzDomain, -1, L".", -1, TRUE)) { - if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, psap->suUser.wzName, -1, L"NetworkService", -1)) + if (CSTR_EQUAL == ::CompareStringOrdinal(psap->suUser.wzName, -1, L"NetworkService", -1, TRUE)) { dwIdentity = MD_APPPOOL_IDENTITY_TYPE_NETWORKSERVICE; } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, psap->suUser.wzName, -1, L"LocalService", -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(psap->suUser.wzName, -1, L"LocalService", -1, TRUE)) { dwIdentity = MD_APPPOOL_IDENTITY_TYPE_LOCALSERVICE; } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, psap->suUser.wzName, -1, L"LocalSystem", -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(psap->suUser.wzName, -1, L"LocalSystem", -1, TRUE)) { dwIdentity = MD_APPPOOL_IDENTITY_TYPE_LOCALSYSTEM; } @@ -497,17 +497,17 @@ HRESULT ScaWriteAppPool( dwIdentity = MD_APPPOOL_IDENTITY_TYPE_SPECIFICUSER; } } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, psap->suUser.wzDomain, -1, L"NT AUTHORITY", -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(psap->suUser.wzDomain, -1, L"NT AUTHORITY", -1, TRUE)) { - if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, psap->suUser.wzName, -1, L"NETWORK SERVICE", -1)) + if (CSTR_EQUAL == ::CompareStringOrdinal(psap->suUser.wzName, -1, L"NETWORK SERVICE", -1, TRUE)) { dwIdentity = MD_APPPOOL_IDENTITY_TYPE_NETWORKSERVICE; } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, psap->suUser.wzName, -1, L"SERVICE", -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(psap->suUser.wzName, -1, L"SERVICE", -1, TRUE)) { dwIdentity = MD_APPPOOL_IDENTITY_TYPE_LOCALSERVICE; } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, psap->suUser.wzName, -1, L"SYSTEM", -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(psap->suUser.wzName, -1, L"SYSTEM", -1, TRUE)) { dwIdentity = MD_APPPOOL_IDENTITY_TYPE_LOCALSYSTEM; } diff --git a/src/ext/Iis/ca/scaexecIIS7.cpp b/src/ext/Iis/ca/scaexecIIS7.cpp index 108007a1..52378d34 100644 --- a/src/ext/Iis/ca/scaexecIIS7.cpp +++ b/src/ext/Iis/ca/scaexecIIS7.cpp @@ -566,7 +566,7 @@ HRESULT IIS7AspProperty( // //Do not append trailing '/' for default vDir // - if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pwzPathName, -1, L"/", -1)) + if (CSTR_EQUAL != ::CompareStringOrdinal(pwzPathName, -1, L"/", -1, TRUE)) { hr = StrAllocConcat(&pwzLocationPath, L"/", 0); ExitOnFailure(hr, "failed to copy location WebDir '/'"); @@ -742,7 +742,7 @@ HRESULT IIS7WebDir( // //Do not append trailing '/' for default vDir // - if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pwzPathName, -1, L"/", -1)) + if (CSTR_EQUAL != ::CompareStringOrdinal(pwzPathName, -1, L"/", -1, TRUE)) { hr = StrAllocConcat(&pwzLocationPath, L"/", 0); ExitOnFailure(hr, "failed to copy location WebDir '/'"); @@ -998,7 +998,7 @@ HRESULT IIS7WebError( hr = StrAllocFormatted(&pwzConfigPath, L"%s/%s", IIS_CONFIG_APPHOST_ROOT, pwzSiteName); ExitOnFailure(hr, "failed to format web error config path"); - if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pwzAppName, -1, L"/", -1)) + if (CSTR_EQUAL != ::CompareStringOrdinal(pwzAppName, -1, L"/", -1, TRUE)) { hr = StrAllocConcat(&pwzConfigPath, L"/", 0); ExitOnFailure(hr, "failed to copy web error config path delim"); @@ -1325,7 +1325,7 @@ HRESULT IIS7HttpHeader( hr = StrAllocFormatted(&pwzConfigPath, L"%s/%s", IIS_CONFIG_APPHOST_ROOT, pwzSiteName); ExitOnFailure(hr, "failed to format web error config path"); - if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pwzAppName, -1, L"/", -1)) + if (CSTR_EQUAL != ::CompareStringOrdinal(pwzAppName, -1, L"/", -1, TRUE)) { hr = StrAllocConcat(&pwzConfigPath, L"/", 0); ExitOnFailure(hr, "failed to copy web error config path delim"); @@ -2340,7 +2340,7 @@ HRESULT IIS7AppExtension( // //Do not append trailing '/' for default vDir // - if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pwzWebRoot, -1, L"/", -1)) + if (CSTR_EQUAL != ::CompareStringOrdinal(pwzWebRoot, -1, L"/", -1, TRUE)) { hr = StrAllocConcat(&pwzConfigPath, L"/", 0); ExitOnFailure(hr, "failed to copy appext config path delim"); @@ -2495,7 +2495,7 @@ LExit: // //Do not append trailing '/' for default vDir // - if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pwzWebRoot, -1, L"/", -1)) + if (CSTR_EQUAL != ::CompareStringOrdinal(pwzWebRoot, -1, L"/", -1, TRUE)) { hr = StrAllocConcat(&pwzConfigPath, L"/", 0); ExitOnFailure(hr, "failed to copy appext config path delim"); @@ -2627,7 +2627,7 @@ HRESULT IIS7DirProperties( // //Do not append trailing '/' for default vDir // - if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pwzWebRoot, -1, L"/", -1)) + if (CSTR_EQUAL != ::CompareStringOrdinal(pwzWebRoot, -1, L"/", -1, TRUE)) { hr = StrAllocConcat(&pwzConfigPath, L"/", 0); ExitOnFailure(hr, "failed to copy appext config path delim"); @@ -3337,7 +3337,7 @@ static HRESULT CreateWebLog( ExitOnFailure(hr, "Failed get logfile element"); ReleaseVariant(vtProp); - if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pwzFormat, -1, L"none", -1)) + if (CSTR_EQUAL != ::CompareStringOrdinal(pwzFormat, -1, L"none", -1, TRUE)) { hr = Iis7PutPropertyString(pLogFile, IIS_CONFIG_LOGFORMAT, pwzFormat); ExitOnFailure(hr, "Failed set logfile format property"); @@ -4118,7 +4118,7 @@ static HRESULT ClearLocationTag( ExitOnFailure(hr, "Failed to get IIS location collection count"); hr = pLocation->get_Path(&bstrLocationPath); - if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, swLocationPath, -1, bstrLocationPath, -1)) + if (CSTR_EQUAL == ::CompareStringOrdinal(swLocationPath, -1, bstrLocationPath, -1, TRUE)) { hr = pLocationCollection->DeleteLocation(vtIndex); ExitOnFailure(hr, "Failed to delete IIS location tag %ls",swLocationPath); diff --git a/src/ext/Iis/ca/scawebappext.cpp b/src/ext/Iis/ca/scawebappext.cpp index cf3b9dd3..2f74871c 100644 --- a/src/ext/Iis/ca/scawebappext.cpp +++ b/src/ext/Iis/ca/scawebappext.cpp @@ -124,7 +124,7 @@ HRESULT ScaWebAppExtensionsWrite( } // if verbs were specified and not the keyword "all" - if (pswappext->wzVerbs[0] && CSTR_EQUAL != CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pswappext->wzVerbs, -1, L"all", -1)) + if (pswappext->wzVerbs[0] && CSTR_EQUAL != CompareStringOrdinal(pswappext->wzVerbs, -1, L"all", -1, TRUE)) { hr = ::StringCchCatW(wzAppExtension, countof(wzAppExtension), L","); ExitOnFailure(hr, "Failed to concatenate comma to app extension string"); diff --git a/src/ext/NetFx/netcoresearch/netcoresearch.cpp b/src/ext/NetFx/netcoresearch/netcoresearch.cpp index 8c788461..1b151d8f 100644 --- a/src/ext/NetFx/netcoresearch/netcoresearch.cpp +++ b/src/ext/NetFx/netcoresearch/netcoresearch.cpp @@ -86,7 +86,7 @@ HRESULT GetSearchStateFromArguments( wzSearchKind = argv[1]; - if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzSearchKind, -1, L"runtime", -1)) + if (CSTR_EQUAL == ::CompareStringOrdinal(wzSearchKind, -1, L"runtime", -1, TRUE)) { if (argc != 4) { @@ -103,7 +103,7 @@ HRESULT GetSearchStateFromArguments( pSearchState->Runtime.wzTargetName = wzTargetName; } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzSearchKind, -1, L"sdk", -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(wzSearchKind, -1, L"sdk", -1, TRUE)) { if (argc != 3) { @@ -117,7 +117,7 @@ HRESULT GetSearchStateFromArguments( hr = StrStringToUInt32(wzMajorVersion, 0, reinterpret_cast(&pSearchState->Sdk.dwMajorVersion)); ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to get sdk major version from: %ls", wzMajorVersion); } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzSearchKind, -1, L"sdkfeatureband", -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(wzSearchKind, -1, L"sdkfeatureband", -1, TRUE)) { if (argc != 5) { @@ -208,7 +208,7 @@ static HRESULT PerformRuntimeSearch( const hostfxr_dotnet_environment_framework_info* pFrameworkInfo = pInfo->frameworks + i; ReleaseVerutilVersion(pFrameworkVersion); - if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzTargetName, -1, pFrameworkInfo->name, -1)) + if (CSTR_EQUAL != ::CompareStringOrdinal(wzTargetName, -1, pFrameworkInfo->name, -1, TRUE)) { continue; } diff --git a/src/ext/VisualStudio/ca/vsca.cpp b/src/ext/VisualStudio/ca/vsca.cpp index 736add1f..681187d6 100644 --- a/src/ext/VisualStudio/ca/vsca.cpp +++ b/src/ext/VisualStudio/ca/vsca.cpp @@ -219,7 +219,7 @@ static HRESULT InstanceInProducts( { const LPCWSTR wzProduct = rgwzProducts[i]; - if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, bstrId, -1, wzProduct, -1)) + if (CSTR_EQUAL == ::CompareStringOrdinal(bstrId, -1, wzProduct, -1, TRUE)) { hr = S_OK; ExitFunction(); @@ -579,7 +579,7 @@ static HRESULT SetPropertyForComponent( { const VS_COMPONENT_PROPERTY* pComponent = &rgComponents[i]; - if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pComponent->pwzComponent, -1, wzComponent, -1)) + if (CSTR_EQUAL == ::CompareStringOrdinal(pComponent->pwzComponent, -1, wzComponent, -1, TRUE)) { hr = WcaSetIntProperty(pComponent->pwzProperty, 1); ExitOnFailure(hr, "Failed to set property: %ls", pComponent->pwzProperty); -- cgit v1.2.3-55-g6feb