From cf28e8d57762bb250fabfc7d0cdf91d94ee421bf Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sat, 10 Jan 2015 15:24:00 -0800 Subject: [PATCH] Remove unused pnUtStr functions. --- Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp | 148 ------------------ Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h | 15 -- 2 files changed, 163 deletions(-) diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp index b4f6167c..3e2a8f1a 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp @@ -98,17 +98,6 @@ static chartype * IStrDup (const chartype str[]) { return buffer; } -//=========================================================================== -template -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 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 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 -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 -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 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(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(source, match); -} - //=========================================================================== unsigned StrLen (const char str[]) { return IStrLen(str); diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h index 6867e257..2102c4e1 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h +++ b/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);