Browse Source

Remove unused pnUtStr functions.

Darryl Pogue 10 years ago
parent
commit
cf28e8d577
  1. 148
      Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp
  2. 15
      Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h

148
Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp

@ -98,17 +98,6 @@ static chartype * IStrDup (const chartype str[]) {
return buffer;
}
//===========================================================================
template<class chartype>
static chartype * IStrDupLen (const chartype str[], unsigned chars) {
unsigned len = IStrLen(str) + 1;
if (len > chars)
len = chars;
chartype * buffer = (chartype *)malloc(len * sizeof(chartype));
IStrCopy(buffer, str, len);
return buffer;
}
//===========================================================================
template<class chartype, class findchartype>
static chartype * IStrChr (chartype * str, findchartype ch, unsigned chars) {
@ -120,60 +109,6 @@ static chartype * IStrChr (chartype * str, findchartype ch, unsigned chars) {
return nil;
}
//===========================================================================
static inline bool ICharUnicodeToUtf8 (char ** dest, const wchar_t * source[], unsigned destChars) {
unsigned ch = *(*source)++;
bool result = false;
if (ch < 0x80) {
if (destChars >= 1) {
*(*dest)++ = (char)ch;
result = true;
}
}
else if (ch < 0x800) {
if (destChars >= 2) {
*(*dest)++ = (char)(0xc0 | (ch >> 6));
*(*dest)++ = (char)(0x80 | (ch & 0x3f));
result = true;
}
}
else {
if (destChars >= 3) {
*(*dest)++ = (char)(0xe0 | (ch >> 12));
*(*dest)++ = (char)(0x80 | ((ch >> 6) & 0x3f));
*(*dest)++ = (char)(0x80 | (ch & 0x3f));
result = true;
}
}
return result;
}
//===========================================================================
static inline void ICharUtf8ToUnicode (wchar_t ** dest, const char * source[]) {
unsigned result, remaining;
if ((**source & 0xf0) == 0xe0) {
result = *(*source)++ & 0x0f;
remaining = 2;
}
else if ((**source & 0xe0) == 0xc0) {
result = *(*source)++ & 0x1f;
remaining = 1;
}
else if ((**source & 0x80) == 0x00) {
result = *(*source)++;
remaining = 0;
}
else {
// unsupported code sequence (>0xffff)
++(*source);
return;
}
for (; remaining-- && *source; ++*source)
if ((**source & 0xc0) == 0x80)
result = (result << 6) | (**source & 0x3f);
*(*dest)++ = (wchar_t)result;
}
//===========================================================================
template<typename chartype>
static unsigned IStrPrintfValidate (chartype * dest, unsigned count, int result) {
@ -214,39 +149,6 @@ static int IStrCmpI (const chartype str1[], const chartype str2[], unsigned char
return 0;
}
//===========================================================================
template<class chartype>
static void IStrPack (chartype * dest, const chartype source[], unsigned chars) {
while ((chars > 1) && *dest) {
--chars;
++dest;
}
while ((chars > 1) && ((*dest = *source++) != 0)) {
--chars;
++dest;
}
if (chars)
*dest = 0;
}
//===========================================================================
template<class chartype>
static chartype * IStrStr (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 && *s1 == *s2)
s1++, s2++;
if (!*s2)
return curr;
}
return nil;
}
//===========================================================================
template<class chartype>
static uint32_t IStrHash (const chartype str[], unsigned chars) {
@ -374,26 +276,6 @@ wchar_t * StrDup (const wchar_t str[]) {
return IStrDup(str);
}
//===========================================================================
char * StrDupLen (const char str[], unsigned chars) {
return IStrDupLen(str, chars);
}
//===========================================================================
wchar_t * StrDupLen (const wchar_t str[], unsigned chars) {
return IStrDupLen(str, chars);
}
//===========================================================================
unsigned StrBytes (const char str[]) { // includes space for terminator
return (IStrLen(str) + 1) * sizeof(str[0]);
}
//===========================================================================
unsigned StrBytes (const wchar_t str[]) { // includes space for terminator
return (IStrLen(str) + 1) * sizeof(str[0]);
}
//===========================================================================
char * StrChr (char * str, char ch, unsigned chars) {
return IStrChr(str, ch, chars);
@ -474,36 +356,6 @@ void StrCopy (wchar_t * dest, const wchar_t source[], unsigned chars) {
IStrCopy(dest, source, chars);
}
//===========================================================================
void StrPack (char * dest, const char source[], unsigned chars) {
IStrPack(dest, source, chars);
}
//===========================================================================
void StrPack (wchar_t * dest, const wchar_t source[], unsigned chars) {
IStrPack(dest, source, chars);
}
//===========================================================================
char * StrStr (char * source, const char match[]) {
return IStrStr(source, match);
}
//===========================================================================
const char * StrStr (const char source[], const char match[]) {
return IStrStr<const char>(source, match);
}
//===========================================================================
wchar_t * StrStr (wchar_t * source, const wchar_t match[]) {
return IStrStr(source, match);
}
//===========================================================================
const wchar_t * StrStr (const wchar_t source[], const wchar_t match[]) {
return IStrStr<const wchar_t>(source, match);
}
//===========================================================================
unsigned StrLen (const char str[]) {
return IStrLen(str);

15
Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h

@ -57,7 +57,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifdef _INC_SHLWAPI
# undef StrChr
# undef StrDup
# undef StrStr
#endif // _INC_SHLWAPI
/*****************************************************************************
@ -69,9 +68,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
inline char CharLowerFast (char ch) { return ((ch >= 'A') && (ch <= 'Z')) ? (char )(ch + 'a' - 'A') : ch; }
inline wchar_t CharLowerFast (wchar_t ch) { return ((ch >= L'A') && (ch <= L'Z')) ? (wchar_t)(ch + L'a' - L'A') : ch; }
unsigned StrBytes (const char str[]); // includes space for terminator
unsigned StrBytes (const wchar_t str[]); // includes space for terminator
char * StrChr (char * str, char ch, unsigned chars = (unsigned)-1);
wchar_t * StrChr (wchar_t * str, wchar_t ch, unsigned chars = (unsigned)-1);
const char * StrChr (const char str[], char ch, unsigned chars = (unsigned)-1);
@ -89,26 +85,15 @@ unsigned StrLen (const wchar_t str[]);
char * StrDup (const char str[]);
wchar_t * StrDup (const wchar_t str[]);
char * StrDupLen (const char str[], unsigned chars);
wchar_t * StrDupLen (const wchar_t str[], unsigned chars);
int StrCmp (const char str1[], const char str2[], unsigned chars = (unsigned)-1);
int StrCmp (const wchar_t str1[], const wchar_t str2[], unsigned chars = (unsigned)-1);
int StrCmpI (const char str1[], const char str2[], unsigned chars = (unsigned)-1);
int StrCmpI (const wchar_t str1[], const wchar_t str2[], unsigned chars = (unsigned)-1);
char * StrStr (char * source, const char match[]);
const char * StrStr (const char source[], const char match[]);
wchar_t * StrStr (wchar_t * source, const wchar_t match[]);
const wchar_t * StrStr (const wchar_t source[], const wchar_t match[]);
void StrCopy (char * dest, const char source[], unsigned chars);
void StrCopy (wchar_t * dest, const wchar_t source[], unsigned chars);
void StrPack (char * dest, const char source[], unsigned chars);
void StrPack (wchar_t * dest, const wchar_t source[], unsigned chars);
float StrToFloat (const char source[], const char ** endptr);
float StrToFloat (const wchar_t source[], const wchar_t ** endptr);

Loading…
Cancel
Save