2
0
Эх сурвалжийг харах

xplat-intl: default to non intl compare for localeCompare

Oguz Bastemur 8 жил өмнө
parent
commit
fa6274f4ae

+ 10 - 4
lib/Runtime/Library/IntlEngineInterfaceExtensionObject.cpp

@@ -1380,10 +1380,6 @@ namespace Js
 #ifdef _WIN32
             // xplat-todo: Need to replace this with platform-agnostic API
             compareResult = CompareStringEx(givenLocale != nullptr ? givenLocale : defaultLocale, compareFlags, aLeft, size1, aRight, size2, NULL, NULL, 0);
-#else
-            // FIXME (doilij): when CompareStringEx is implemented in PlatformAgnostic, call that function here
-            compareResult = 2; // 2 means strings are equal (reasonable default)
-#endif
 
             // Get the last error code so that it won't be affected by END_TEMP_ALLOCATOR.
             if (compareResult == 0)
@@ -1400,6 +1396,16 @@ namespace Js
         }
 
         JavascriptError::MapAndThrowError(scriptContext, HRESULT_FROM_WIN32(lastError));
+#else // _WIN32 (once ICU interface supports this, keep the implementation below for non-icu!)
+            compareResult = wcsncmp(aLeft, aRight, min(size1, size2));
+            if (compareResult == 0 && size1 != size2)
+            {
+                compareResult = size1 > size2 ? 1 : -1;
+            }
+            return JavascriptNumber::ToVar(compareResult, scriptContext);
+        }
+        END_TEMP_ALLOCATOR(tempAllocator, scriptContext);
+#endif
     }
 
     Var IntlEngineInterfaceExtensionObject::EntryIntl_CurrencyDigits(RecyclableObject* function, CallInfo callInfo, ...)

+ 1 - 2
test/Strings/rlexe.xml

@@ -106,7 +106,6 @@
     <default>
       <files>compare.js</files>
       <baseline>compare.baseline</baseline>
-      <compile-flags>-Intl-</compile-flags>
     </default>
   </test>
   <test>
@@ -248,7 +247,7 @@
       <tags>exclude_win7</tags>
     </default>
   </test>
-  <!--  This test is disabled as this is going to throw out of memory. Since this test takes time to reach the memory boundary, 
+  <!--  This test is disabled as this is going to throw out of memory. Since this test takes time to reach the memory boundary,
         it does not seem to be a good test to keep it enabled with -EnableFatalErrorOnOOM-
   <test>
     <default>