1/* 2** Copyright 2011, Oliver Tappe, zooey@hirschkaefer.de. All rights reserved. 3** Distributed under the terms of the MIT License. 4*/ 5 6#include <wctype.h> 7 8#include <wchar_private.h> 9 10 11int 12__wcscasecmp(const wchar_t* wcs1, const wchar_t* wcs2) 13{ 14 int cmp; 15 16 for (;;) { 17 cmp = towlower(*wcs1) - towlower(*wcs2++); 18 /* note: won't overflow, since our wchar_t is guaranteed to never 19 have the highest bit set */ 20 21 if (cmp != 0 || *wcs1++ == L'\0') 22 break; 23 } 24 25 return cmp; 26} 27 28 29B_DEFINE_WEAK_ALIAS(__wcscasecmp, wcscasecmp); 30 31 32int 33__wcscasecmp_l(const wchar_t* wcs1, const wchar_t* wcs2, locale_t locale) 34{ 35 int cmp; 36 37 for (;;) { 38 cmp = towlower_l(*wcs1, locale) - towlower_l(*wcs2++, locale); 39 40 if (cmp != 0 || *wcs1++ == L'\0') 41 break; 42 } 43 44 return cmp; 45} 46 47 48B_DEFINE_WEAK_ALIAS(__wcscasecmp_l, wcscasecmp_l); 49