Reactos
at master 67 lines 2.0 kB view raw
1/*** 2*w_cmp.c - W versions of CompareString. 3* 4* Copyright (c) Microsoft Corporation. All rights reserved. 5* 6*Purpose: 7* Wrapper for CompareStringW. 8* 9*******************************************************************************/ 10#include <corecrt_internal.h> 11 12/*** 13*int __cdecl __acrt_CompareStringW - Get type information about a wide string. 14* 15*Purpose: 16* Internal support function. Assumes info in wide string format. 17* 18*Entry: 19* LPCWSTR LocaleName - locale context for the comparison. 20* DWORD dwCmpFlags - see NT\Chicago docs 21* LPCWSTR lpStringn - wide string to be compared 22* int cchCountn - wide char (word) count (NOT including nullptr) 23* (-1 if nullptr terminated) 24* 25*Exit: 26* Success: 1 - if lpString1 < lpString2 27* 2 - if lpString1 == lpString2 28* 3 - if lpString1 > lpString2 29* Failure: 0 30* 31*Exceptions: 32* 33*******************************************************************************/ 34 35extern "C" int __cdecl __acrt_CompareStringW( 36 LPCWSTR LocaleName, 37 DWORD dwCmpFlags, 38 PCWCH lpString1, 39 int cchCount1, 40 PCWCH lpString2, 41 int cchCount2 42 ) 43{ 44 /* 45 * CompareString will compare past nullptr. Must find nullptr if in string 46 * before cchCountn wide characters. 47 */ 48 49 if (cchCount1 > 0) 50 cchCount1= (int) wcsnlen(lpString1, cchCount1); 51 if (cchCount2 > 0) 52 cchCount2= (int) wcsnlen(lpString2, cchCount2); 53 54 if (!cchCount1 || !cchCount2) 55 return (cchCount1 - cchCount2 == 0) ? 2 : 56 (cchCount1 - cchCount2 < 0) ? 1 : 3; 57 58 return __acrt_CompareStringEx( LocaleName, 59 dwCmpFlags, 60 lpString1, 61 cchCount1, 62 lpString2, 63 cchCount2, 64 nullptr, 65 nullptr, 66 0); 67}