|
|
|
@ -62,7 +62,7 @@ kvi_wslen_t kvi_wstrlen(const kvi_wchar_t * str)
|
|
|
|
|
|
|
|
|
|
#define WVSNPRINTF_BODY \
|
|
|
|
|
\
|
|
|
|
|
register kvi_wchar_t *p; \
|
|
|
|
|
kvi_wchar_t *p; \
|
|
|
|
|
long int argValue; \
|
|
|
|
|
unsigned long argUValue; \
|
|
|
|
|
\
|
|
|
|
@ -204,7 +204,7 @@ bool kvi_qstringEqualCI(const TQString &s1,const TQString &s2)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool kvi_matchStringCI(register const char * exp,register const char * str)
|
|
|
|
|
bool kvi_matchStringCI(const char * exp,const char * str)
|
|
|
|
|
{
|
|
|
|
|
// a
|
|
|
|
|
// .
|
|
|
|
@ -264,7 +264,7 @@ check_recovery:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool kvi_matchStringCS(register const char * exp,register const char * str)
|
|
|
|
|
bool kvi_matchStringCS(const char * exp,const char * str)
|
|
|
|
|
{
|
|
|
|
|
// a
|
|
|
|
|
// .
|
|
|
|
@ -325,7 +325,7 @@ check_recovery:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool kvi_matchStringWithTerminator(register const char * exp,register const char * str,char terminator,const char ** r1,const char ** r2)
|
|
|
|
|
bool kvi_matchStringWithTerminator(const char * exp,const char * str,char terminator,const char ** r1,const char ** r2)
|
|
|
|
|
{
|
|
|
|
|
#define NOT_AT_END(__str) (*__str && (*__str != terminator))
|
|
|
|
|
|
|
|
|
@ -396,7 +396,7 @@ check_recovery:
|
|
|
|
|
#undef NOT_AT_END
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool kvi_matchWildExpr(register const char *m1,register const char *m2)
|
|
|
|
|
bool kvi_matchWildExpr(const char *m1,const char *m2)
|
|
|
|
|
{
|
|
|
|
|
//Matches two regular expressions containging wildcards (* and ?)
|
|
|
|
|
|
|
|
|
@ -492,7 +492,7 @@ bool kvi_matchWildExpr(register const char *m1,register const char *m2)
|
|
|
|
|
WARNING: Don't remove: working code but actually unused in KVIrc
|
|
|
|
|
Later it might become useful
|
|
|
|
|
|
|
|
|
|
bool kvi_matchWildExprCS(register const char *m1,register const char *m2)
|
|
|
|
|
bool kvi_matchWildExprCS(const char *m1,const char *m2)
|
|
|
|
|
{
|
|
|
|
|
if(!(m1 && m2 && (*m1)))return false;
|
|
|
|
|
const char * savePos1 = 0;
|
|
|
|
@ -541,7 +541,7 @@ bool kvi_matchWildExprCS(register const char *m1,register const char *m2)
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bool kvi_matchWildExprWithTerminator(register const char *m1,register const char *m2,char terminator,
|
|
|
|
|
bool kvi_matchWildExprWithTerminator(const char *m1,const char *m2,char terminator,
|
|
|
|
|
const char ** r1,const char ** r2)
|
|
|
|
|
{
|
|
|
|
|
//Matches two regular expressions containging wildcards
|
|
|
|
@ -664,7 +664,7 @@ int kvi_vsnprintf(char *buffer,int len,const char *fmt,kvi_va_list list)
|
|
|
|
|
__range_valid(buffer);
|
|
|
|
|
__range_valid(len > 0); //printing 0 characters is senseless
|
|
|
|
|
|
|
|
|
|
register char *p;
|
|
|
|
|
char *p;
|
|
|
|
|
char *argString;
|
|
|
|
|
long argValue;
|
|
|
|
|
unsigned long argUValue;
|
|
|
|
@ -781,7 +781,7 @@ int kvi_irc_vsnprintf(char *buffer,const char *fmt,kvi_va_list list,bool *bTrunc
|
|
|
|
|
__range_valid(fmt);
|
|
|
|
|
__range_valid(buffer);
|
|
|
|
|
if( !( buffer && fmt) ) return false;
|
|
|
|
|
register char *p;
|
|
|
|
|
char *p;
|
|
|
|
|
char *argString;
|
|
|
|
|
long argValue;
|
|
|
|
|
unsigned long argUValue;
|
|
|
|
@ -892,8 +892,8 @@ bool kvi_strEqualCS(const char *str1,const char *str2)
|
|
|
|
|
__range_valid(str1);
|
|
|
|
|
__range_valid(str2);
|
|
|
|
|
if( !( str1 && str2 ) ) return false;
|
|
|
|
|
register unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
register unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
while(*s1)if(*s1++ != *s2++)return false;
|
|
|
|
|
return (*s1 == *s2);
|
|
|
|
|
}
|
|
|
|
@ -904,8 +904,8 @@ bool kvi_strEqualCSN(const char *str1,const char *str2,int len)
|
|
|
|
|
__range_valid(str2);
|
|
|
|
|
__range_valid(len >= 0);
|
|
|
|
|
if( !( str1 && str2 && (len >= 0) ) ) return false;
|
|
|
|
|
register unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
register unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
while(len-- && *s1)if(*s1++ != *s2++)return false;
|
|
|
|
|
return (len < 0);
|
|
|
|
|
}
|
|
|
|
@ -918,8 +918,8 @@ bool kvi_strEqualCIN(const char *str1,const char *str2,int len)
|
|
|
|
|
__range_valid(str2);
|
|
|
|
|
__range_valid(len >= 0);
|
|
|
|
|
if( !( str1 && str2 && (len >= 0) ) ) return false;
|
|
|
|
|
register unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
register unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
while(len-- && *s1)if(tolower(*s1++) != tolower(*s2++))return false;
|
|
|
|
|
return (len < 0);
|
|
|
|
|
}
|
|
|
|
@ -929,8 +929,8 @@ bool kvi_strEqualCI(const char *str1,const char *str2)
|
|
|
|
|
__range_valid(str1);
|
|
|
|
|
__range_valid(str2);
|
|
|
|
|
if( !( str1 && str2) ) return false;
|
|
|
|
|
register unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
register unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
while(*s1)if(tolower(*s1++) != tolower(*s2++))return false;
|
|
|
|
|
return (*s1 == *s2);
|
|
|
|
|
}
|
|
|
|
@ -945,8 +945,8 @@ int kvi_strcmpCI(const char *str1,const char *str2)
|
|
|
|
|
__range_valid(str1);
|
|
|
|
|
__range_valid(str2);
|
|
|
|
|
if( !( str1 && str2) ) return false;
|
|
|
|
|
register unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
register unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
int diff;
|
|
|
|
|
unsigned char rightchar;
|
|
|
|
|
while(!(diff=(rightchar=tolower(*s1++)) - tolower(*s2++)))if(!rightchar)break;
|
|
|
|
@ -963,8 +963,8 @@ int kvi_strcmpCI(const char *str1,const char *str2)
|
|
|
|
|
// //abcd abce
|
|
|
|
|
// __range_valid(str1);
|
|
|
|
|
// __range_valid(str2);
|
|
|
|
|
// register unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
// register unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
// unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
// unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
// int diff;
|
|
|
|
|
// unsigned char rightchar;
|
|
|
|
|
// while(len--)
|
|
|
|
@ -981,8 +981,8 @@ int kvi_strcmpCS(const char *str1,const char *str2)
|
|
|
|
|
__range_valid(str1);
|
|
|
|
|
__range_valid(str2);
|
|
|
|
|
if( !( str1 && str2) ) return false;
|
|
|
|
|
register unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
register unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
|
unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
int diff;
|
|
|
|
|
while(!(diff=(*s1)-(*s2++)))if(!*s1++)break;
|
|
|
|
|
return diff; //diff is nonzero or end of both was reached (it is positive if *s2 > *s1
|
|
|
|
@ -993,8 +993,8 @@ int kvi_strMatchRevCS(const char *str1, const char *str2, int index)
|
|
|
|
|
__range_valid(str1);
|
|
|
|
|
__range_valid(str2);
|
|
|
|
|
if( !( str1 && str2) ) return false;
|
|
|
|
|
register char *s1=(char *)str1;
|
|
|
|
|
register char *s2=(char *)str2;
|
|
|
|
|
char *s1=(char *)str1;
|
|
|
|
|
char *s2=(char *)str2;
|
|
|
|
|
|
|
|
|
|
int curlen=(int)strlen(str1);
|
|
|
|
|
int diff;
|
|
|
|
@ -1135,7 +1135,7 @@ KviStr::KviStr(char c,int fillLen)
|
|
|
|
|
__range_valid(fillLen >= 0);
|
|
|
|
|
m_len = fillLen;
|
|
|
|
|
m_ptr = (char *)kvi_malloc(m_len+1);
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
while(fillLen--)*p++=c;
|
|
|
|
|
*p='\0';
|
|
|
|
|
}
|
|
|
|
@ -1151,7 +1151,7 @@ KviStr::KviStr(const kvi_wchar_t * unicode)
|
|
|
|
|
} else {
|
|
|
|
|
m_len = kvi_wstrlen(unicode);
|
|
|
|
|
m_ptr = (char *)kvi_malloc(m_len + 1);
|
|
|
|
|
register char * p = m_ptr;
|
|
|
|
|
char * p = m_ptr;
|
|
|
|
|
while(*unicode)*p++ = *unicode++;
|
|
|
|
|
*p = 0;
|
|
|
|
|
}
|
|
|
|
@ -1161,7 +1161,7 @@ KviStr::KviStr(const kvi_wchar_t * unicode,int len)
|
|
|
|
|
{
|
|
|
|
|
m_len = len;
|
|
|
|
|
m_ptr = (char *)kvi_malloc(m_len + 1);
|
|
|
|
|
register char * p = m_ptr;
|
|
|
|
|
char * p = m_ptr;
|
|
|
|
|
char * end = p + len;
|
|
|
|
|
while(p != end)
|
|
|
|
|
{
|
|
|
|
@ -1671,7 +1671,7 @@ unsigned char iso88591_toUpper_map[256]=
|
|
|
|
|
|
|
|
|
|
void KviStr::toUpperISO88591()
|
|
|
|
|
{
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
while(*p)
|
|
|
|
|
{
|
|
|
|
|
*p=(char)iso88591_toUpper_map[(unsigned char)*p];
|
|
|
|
@ -1681,7 +1681,7 @@ void KviStr::toUpperISO88591()
|
|
|
|
|
|
|
|
|
|
void KviStr::toUpper()
|
|
|
|
|
{
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
while(*p)
|
|
|
|
|
{
|
|
|
|
|
*p=toupper(*p);
|
|
|
|
@ -1727,7 +1727,7 @@ unsigned char iso88591_toLower_map[256]=
|
|
|
|
|
|
|
|
|
|
void KviStr::toLowerISO88591()
|
|
|
|
|
{
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
while(*p)
|
|
|
|
|
{
|
|
|
|
|
*p=(char)iso88591_toLower_map[(unsigned char)*p];
|
|
|
|
@ -1738,7 +1738,7 @@ void KviStr::toLowerISO88591()
|
|
|
|
|
|
|
|
|
|
void KviStr::toLower()
|
|
|
|
|
{
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
while(*p)
|
|
|
|
|
{
|
|
|
|
|
*p=tolower(*p);
|
|
|
|
@ -2161,7 +2161,7 @@ KviStr & KviStr::transliterate(const char * szToFind,const char * szReplacement)
|
|
|
|
|
|
|
|
|
|
int KviStr::occurences(char c,bool caseS) const
|
|
|
|
|
{
|
|
|
|
|
register char *p = m_ptr;
|
|
|
|
|
char *p = m_ptr;
|
|
|
|
|
int cnt=0;
|
|
|
|
|
if(caseS){
|
|
|
|
|
while(*p){
|
|
|
|
@ -2181,7 +2181,7 @@ int KviStr::occurences(char c,bool caseS) const
|
|
|
|
|
int KviStr::occurences(const char *str,bool caseS) const
|
|
|
|
|
{
|
|
|
|
|
__range_valid(str);
|
|
|
|
|
register char *p = m_ptr;
|
|
|
|
|
char *p = m_ptr;
|
|
|
|
|
int cnt=0;
|
|
|
|
|
int len = (int)strlen(str);
|
|
|
|
|
if(caseS){
|
|
|
|
@ -2205,7 +2205,7 @@ int KviStr::occurences(const char *str,bool caseS) const
|
|
|
|
|
|
|
|
|
|
bool KviStr::contains(char c,bool caseS) const
|
|
|
|
|
{
|
|
|
|
|
register char *p = m_ptr;
|
|
|
|
|
char *p = m_ptr;
|
|
|
|
|
if(caseS)
|
|
|
|
|
{
|
|
|
|
|
while(*p)
|
|
|
|
@ -2227,7 +2227,7 @@ bool KviStr::contains(char c,bool caseS) const
|
|
|
|
|
bool KviStr::contains(const char *str,bool caseS) const
|
|
|
|
|
{
|
|
|
|
|
__range_valid(str);
|
|
|
|
|
register char *p = m_ptr;
|
|
|
|
|
char *p = m_ptr;
|
|
|
|
|
int len = (int)strlen(str);
|
|
|
|
|
if(caseS)
|
|
|
|
|
{
|
|
|
|
@ -2259,8 +2259,8 @@ KviStr & KviStr::setNum(long num)
|
|
|
|
|
char numberBuffer[30];
|
|
|
|
|
bool bNegative = false;
|
|
|
|
|
long tmp;
|
|
|
|
|
register char *p;
|
|
|
|
|
register char *pNumBuf = numberBuffer;
|
|
|
|
|
char *p;
|
|
|
|
|
char *pNumBuf = numberBuffer;
|
|
|
|
|
|
|
|
|
|
// somebody can explain me why -(-2147483648) = -2147483648 ? (2^31)
|
|
|
|
|
// it is like signed char x = 128 ---> 10000000 that is signed -0 (!?)
|
|
|
|
@ -2320,8 +2320,8 @@ KviStr & KviStr::setNum(unsigned long num)
|
|
|
|
|
{
|
|
|
|
|
char numberBuffer[30];
|
|
|
|
|
unsigned long tmp;
|
|
|
|
|
register char *p;
|
|
|
|
|
register char *pNumBuf = numberBuffer;
|
|
|
|
|
char *p;
|
|
|
|
|
char *pNumBuf = numberBuffer;
|
|
|
|
|
|
|
|
|
|
//write the number in a temporary buffer (at least '0')
|
|
|
|
|
do {
|
|
|
|
@ -2342,7 +2342,7 @@ long KviStr::toLong(bool *bOk) const
|
|
|
|
|
{
|
|
|
|
|
long result = 0;
|
|
|
|
|
if(bOk)*bOk = false;
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
bool bNeg = false;
|
|
|
|
|
while(isspace(*p))p++; //skip spaces
|
|
|
|
|
if(*p == '-'){
|
|
|
|
@ -2369,7 +2369,7 @@ unsigned long KviStr::toULong(bool *bOk) const
|
|
|
|
|
{
|
|
|
|
|
unsigned long result = 0;
|
|
|
|
|
if(bOk)*bOk = false;
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
while(isspace(*p))p++; //skip spaces
|
|
|
|
|
if(isdigit(*p)){ //point to something interesting ?
|
|
|
|
|
do{
|
|
|
|
@ -2558,7 +2558,7 @@ KviStr & KviStr::setLen(int len)
|
|
|
|
|
|
|
|
|
|
KviStr & KviStr::stripLeftWhiteSpace()
|
|
|
|
|
{
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
while(isspace(*p))p++;
|
|
|
|
|
m_len -= (p-m_ptr);
|
|
|
|
|
kvi_memmove(m_ptr,p,m_len+1);
|
|
|
|
@ -2569,7 +2569,7 @@ KviStr & KviStr::stripLeftWhiteSpace()
|
|
|
|
|
KviStr & KviStr::stripLeft(char c)
|
|
|
|
|
{
|
|
|
|
|
__range_valid(c != '\0');
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
while(*p == c)p++;
|
|
|
|
|
m_len -= (p-m_ptr);
|
|
|
|
|
kvi_memmove(m_ptr,p,m_len+1);
|
|
|
|
@ -2581,7 +2581,7 @@ bool KviStr::getToken(KviStr & str,char sep)
|
|
|
|
|
{
|
|
|
|
|
__range_valid(str.m_ptr);
|
|
|
|
|
__range_valid(str.m_ptr != m_ptr);
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
//skip to the end
|
|
|
|
|
while(*p && (*p != sep))p++;
|
|
|
|
|
//0123456789
|
|
|
|
@ -2601,7 +2601,7 @@ bool KviStr::getLine(KviStr &str)
|
|
|
|
|
__range_valid(str.m_ptr);
|
|
|
|
|
__range_valid(str.m_ptr != m_ptr);
|
|
|
|
|
if(m_len == 0)return false;
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
//skip to the end
|
|
|
|
|
while(*p && (*p != '\n'))p++;
|
|
|
|
|
//0123456789
|
|
|
|
@ -2618,7 +2618,7 @@ bool KviStr::getLine(KviStr &str)
|
|
|
|
|
|
|
|
|
|
KviStr KviStr::getToken(char sep)
|
|
|
|
|
{
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
while(*p && (*p != sep))p++;
|
|
|
|
|
KviStr ret(m_ptr,p);
|
|
|
|
|
while(*p && (*p == sep))p++;
|
|
|
|
@ -2660,7 +2660,7 @@ KviStr & KviStr::sprintf(const char *fmt,...)
|
|
|
|
|
int KviStr::find(const char *str,int idx,bool caseS) const
|
|
|
|
|
{
|
|
|
|
|
if(idx >= m_len)return -1;
|
|
|
|
|
register char *p=m_ptr + idx;
|
|
|
|
|
char *p=m_ptr + idx;
|
|
|
|
|
int len = (int)strlen(str);
|
|
|
|
|
if(caseS){
|
|
|
|
|
for(;;){
|
|
|
|
@ -2685,7 +2685,7 @@ int KviStr::find(const char *str,int idx,bool caseS) const
|
|
|
|
|
int KviStr::find(char c,int idx) const
|
|
|
|
|
{
|
|
|
|
|
if(idx >= m_len)return -1;
|
|
|
|
|
register char *p=m_ptr + idx;
|
|
|
|
|
char *p=m_ptr + idx;
|
|
|
|
|
while(*p && (*p != c))p++;
|
|
|
|
|
return (*p ? p-m_ptr : -1);
|
|
|
|
|
}
|
|
|
|
@ -2694,7 +2694,7 @@ int KviStr::find(char c,int idx) const
|
|
|
|
|
int KviStr::findRev(const char *str,int idx,bool caseS) const
|
|
|
|
|
{
|
|
|
|
|
if((m_len + idx) < 0)return -1;
|
|
|
|
|
register char *p=m_ptr + m_len + idx;
|
|
|
|
|
char *p=m_ptr + m_len + idx;
|
|
|
|
|
int len = (int)strlen(str);
|
|
|
|
|
if(caseS)
|
|
|
|
|
{
|
|
|
|
@ -2720,7 +2720,7 @@ int KviStr::findRev(const char *str,int idx,bool caseS) const
|
|
|
|
|
|
|
|
|
|
int KviStr::findFirstIdx(char c) const
|
|
|
|
|
{
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
while(*p && (*p != c))p++;
|
|
|
|
|
return (*p ? p-m_ptr : -1);
|
|
|
|
|
}
|
|
|
|
@ -2743,7 +2743,7 @@ int KviStr::findFirstIdx(const char *str,bool caseS) const
|
|
|
|
|
// since a single UNICODE char may use one or more bytes...
|
|
|
|
|
|
|
|
|
|
__range_valid(str);
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
int len = (int)strlen(str);
|
|
|
|
|
if(caseS){
|
|
|
|
|
for(;;){
|
|
|
|
@ -2771,7 +2771,7 @@ int KviStr::findLastIdx(char c) const
|
|
|
|
|
//Empty string ?
|
|
|
|
|
if(m_len < 1)return -1;
|
|
|
|
|
//p points to the last character in the string
|
|
|
|
|
register char *p=((m_ptr+m_len)-1);
|
|
|
|
|
char *p=((m_ptr+m_len)-1);
|
|
|
|
|
//go back until we find a match or we run to the first char in the string.
|
|
|
|
|
while((*p != c) && (p > m_ptr))p--;
|
|
|
|
|
//if *p == c --> matched , else we are at the beginning of the string.
|
|
|
|
@ -2793,7 +2793,7 @@ int KviStr::findLastIdx(const char *str,bool caseS) const
|
|
|
|
|
//Too long ?
|
|
|
|
|
if(m_len < len)return -1;
|
|
|
|
|
//p points to the last character in the string
|
|
|
|
|
register char *p=((m_ptr+m_len)-1);
|
|
|
|
|
char *p=((m_ptr+m_len)-1);
|
|
|
|
|
if(caseS){
|
|
|
|
|
for(;;){
|
|
|
|
|
//go back until we find a character that mathes or we run to the first char.
|
|
|
|
@ -2833,8 +2833,8 @@ KviStr & KviStr::stripWhiteSpace()
|
|
|
|
|
// abcd 0
|
|
|
|
|
// ^ ^
|
|
|
|
|
// left right
|
|
|
|
|
register char *left=m_ptr;
|
|
|
|
|
register char *right=m_ptr+m_len-1;
|
|
|
|
|
char *left=m_ptr;
|
|
|
|
|
char *right=m_ptr+m_len-1;
|
|
|
|
|
// skip initial spaces
|
|
|
|
|
while(isspace(*left))left++;
|
|
|
|
|
if(*left){
|
|
|
|
@ -2860,7 +2860,7 @@ KviStr & KviStr::stripRightWhiteSpace()
|
|
|
|
|
{
|
|
|
|
|
if(*m_ptr)
|
|
|
|
|
{
|
|
|
|
|
register char *right=m_ptr+m_len-1;
|
|
|
|
|
char *right=m_ptr+m_len-1;
|
|
|
|
|
const char *start=right;
|
|
|
|
|
while((right >= m_ptr) && isspace( *right ))right--;
|
|
|
|
|
if(right != start)
|
|
|
|
@ -2877,7 +2877,7 @@ KviStr & KviStr::stripRight(char c)
|
|
|
|
|
{
|
|
|
|
|
if(*m_ptr)
|
|
|
|
|
{
|
|
|
|
|
register char *right=m_ptr+m_len-1;
|
|
|
|
|
char *right=m_ptr+m_len-1;
|
|
|
|
|
const char *start=right;
|
|
|
|
|
while((right >= m_ptr) && (*right == c))right--;
|
|
|
|
|
if(right != start)
|
|
|
|
@ -2896,8 +2896,8 @@ KviStr & KviStr::stripSpace()
|
|
|
|
|
// abcd 0
|
|
|
|
|
// ^ ^
|
|
|
|
|
// left right
|
|
|
|
|
register char *left=m_ptr;
|
|
|
|
|
register char *right=m_ptr+m_len-1;
|
|
|
|
|
char *left=m_ptr;
|
|
|
|
|
char *right=m_ptr+m_len-1;
|
|
|
|
|
// skip initial spaces
|
|
|
|
|
while((*left == ' ') || (*left == '\t'))left++;
|
|
|
|
|
if(*left){
|
|
|
|
@ -2921,7 +2921,7 @@ KviStr & KviStr::stripSpace()
|
|
|
|
|
|
|
|
|
|
bool KviStr::isNum() const
|
|
|
|
|
{
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
while(isspace(*p))p++;
|
|
|
|
|
if(*p=='-')p++;
|
|
|
|
|
if(!isdigit(*p))return false;
|
|
|
|
@ -2932,7 +2932,7 @@ bool KviStr::isNum() const
|
|
|
|
|
|
|
|
|
|
bool KviStr::isUnsignedNum() const
|
|
|
|
|
{
|
|
|
|
|
register char *p=m_ptr;
|
|
|
|
|
char *p=m_ptr;
|
|
|
|
|
while(isspace(*p))p++;
|
|
|
|
|
if(!isdigit(*p))return false;
|
|
|
|
|
while(isdigit(*p))p++;
|
|
|
|
@ -2948,7 +2948,7 @@ KviStr & KviStr::emptyString()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool KviStr::ext_contains(register const char * data,const char * item,bool caseS)
|
|
|
|
|
bool KviStr::ext_contains(const char * data,const char * item,bool caseS)
|
|
|
|
|
{
|
|
|
|
|
if(item && data)
|
|
|
|
|
{
|
|
|
|
|