MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / wcsnicomp

Function wcsnicomp

Libraries/unrar/unicode.cpp:446–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444
445
446int wcsnicomp(const wchar *s1,const wchar *s2,size_t n)
447{
448#ifdef _WIN_ALL
449 // If we specify 'n' exceeding the actual string length, CompareString goes
450 // beyond the trailing zero and compares garbage. So we need to limit 'n'
451 // to real string length.
452 size_t l1=Min(wcslen(s1)+1,n);
453 size_t l2=Min(wcslen(s2)+1,n);
454 return CompareStringW(LOCALE_USER_DEFAULT,NORM_IGNORECASE|SORT_STRINGSORT,s1,(int)l1,s2,(int)l2)-2;
455#else
456 if (n==0)
457 return 0;
458 while (true)
459 {
460 wchar u1 = towupper(*s1);
461 wchar u2 = towupper(*s2);
462 if (u1 != u2)
463 return u1 < u2 ? -1 : 1;
464 if (*s1==0 || --n==0)
465 break;
466 s1++;
467 s2++;
468 }
469 return 0;
470#endif
471}
472
473
474const wchar_t* wcscasestr(const wchar_t *str, const wchar_t *search)

Callers 6

wcsnicompcFunction · 0.85
PreprocessArgMethod · 0.85
ReadConfigMethod · 0.85
ProcessSwitchMethod · 0.85
ProcessCommandMethod · 0.85
mwcsnicompcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected