|
|
@ -120,18 +120,6 @@ static chartype * IStrChr (chartype * str, findchartype ch, unsigned chars) { |
|
|
|
return nil; |
|
|
|
return nil; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
template<class chartype, class findchartype> |
|
|
|
|
|
|
|
static chartype * IStrChrR (chartype * str, findchartype ch) { |
|
|
|
|
|
|
|
chartype * start = str; |
|
|
|
|
|
|
|
for (; *str; ++str) |
|
|
|
|
|
|
|
NULL_STMT; |
|
|
|
|
|
|
|
while (str-- > start) |
|
|
|
|
|
|
|
if (*str == ch) |
|
|
|
|
|
|
|
return str; |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
static inline bool ICharUnicodeToUtf8 (char ** dest, const wchar_t * source[], unsigned destChars) { |
|
|
|
static inline bool ICharUnicodeToUtf8 (char ** dest, const wchar_t * source[], unsigned destChars) { |
|
|
|
unsigned ch = *(*source)++; |
|
|
|
unsigned ch = *(*source)++; |
|
|
@ -226,20 +214,6 @@ static int IStrCmpI (const chartype str1[], const chartype str2[], unsigned char |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
// returns StrLen(dest)
|
|
|
|
|
|
|
|
template<class chartype> |
|
|
|
|
|
|
|
static unsigned IStrCopyLen (chartype * dest, const chartype source[], unsigned chars) { |
|
|
|
|
|
|
|
chartype * const start = dest; |
|
|
|
|
|
|
|
while ((chars > 1) && ((*dest = *source++) != 0)) { |
|
|
|
|
|
|
|
--chars; |
|
|
|
|
|
|
|
++dest; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (chars) |
|
|
|
|
|
|
|
*dest = 0; |
|
|
|
|
|
|
|
return dest - start; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
template<class chartype> |
|
|
|
template<class chartype> |
|
|
|
static void IStrPack (chartype * dest, const chartype source[], unsigned chars) { |
|
|
|
static void IStrPack (chartype * dest, const chartype source[], unsigned chars) { |
|
|
@ -273,46 +247,6 @@ static chartype * IStrStr (chartype source[], const chartype match[]) { |
|
|
|
return nil; |
|
|
|
return nil; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
template<class chartype> |
|
|
|
|
|
|
|
static chartype * IStrStrI (chartype source[], const chartype match[]) { |
|
|
|
|
|
|
|
if (!*match) |
|
|
|
|
|
|
|
return source; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (chartype * curr = source; *curr; ++curr) { |
|
|
|
|
|
|
|
chartype * s1 = curr; |
|
|
|
|
|
|
|
const chartype * s2 = match; |
|
|
|
|
|
|
|
while (*s1 && *s2 && (CharLowerFast(*s1) == CharLowerFast(*s2))) |
|
|
|
|
|
|
|
s1++, s2++; |
|
|
|
|
|
|
|
if (!*s2) |
|
|
|
|
|
|
|
return curr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
template<class chartype> |
|
|
|
|
|
|
|
static void IStrLower (chartype * dest, unsigned chars) { |
|
|
|
|
|
|
|
while ((chars > 1) && ((*dest = CharLowerFast(*dest)) != 0)) { |
|
|
|
|
|
|
|
--chars; |
|
|
|
|
|
|
|
++dest; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
template<class chartype> |
|
|
|
|
|
|
|
static void IStrLower (chartype * dest, const chartype source[], unsigned chars) { |
|
|
|
|
|
|
|
while ((chars > 1) && ((*dest = CharLowerFast(*source)) != 0)) { |
|
|
|
|
|
|
|
--chars; |
|
|
|
|
|
|
|
++dest; |
|
|
|
|
|
|
|
++source; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (chars) |
|
|
|
|
|
|
|
*dest = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
template<class chartype> |
|
|
|
template<class chartype> |
|
|
|
static uint32_t IStrHash (const chartype str[], unsigned chars) { |
|
|
|
static uint32_t IStrHash (const chartype str[], unsigned chars) { |
|
|
@ -496,26 +430,6 @@ const wchar_t * StrChr (const wchar_t str[], wchar_t ch, unsigned chars) { |
|
|
|
return IStrChr(str, ch, chars); |
|
|
|
return IStrChr(str, ch, chars); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
char * StrChrR (char * str, char ch) { |
|
|
|
|
|
|
|
return IStrChrR(str, ch); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
wchar_t * StrChrR (wchar_t * str, wchar_t ch) { |
|
|
|
|
|
|
|
return IStrChrR(str, ch); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
const char * StrChrR (const char str[], char ch) { |
|
|
|
|
|
|
|
return IStrChrR(str, ch); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
const wchar_t * StrChrR (const wchar_t str[], wchar_t ch) { |
|
|
|
|
|
|
|
return IStrChrR(str, ch); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
unsigned StrPrintf (char * dest, unsigned count, const char format[], ...) { |
|
|
|
unsigned StrPrintf (char * dest, unsigned count, const char format[], ...) { |
|
|
|
va_list argList; |
|
|
|
va_list argList; |
|
|
@ -576,16 +490,6 @@ void StrCopy (wchar_t * dest, const wchar_t source[], unsigned chars) { |
|
|
|
IStrCopy(dest, source, chars); |
|
|
|
IStrCopy(dest, source, chars); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
unsigned StrCopyLen (char * dest, const char source[], unsigned chars) { |
|
|
|
|
|
|
|
return IStrCopyLen(dest, source, chars); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
unsigned StrCopyLen (wchar_t * dest, const wchar_t source[], unsigned chars) { |
|
|
|
|
|
|
|
return IStrCopyLen(dest, source, chars); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
void StrPack (char * dest, const char source[], unsigned chars) { |
|
|
|
void StrPack (char * dest, const char source[], unsigned chars) { |
|
|
|
IStrPack(dest, source, chars); |
|
|
|
IStrPack(dest, source, chars); |
|
|
@ -616,26 +520,6 @@ const wchar_t * StrStr (const wchar_t source[], const wchar_t match[]) { |
|
|
|
return IStrStr<const wchar_t>(source, match); |
|
|
|
return IStrStr<const wchar_t>(source, match); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
char * StrStrI (char * source, const char match[]) { |
|
|
|
|
|
|
|
return IStrStrI(source, match); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
const char * StrStrI (const char source[], const char match[]) { |
|
|
|
|
|
|
|
return IStrStrI<const char>(source, match); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
wchar_t * StrStrI (wchar_t * source, const wchar_t match[]) { |
|
|
|
|
|
|
|
return IStrStrI(source, match); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
const wchar_t * StrStrI (const wchar_t source[], const wchar_t match[]) { |
|
|
|
|
|
|
|
return IStrStrI<const wchar_t>(source, match); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
unsigned StrLen (const char str[]) { |
|
|
|
unsigned StrLen (const char str[]) { |
|
|
|
return IStrLen(str); |
|
|
|
return IStrLen(str); |
|
|
@ -647,29 +531,6 @@ unsigned StrLen (const wchar_t str[]) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
unsigned StrUnicodeToUtf8 (char * dest, const wchar_t source[], unsigned destChars) { |
|
|
|
|
|
|
|
char * destCurr = dest; |
|
|
|
|
|
|
|
char * destTerm = dest + destChars; |
|
|
|
|
|
|
|
while (*source && (destCurr + 1 < destTerm)) |
|
|
|
|
|
|
|
if (!ICharUnicodeToUtf8(&destCurr, &source, destTerm - destCurr - 1)) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
if (destCurr < destTerm) |
|
|
|
|
|
|
|
*destCurr = 0; |
|
|
|
|
|
|
|
return destCurr - dest; // dest chars not including null terminator
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
unsigned StrUtf8ToUnicode (wchar_t * dest, const char source[], unsigned destChars) { |
|
|
|
|
|
|
|
wchar_t * destCurr = dest; |
|
|
|
|
|
|
|
wchar_t * destTerm = dest + destChars; |
|
|
|
|
|
|
|
while (*source && (destCurr + 1 < destTerm)) |
|
|
|
|
|
|
|
ICharUtf8ToUnicode(&destCurr, &source); |
|
|
|
|
|
|
|
if (destCurr < destTerm) |
|
|
|
|
|
|
|
*destCurr = 0; |
|
|
|
|
|
|
|
return destCurr - dest; // dest chars not including null terminator
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
float StrToFloat (const char source[], const char ** endptr) { |
|
|
|
float StrToFloat (const char source[], const char ** endptr) { |
|
|
|
return (float) strtod(source, const_cast<char **>(endptr)); |
|
|
|
return (float) strtod(source, const_cast<char **>(endptr)); |
|
|
|
} |
|
|
|
} |
|
|
@ -710,26 +571,6 @@ unsigned StrToUnsigned (const wchar_t source[], const wchar_t ** endptr, int rad |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
void StrLower (char * dest, unsigned chars) { |
|
|
|
|
|
|
|
IStrLower(dest, chars); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void StrLower (wchar_t * dest, unsigned chars) { |
|
|
|
|
|
|
|
IStrLower(dest, chars); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void StrLower (char * dest, const char source[], unsigned chars) { |
|
|
|
|
|
|
|
IStrLower(dest, source, chars); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void StrLower (wchar_t * dest, const wchar_t source[], unsigned chars) { |
|
|
|
|
|
|
|
IStrLower(dest, source, chars); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
uint32_t StrHash (const char str[], unsigned chars) { |
|
|
|
uint32_t StrHash (const char str[], unsigned chars) { |
|
|
|
return IStrHash(str, chars); |
|
|
|
return IStrHash(str, chars); |
|
|
|
} |
|
|
|
} |
|
|
|