- /* Only call _wcsicmp() if both strings are of nonzero length; otherwise
- * one could be NULL. */
- if (nbytes1 && nbytes2)
- return _wcsicmp((const wchar_t*)name1, (const wchar_t*)name2);
+ /* Return the result if the strings differ up to their minimum length.
+ * */
+ int result = _wcsnicmp((const wchar_t*)name1, (const wchar_t*)name2,
+ min(nbytes1 / 2, nbytes2 / 2));
+ if (result)
+ return result;
+