Purpose: Compare two strings on a case insensitive basis. This does not crash when given null arguments.
| Return Type | Function name | Arguments |
|---|---|---|
| int32_t | CstrCompareI | (const char*,const char*,uint32_t,) |
Declared in file: hzTextproc.h
Defined in file : hzTextproc.cpp
Function Logic:
Function body:
int32_t CstrCompareI (const char* pA)const char* pB, uint32_t nMaxlen,
{
// Category: Text Processing
//
// Purpose: Compare two strings on a case insensitive basis. This does not crash when
// given null arguments.
//
// Arguments: 1) pA First string
// 2) pB Second string
// 3) nMaxlen Max length to compare (default 0 for no maximum)
//
// Returns: +1 If pA is lexically greater than pB within the specified length
// -1 If pA is lexically less than pB within the specified length
// 0 If pA and pB are equivelent within the specified length
_hzfunc("CstrCompareI") ;
if (!pA || !pA[0])
{
if (!pB || !pB[0])
return 0;
return 1;
}
if (!pB || !pB[0])
return conv2lower(*pA) ;
if (!nMaxlen)
{
for (; *pA && *pB ; pA++, pB++)
{
if (conv2lower(*pA) != conv2lower(*pB))
break ;
}
}
else
{
uint32_t nCount ;
for (nCount = 0; nCount < nMaxlen ; nCount++, pA++, pB++)
{
if (conv2lower(*pA) != conv2lower(*pB))
break ;
}
if (nCount == nMaxlen)
return 0;
}
if (conv2lower(*pA) > conv2lower(*pB))
return 1;
if (conv2lower(*pA) < conv2lower(*pB))
return -1;
return 0;
}