From 5a78793da86ef201f3820f00e10eb4a5ec68855b Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Thu, 14 Feb 2002 23:23:55 +0000 Subject: [PATCH] re-land fix for bug 107575, moving nsStr static routines into a private class/namespace git-svn-id: svn://10.0.0.236/trunk@114538 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/string/obsolete/MANIFEST | 1 + mozilla/string/obsolete/Makefile.in | 1 + mozilla/string/obsolete/makefile.win | 1 + mozilla/string/obsolete/nsStr.cpp | 117 +++++----- mozilla/string/obsolete/nsStr.h | 227 +------------------ mozilla/string/obsolete/nsStrPrivate.h | 1 + mozilla/string/obsolete/nsStrShared.h | 8 + mozilla/string/obsolete/nsString.cpp | 147 ++++++------ mozilla/string/obsolete/nsString2.cpp | 149 ++++++------ mozilla/xpcom/string/obsolete/MANIFEST | 1 + mozilla/xpcom/string/obsolete/Makefile.in | 1 + mozilla/xpcom/string/obsolete/makefile.win | 1 + mozilla/xpcom/string/obsolete/nsStr.cpp | 117 +++++----- mozilla/xpcom/string/obsolete/nsStr.h | 227 +------------------ mozilla/xpcom/string/obsolete/nsStrPrivate.h | 1 + mozilla/xpcom/string/obsolete/nsStrShared.h | 8 + mozilla/xpcom/string/obsolete/nsString.cpp | 147 ++++++------ mozilla/xpcom/string/obsolete/nsString2.cpp | 149 ++++++------ 18 files changed, 444 insertions(+), 860 deletions(-) create mode 100644 mozilla/string/obsolete/nsStrShared.h create mode 100644 mozilla/xpcom/string/obsolete/nsStrShared.h diff --git a/mozilla/string/obsolete/MANIFEST b/mozilla/string/obsolete/MANIFEST index fdd6d7a70ad..9392a90cf90 100644 --- a/mozilla/string/obsolete/MANIFEST +++ b/mozilla/string/obsolete/MANIFEST @@ -22,5 +22,6 @@ nsStr.h +nsStrShared.h nsString.h nsString2.h diff --git a/mozilla/string/obsolete/Makefile.in b/mozilla/string/obsolete/Makefile.in index 7baa1bf7043..330ea73bc09 100644 --- a/mozilla/string/obsolete/Makefile.in +++ b/mozilla/string/obsolete/Makefile.in @@ -42,6 +42,7 @@ CPPSRCS = \ EXPORTS = \ nsStr.h \ + nsStrShared.h \ nsString.h \ nsString2.h \ $(NULL) diff --git a/mozilla/string/obsolete/makefile.win b/mozilla/string/obsolete/makefile.win index fe8dc9abd82..fbd3956e446 100644 --- a/mozilla/string/obsolete/makefile.win +++ b/mozilla/string/obsolete/makefile.win @@ -30,6 +30,7 @@ REQUIRES = unicharutil \ EXPORTS = \ nsStr.h \ + nsStrShared.h \ nsString.h \ nsString2.h \ $(NULL) diff --git a/mozilla/string/obsolete/nsStr.cpp b/mozilla/string/obsolete/nsStr.cpp index 4acc9ab610d..27b8715df4d 100644 --- a/mozilla/string/obsolete/nsStr.cpp +++ b/mozilla/string/obsolete/nsStr.cpp @@ -37,6 +37,7 @@ * * ***** END LICENSE BLOCK ***** */ +#include "nsStrPrivate.h" #include "nsStr.h" #include "bufferRoutines.h" #include //only used for printf @@ -71,7 +72,7 @@ static PRBool gStringAcquiredMemory = PR_TRUE; * @param * @return */ -void nsStr::Initialize(nsStr& aDest,eCharSize aCharSize) { +void nsStrPrivate::Initialize(nsStr& aDest,eCharSize aCharSize) { aDest.mStr=(char*)gCommonEmptyBuffer; aDest.mLength=0; aDest.SetInternalCapacity(0); @@ -85,7 +86,7 @@ void nsStr::Initialize(nsStr& aDest,eCharSize aCharSize) { * @param * @return */ -void nsStr::Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 aLength,eCharSize aCharSize,PRBool aOwnsBuffer){ +void nsStrPrivate::Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 aLength,eCharSize aCharSize,PRBool aOwnsBuffer){ aDest.mStr=(aCString) ? aCString : (char*)gCommonEmptyBuffer; aDest.mLength=aLength; aDest.SetInternalCapacity(aCapacity); @@ -99,7 +100,7 @@ void nsStr::Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 a * @param * @return */ -void nsStr::Destroy(nsStr& aDest) { +void nsStrPrivate::Destroy(nsStr& aDest) { if((aDest.mStr) && (aDest.mStr!=(char*)gCommonEmptyBuffer)) { Free(aDest); } @@ -113,7 +114,7 @@ void nsStr::Destroy(nsStr& aDest) { * @param aNewLength -- new capacity of string in charSize units * @return void */ -PRBool nsStr::EnsureCapacity(nsStr& aString,PRUint32 aNewLength) { +PRBool nsStrPrivate::EnsureCapacity(nsStr& aString,PRUint32 aNewLength) { PRBool result=PR_TRUE; if(aNewLength>aString.GetCapacity()) { result=Realloc(aString,aNewLength); @@ -130,11 +131,11 @@ PRBool nsStr::EnsureCapacity(nsStr& aString,PRUint32 aNewLength) { * @param aNewLength -- new capacity of string in charSize units * @return void */ -PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) { +PRBool nsStrPrivate::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) { PRBool result=PR_TRUE; if(aNewLength>aDest.GetCapacity()) { nsStr theTempStr; - nsStr::Initialize(theTempStr,eCharSize(aDest.GetCharSize())); + nsStrPrivate::Initialize(theTempStr,eCharSize(aDest.GetCharSize())); // the new strategy is, allocate exact size, double on grows if ( aDest.GetCapacity() ) { @@ -167,7 +168,7 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) { * @param aSource is where chars are copied from * @param aCount is the number of chars copied from aSource */ -void nsStr::StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){ +void nsStrPrivate::StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){ if(&aDest!=&aSource){ StrTruncate(aDest,0); StrAppend(aDest,aSource,anOffset,aCount); @@ -182,7 +183,7 @@ void nsStr::StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt3 * @param aSource is where char are copied from * @aCount is the number of bytes to be copied */ -void nsStr::StrAppend(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){ +void nsStrPrivate::StrAppend(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){ if(anOffset0) && aSet){ PRInt32 theIndex=-1; @@ -542,7 +543,7 @@ void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool a * @param * @return */ -void nsStr::CompressSet1(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){ +void nsStrPrivate::CompressSet1(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){ NS_ASSERTION(aDest.GetCharSize() == eOneByte, "Must be 1 byte"); Trim(aDest,aSet,aEliminateLeading,aEliminateTrailing); @@ -551,7 +552,7 @@ void nsStr::CompressSet1(nsStr& aDest,const char* aSet,PRBool aEliminateLeading, NSSTR_SEEN(aDest); } -void nsStr::CompressSet2(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){ +void nsStrPrivate::CompressSet2(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){ NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 bytes"); Trim(aDest,aSet,aEliminateLeading,aEliminateTrailing); @@ -567,7 +568,7 @@ void nsStr::CompressSet2(nsStr& aDest,const char* aSet,PRBool aEliminateLeading, * @param * @return */ -void nsStr::StripChars1(nsStr& aDest,const char* aSet){ +void nsStrPrivate::StripChars1(nsStr& aDest,const char* aSet){ NS_ASSERTION(aDest.GetCharSize() == eOneByte, "Must be 1 byte"); if((0aSource=1 */ -PRInt32 nsStr::StrCompare1To1(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { +PRInt32 nsStrPrivate::StrCompare1To1(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { NS_ASSERTION(aDest.GetCharSize() == eOneByte, "Must be 1 byte"); NS_ASSERTION(aSource.GetCharSize() == eOneByte, "Must be 1 byte"); if (aCount) { @@ -1151,7 +1152,7 @@ PRInt32 nsStr::StrCompare1To1(const nsStr& aDest,const nsStr& aSource,PRInt32 aC return 0; } -PRInt32 nsStr::StrCompare1To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { +PRInt32 nsStrPrivate::StrCompare1To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { NS_ASSERTION(aDest.GetCharSize() == eOneByte, "Must be 1 byte"); NS_ASSERTION(aSource.GetCharSize() == eTwoByte, "Must be 2 byte"); @@ -1165,7 +1166,7 @@ PRInt32 nsStr::StrCompare1To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aC return 0; } -PRInt32 nsStr::StrCompare2To1(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { +PRInt32 nsStrPrivate::StrCompare2To1(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 byte"); NS_ASSERTION(aSource.GetCharSize() == eOneByte, "Must be 1 byte"); @@ -1179,7 +1180,7 @@ PRInt32 nsStr::StrCompare2To1(const nsStr& aDest,const nsStr& aSource,PRInt32 aC return 0; } -PRInt32 nsStr::StrCompare2To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { +PRInt32 nsStrPrivate::StrCompare2To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 byte"); NS_ASSERTION(aSource.GetCharSize() == eTwoByte, "Must be 2 byte"); @@ -1201,7 +1202,7 @@ PRInt32 nsStr::StrCompare2To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aC * @param aDestOffset is the offset within aDest where source should be copied * @return error code */ -void nsStr::Overwrite(nsStr& aDest,const nsStr& aSource,PRInt32 aDestOffset) { +void nsStrPrivate::Overwrite(nsStr& aDest,const nsStr& aSource,PRInt32 aDestOffset) { if(aDest.mLength && aSource.mLength) { if((aDest.mLength-aDestOffset)>=aSource.mLength) { //if you're here, then both dest and source have valid lengths @@ -1213,7 +1214,7 @@ void nsStr::Overwrite(nsStr& aDest,const nsStr& aSource,PRInt32 aDestOffset) { //---------------------------------------------------------------------------------------- // allocate the given bytes, not including the null terminator -PRBool nsStr::Alloc(nsStr& aDest,PRUint32 aCount) { +PRBool nsStrPrivate::Alloc(nsStr& aDest,PRUint32 aCount) { // the new strategy is, allocate exact size, double on grows aDest.SetInternalCapacity(aCount); @@ -1229,7 +1230,7 @@ PRBool nsStr::Alloc(nsStr& aDest,PRUint32 aCount) { return (aDest.mStr != nsnull); } -PRBool nsStr::Free(nsStr& aDest){ +PRBool nsStrPrivate::Free(nsStr& aDest){ if(aDest.mStr){ if(aDest.GetOwnsBuffer()){ nsMemory::Free(aDest.mStr); @@ -1241,7 +1242,7 @@ PRBool nsStr::Free(nsStr& aDest){ return PR_FALSE; } -PRBool nsStr::Realloc(nsStr& aDest,PRUint32 aCount){ +PRBool nsStrPrivate::Realloc(nsStr& aDest,PRUint32 aCount){ nsStr temp; memcpy(&temp,&aDest,sizeof(aDest)); @@ -1263,7 +1264,7 @@ PRBool nsStr::Realloc(nsStr& aDest,PRUint32 aCount){ * @update gess 10/11/99 * @return memory error (usually returns PR_TRUE) */ -PRBool nsStr::DidAcquireMemory(void) { +PRBool nsStrPrivate::DidAcquireMemory(void) { return gStringAcquiredMemory; } #endif @@ -1330,7 +1331,7 @@ CBufDescriptor::CBufDescriptor(const PRUnichar* aString,PRBool aStackBased,PRUin //---------------------------------------------------------------------------------------- PRUint32 -nsStr::HashCode(const nsStr& aDest) +nsStrPrivate::HashCode(const nsStr& aDest) { if (aDest.GetCharSize() == eTwoByte) return nsCRT::HashCode(aDest.mUStr); @@ -1347,7 +1348,7 @@ nsStr::HashCode(const nsStr& aDest) #endif void -nsStr::Print(const nsStr& aDest, FILE* out, PRBool truncate) +nsStrPrivate::Print(const nsStr& aDest, FILE* out, PRBool truncate) { PRInt32 printLen = (PRInt32)aDest.mLength; @@ -1378,9 +1379,9 @@ PRBool gNoStringInfo = PR_FALSE; nsStringInfo::nsStringInfo(nsStr& str) : mCount(0) { - nsStr::Initialize(mStr, str.GetCharSize()); - nsStr::StrAssign(mStr, str, 0, -1); -// nsStr::Print(mStr, stdout); + nsStrPrivate::Initialize(mStr, str.GetCharSize()); + nsStrPrivate::StrAssign(mStr, str, 0, -1); +// nsStrPrivate::Print(mStr, stdout); // fputc('\n', stdout); } @@ -1388,7 +1389,7 @@ PR_EXTERN(PRHashNumber) nsStr_Hash(const void* key) { nsStr* str = (nsStr*)key; - return nsStr::HashCode(*str); + return nsStrPrivate::HashCode(*str); } nsStringInfo* @@ -1446,7 +1447,7 @@ nsStringInfo::ReportEntry(PLHashEntry *he, PRIntn i, void *arg) FILE* out = (FILE*)arg; fprintf(out, "%d ==> (%d) ", entry->mCount, entry->mStr.mLength); - nsStr::Print(entry->mStr, out, PR_TRUE); + nsStrPrivate::Print(entry->mStr, out, PR_TRUE); fputc('\n', out); return HT_ENUMERATE_NEXT; } diff --git a/mozilla/string/obsolete/nsStr.h b/mozilla/string/obsolete/nsStr.h index 968d6e80f3f..06c0c071c91 100644 --- a/mozilla/string/obsolete/nsStr.h +++ b/mozilla/string/obsolete/nsStr.h @@ -213,10 +213,9 @@ #include #include #include "plhash.h" +#include "nsStrShared.h" //---------------------------------------------------------------------------------------- - -enum eCharSize {eOneByte=0,eTwoByte=1}; #define kDefaultCharSize eTwoByte #define kRadix10 (10) #define kRadix16 (16) @@ -267,225 +266,6 @@ protected: MOZ_COUNT_DTOR(nsStr); } - /** - * This method initializes an nsStr for use - * - * @update gess 01/04/99 - * @param aString is the nsStr to be initialized - * @param aCharSize tells us the requested char size (1 or 2 bytes) - */ - static void Initialize(nsStr& aDest,eCharSize aCharSize); - - /** - * This method initializes an nsStr for use - * - * @update gess 01/04/99 - * @param aString is the nsStr to be initialized - * @param aCharSize tells us the requested char size (1 or 2 bytes) - */ - static void Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 aLength,eCharSize aCharSize,PRBool aOwnsBuffer); - /** - * This method destroys the given nsStr, and *MAY* - * deallocate it's memory depending on the setting - * of the internal mOwnsBUffer flag. - * - * @update gess 01/04/99 - * @param aString is the nsStr to be manipulated - */ - static void Destroy(nsStr& aDest); - - /** - * These methods are where memory allocation/reallocation occur. - * - * @update gess 01/04/99 - * @param aString is the nsStr to be manipulated - * @return - */ - static PRBool EnsureCapacity(nsStr& aString,PRUint32 aNewLength); - static PRBool GrowCapacity(nsStr& aString,PRUint32 aNewLength); - - /** - * These methods are used to append content to the given nsStr - * - * @update gess 01/04/99 - * @param aDest is the nsStr to be appended to - * @param aSource is the buffer to be copied from - * @param anOffset tells us where in source to start copying - * @param aCount tells us the (max) # of chars to copy - */ - static void StrAppend(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount); - - /** - * These methods are used to assign contents of a source string to dest string - * - * @update gess 01/04/99 - * @param aDest is the nsStr to be appended to - * @param aSource is the buffer to be copied from - * @param anOffset tells us where in source to start copying - * @param aCount tells us the (max) # of chars to copy - */ - static void StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount); - - /** - * These methods are used to insert content from source string to the dest nsStr - * - * @update gess 01/04/99 - * @param aDest is the nsStr to be appended to - * @param aDestOffset tells us where in dest to start insertion - * @param aSource is the buffer to be copied from - * @param aSrcOffset tells us where in source to start copying - * @param aCount tells us the (max) # of chars to insert - */ - static void StrInsert1into1( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount); - static void StrInsert1into2( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount); - static void StrInsert2into1( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount); - static void StrInsert2into2( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount); - - - /** - * Helper routines for StrInsert1into1, etc - */ - static PRInt32 GetSegmentLength(const nsStr& aSource, - PRUint32 aSrcOffset, PRInt32 aCount); - static void AppendForInsert(nsStr& aDest, PRUint32 aDestOffset, const nsStr& aSource, PRUint32 aSrcOffset, PRInt32 theLength); - - /** - * This method deletes chars from the given str. - * The given allocator may choose to resize the str as well. - * - * @update gess 01/04/99 - * @param aDest is the nsStr to be deleted from - * @param aDestOffset tells us where in dest to start deleting - * @param aCount tells us the (max) # of chars to delete - */ - static void Delete1(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount); - static void Delete2(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount); - - /** - * helper routines for Delete1, Delete2 - */ - static PRInt32 GetDeleteLength(const nsStr& aDest, PRUint32 aDestOffset, PRUint32 aCount); - - /** - * This method is used to truncate the given string. - * The given allocator may choose to resize the str as well (but it's not likely). - * - * @update gess 01/04/99 - * @param aDest is the nsStr to be appended to - * @param aDestOffset tells us where in dest to start insertion - * @param aSource is the buffer to be copied from - * @param aSrcOffset tells us where in source to start copying - */ - static void StrTruncate(nsStr& aDest,PRUint32 aDestOffset); - - /** - * This method trims chars (given in aSet) from the edges of given buffer - * - * @update gess 01/04/99 - * @param aDest is the buffer to be manipulated - * @param aSet tells us which chars to remove from given buffer - * @param aEliminateLeading tells us whether to strip chars from the start of the buffer - * @param aEliminateTrailing tells us whether to strip chars from the start of the buffer - */ - static void Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing); - - /** - * This method compresses duplicate runs of a given char from the given buffer - * - * @update gess 01/04/99 - * @param aDest is the buffer to be manipulated - * @param aSet tells us which chars to compress from given buffer - * @param aChar is the replacement char - * @param aEliminateLeading tells us whether to strip chars from the start of the buffer - * @param aEliminateTrailing tells us whether to strip chars from the start of the buffer - */ - static void CompressSet1(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing); - static void CompressSet2(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing); - - /** - * This method removes all occurances of chars in given set from aDest - * - * @update gess 01/04/99 - * @param aDest is the buffer to be manipulated - * @param aSet tells us which chars to compress from given buffer - * @param aChar is the replacement char - * @param aEliminateLeading tells us whether to strip chars from the start of the buffer - * @param aEliminateTrailing tells us whether to strip chars from the start of the buffer - */ - static void StripChars1(nsStr& aDest,const char* aSet); - static void StripChars2(nsStr& aDest,const char* aSet); - - /** - * This method compares the data bewteen two nsStr's - * - * @update gess 01/04/99 - * @param aStr1 is the first buffer to be compared - * @param aStr2 is the 2nd buffer to be compared - * @param aCount is the number of chars to compare - * @param aIgnorecase tells us whether to use a case-sensitive comparison - * @return -1,0,1 depending on <,==,> - */ - static PRInt32 StrCompare1To1(const nsStr& aDest,const nsStr& aSource, - PRInt32 aCount,PRBool aIgnoreCase); - static PRInt32 StrCompare1To2(const nsStr& aDest, const nsStr& aSource, - PRInt32 aCount, PRBool aIgnoreCase); - static PRInt32 StrCompare2To1(const nsStr& aDest, const nsStr& aSource, - PRInt32 aCount, PRBool aIgnoreCase); - static PRInt32 StrCompare2To2(const nsStr& aDest, const nsStr& aSource, - PRInt32 aCount, PRBool aIgnoreCase); - - /** - * These methods scan the given string for 1 or more chars in a given direction - * - * @update gess 01/04/99 - * @param aDest is the nsStr to be searched to - * @param aSource (or aChar) is the substr we're looking to find - * @param aIgnoreCase tells us whether to search in a case-sensitive manner - * @param anOffset tells us where in the dest string to start searching - * @return the index of the source (substr) in dest, or -1 (kNotFound) if not found. - */ - static PRInt32 FindSubstr1in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - static PRInt32 FindSubstr1in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - static PRInt32 FindSubstr2in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - static PRInt32 FindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - - static PRInt32 FindChar1(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount); - static PRInt32 FindChar2(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount); - - static PRInt32 FindCharInSet1(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset); - static PRInt32 FindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRInt32 anOffset); - - static PRInt32 RFindSubstr1in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - static PRInt32 RFindSubstr2in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - static PRInt32 RFindSubstr1in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - static PRInt32 RFindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - - static PRInt32 RFindChar1(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount); - static PRInt32 RFindChar2(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount); - - static PRInt32 RFindCharInSet1(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset); - static PRInt32 RFindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRInt32 anOffset); - - static void Overwrite(nsStr& aDest,const nsStr& aSource,PRInt32 anOffset); - -#ifdef NS_STR_STATS - static PRBool DidAcquireMemory(void); -#endif - - /** - * Returns a hash code for the string for use in a PLHashTable. - */ - static PRUint32 HashCode(const nsStr& aDest); - -#ifdef NS_STR_STATS - /** - * Prints an nsStr. If truncate is true, the string is only printed up to - * the first newline. (Note: The current implementation doesn't handle - * non-ascii unicode characters.) - */ - static void Print(const nsStr& aDest, FILE* out, PRBool truncate = PR_FALSE); -#endif - protected: union { char* mStr; @@ -528,16 +308,13 @@ private: (aOwnsBuffer ? 1 : 0) << NSSTR_OWNSBUFFER_BIT); } - static PRBool Alloc(nsStr& aString,PRUint32 aCount); - static PRBool Realloc(nsStr& aString,PRUint32 aCount); - static PRBool Free(nsStr& aString); - public: friend NS_COM char* ToNewUTF8String( const nsAString& aSource ); friend inline void AddNullTerminator(nsStr& aDest); friend inline PRUnichar GetCharAt(const nsStr& aDest,PRUint32 anIndex); + friend class nsStrPrivate; friend class nsString; friend class nsCString; }; diff --git a/mozilla/string/obsolete/nsStrPrivate.h b/mozilla/string/obsolete/nsStrPrivate.h index 762aedec0fb..0d8d4dea37a 100644 --- a/mozilla/string/obsolete/nsStrPrivate.h +++ b/mozilla/string/obsolete/nsStrPrivate.h @@ -41,6 +41,7 @@ #define __nsStrPrivate_h #include "nscore.h" +#include "nsStrShared.h" struct nsStr; enum eCharSize; diff --git a/mozilla/string/obsolete/nsStrShared.h b/mozilla/string/obsolete/nsStrShared.h new file mode 100644 index 00000000000..251c9bfd915 --- /dev/null +++ b/mozilla/string/obsolete/nsStrShared.h @@ -0,0 +1,8 @@ + +#ifndef __nsStrShared_h +#define __nsStrShared_h + + +enum eCharSize {eOneByte=0,eTwoByte=1}; + +#endif diff --git a/mozilla/string/obsolete/nsString.cpp b/mozilla/string/obsolete/nsString.cpp index 1be4da8c3fd..bab9e69e501 100644 --- a/mozilla/string/obsolete/nsString.cpp +++ b/mozilla/string/obsolete/nsString.cpp @@ -41,6 +41,7 @@ #include #include #include +#include "nsStrPrivate.h" #include "nsString.h" #include "nsReadableUtils.h" #include "nsDebug.h" @@ -66,11 +67,11 @@ nsCString::GetFlatBufferHandle() const * Default constructor. */ nsCString::nsCString() { - Initialize(*this,eOneByte); + nsStrPrivate::Initialize(*this,eOneByte); } nsCString::nsCString(const char* aCString) { - Initialize(*this,eOneByte); + nsStrPrivate::Initialize(*this,eOneByte); Assign(aCString); } @@ -81,7 +82,7 @@ nsCString::nsCString(const char* aCString) { * @param aLength tells us how many chars to copy from given CString */ nsCString::nsCString(const char* aCString,PRInt32 aLength) { - Initialize(*this,eOneByte); + nsStrPrivate::Initialize(*this,eOneByte); Assign(aCString,aLength); } @@ -91,15 +92,15 @@ nsCString::nsCString(const char* aCString,PRInt32 aLength) { * @param reference to another nsCString */ nsCString::nsCString(const nsCString& aString) { - Initialize(*this,aString.GetCharSize()); - StrAssign(*this,aString,0,aString.mLength); + nsStrPrivate::Initialize(*this,aString.GetCharSize()); + nsStrPrivate::StrAssign(*this,aString,0,aString.mLength); } /** * Destructor */ nsCString::~nsCString() { - Destroy(*this); + nsStrPrivate::Destroy(*this); } const char* nsCString::GetReadableFragment( nsReadableFragment& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const { @@ -133,7 +134,7 @@ char* nsCString::GetWritableFragment( nsWritableFragment& aFragment, nsFra } nsCString::nsCString( const nsACString& aReadable ) { - Initialize(*this,eOneByte); + nsStrPrivate::Initialize(*this,eOneByte); Assign(aReadable); } @@ -158,7 +159,7 @@ void nsCString::SetLength(PRUint32 anIndex) { // |SetCapacity| normally doesn't guarantee the use we are putting it to here (see its interface comment in nsAWritableString.h), // we can only use it since our local implementation, |nsCString::SetCapacity|, is known to do what we want - nsStr::StrTruncate(*this,anIndex); + nsStrPrivate::StrTruncate(*this,anIndex); } @@ -174,13 +175,13 @@ nsCString::SetCapacity( PRUint32 aNewCapacity ) if ( aNewCapacity ) { if( aNewCapacity > GetCapacity() ) - GrowCapacity(*this,aNewCapacity); + nsStrPrivate::GrowCapacity(*this,aNewCapacity); AddNullTerminator(*this); } else { - nsStr::Destroy(*this); - nsStr::Initialize(*this, eOneByte); + nsStrPrivate::Destroy(*this); + nsStrPrivate::Initialize(*this, eOneByte); } } @@ -248,7 +249,7 @@ nsCString::StripChar(PRUnichar aChar,PRInt32 anOffset){ */ void nsCString::StripChars(const char* aSet){ - nsStr::StripChars1(*this,aSet); + nsStrPrivate::StripChars1(*this,aSet); } @@ -353,19 +354,19 @@ nsCString::ReplaceSubstring(const nsCString& aTarget,const nsCString& aNewValue) } else { PRInt32 theIndex=0; - while(kNotFound!=(theIndex=nsStr::FindSubstr1in1(*this,aTarget,PR_FALSE,theIndex,mLength))) { + while(kNotFound!=(theIndex=nsStrPrivate::FindSubstr1in1(*this,aTarget,PR_FALSE,theIndex,mLength))) { if(aNewValue.mLength 0 ) { temp.mLength = aLength; - StrAppend(*this, temp, 0, aLength); + nsStrPrivate::StrAppend(*this, temp, 0, aLength); } } @@ -788,7 +789,7 @@ void nsCString::AppendWithConversion(const nsString& aString,PRInt32 aCount) { else aCount=MinInt(aCount,aString.mLength); if(0::length(aPtr); // We don't know the capacity, so we'll just have to assume // capacity = length. - nsStr::Initialize(*this, aPtr, aLength, aLength, eOneByte, PR_TRUE); + nsStrPrivate::Initialize(*this, aPtr, aLength, aLength, eOneByte, PR_TRUE); } /********************************************************************** @@ -840,10 +841,10 @@ PRInt32 nsCString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset PRInt32 result=kNotFound; if(aCString) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength = nsCRT::strlen(aCString); temp.mStr=(char*)aCString; - result=nsStr::FindSubstr1in1(*this,temp,aIgnoreCase,anOffset,aCount); + result=nsStrPrivate::FindSubstr1in1(*this,temp,aIgnoreCase,anOffset,aCount); } return result; } @@ -864,10 +865,10 @@ PRInt32 nsCString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOf PRInt32 result=kNotFound; if(aString) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength = nsCRT::strlen(aString); temp.mUStr=(PRUnichar*)aString; - result=nsStr::FindSubstr2in1(*this,temp,aIgnoreCase,anOffset,aCount); + result=nsStrPrivate::FindSubstr2in1(*this,temp,aIgnoreCase,anOffset,aCount); } return result; } @@ -883,12 +884,12 @@ PRInt32 nsCString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOf * @return offset in string, or -1 (kNotFound) */ PRInt32 nsCString::Find(const nsCString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::FindSubstr1in1(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::FindSubstr1in1(*this,aString,aIgnoreCase,anOffset,aCount); return result; } PRInt32 nsCString::Find(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::FindSubstr1in2(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::FindSubstr1in2(*this,aString,aIgnoreCase,anOffset,aCount); return result; } @@ -904,7 +905,7 @@ PRInt32 nsCString::Find(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOff * @return index in aDest where member of aSet occurs, or -1 if not found */ PRInt32 nsCString::FindChar(PRUnichar aChar,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::FindChar1(*this,aChar,anOffset,aCount); + PRInt32 result=nsStrPrivate::FindChar1(*this,aChar,anOffset,aCount); return result; } @@ -923,10 +924,10 @@ PRInt32 nsCString::FindCharInSet(const char* aCStringSet,PRInt32 anOffset) const PRInt32 result=kNotFound; if(aCStringSet) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aCStringSet); temp.mStr=(char*)aCStringSet; - result=nsStr::FindCharInSet1(*this,temp,PR_FALSE,anOffset); + result=nsStrPrivate::FindCharInSet1(*this,temp,PR_FALSE,anOffset); } return result; } @@ -946,10 +947,10 @@ PRInt32 nsCString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c PRInt32 result=kNotFound; if(aStringSet) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength=nsCRT::strlen(aStringSet); temp.mStr=(char*)aStringSet; - result=nsStr::FindCharInSet2(*this,temp,anOffset); + result=nsStrPrivate::FindCharInSet2(*this,temp,anOffset); } return result; } @@ -964,12 +965,12 @@ PRInt32 nsCString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c * @return */ PRInt32 nsCString::FindCharInSet(const nsCString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::FindCharInSet1(*this,aSet,PR_FALSE,anOffset); + PRInt32 result=nsStrPrivate::FindCharInSet1(*this,aSet,PR_FALSE,anOffset); return result; } PRInt32 nsCString::FindCharInSet(const nsString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::FindCharInSet2(*this,aSet,anOffset); + PRInt32 result=nsStrPrivate::FindCharInSet2(*this,aSet,anOffset); return result; } @@ -984,12 +985,12 @@ PRInt32 nsCString::FindCharInSet(const nsString& aSet,PRInt32 anOffset) const{ * @return offset in string, or -1 (kNotFound) */ PRInt32 nsCString::RFind(const nsCString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::RFindSubstr1in1(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::RFindSubstr1in1(*this,aString,aIgnoreCase,anOffset,aCount); return result; } PRInt32 nsCString::RFind(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::RFindSubstr2in1(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::RFindSubstr2in1(*this,aString,aIgnoreCase,anOffset,aCount); return result; } @@ -1010,10 +1011,10 @@ PRInt32 nsCString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset PRInt32 result=kNotFound; if(aString) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aString); temp.mStr=(char*)aString; - result=nsStr::RFindSubstr1in1(*this,temp,aIgnoreCase,anOffset,aCount); + result=nsStrPrivate::RFindSubstr1in1(*this,temp,aIgnoreCase,anOffset,aCount); } return result; } @@ -1029,7 +1030,7 @@ PRInt32 nsCString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset * @return index in aDest where member of aSet occurs, or -1 if not found */ PRInt32 nsCString::RFindChar(PRUnichar aChar,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::RFindChar1(*this,aChar,anOffset,aCount); + PRInt32 result=nsStrPrivate::RFindChar1(*this,aChar,anOffset,aCount); return result; } @@ -1047,10 +1048,10 @@ PRInt32 nsCString::RFindCharInSet(const char* aCStringSet,PRInt32 anOffset) cons PRInt32 result=kNotFound; if(aCStringSet) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aCStringSet); temp.mStr=(char*)aCStringSet; - result=nsStr::RFindCharInSet1(*this,temp,PR_FALSE,anOffset); + result=nsStrPrivate::RFindCharInSet1(*this,temp,PR_FALSE,anOffset); } return result; } @@ -1069,10 +1070,10 @@ PRInt32 nsCString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) PRInt32 result=kNotFound; if(aStringSet) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength=nsCRT::strlen(aStringSet); temp.mUStr=(PRUnichar*)aStringSet; - result=nsStr::RFindCharInSet2(*this,temp,anOffset); + result=nsStrPrivate::RFindCharInSet2(*this,temp,anOffset); } return result; } @@ -1087,12 +1088,12 @@ PRInt32 nsCString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) * @return offset of found char, or -1 (kNotFound) */ PRInt32 nsCString::RFindCharInSet(const nsCString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::RFindCharInSet1(*this,aSet,PR_FALSE,anOffset); + PRInt32 result=nsStrPrivate::RFindCharInSet1(*this,aSet,PR_FALSE,anOffset); return result; } PRInt32 nsCString::RFindCharInSet(const nsString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::RFindCharInSet2(*this,aSet,anOffset); + PRInt32 result=nsStrPrivate::RFindCharInSet2(*this,aSet,anOffset); return result; } @@ -1115,10 +1116,10 @@ PRInt32 nsCString::CompareWithConversion(const PRUnichar* aString,PRBool aIgnore if(aString) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength=nsCRT::strlen(aString); temp.mUStr=(PRUnichar*)aString; - return nsStr::StrCompare1To2(*this,temp,aCount,aIgnoreCase); + return nsStrPrivate::StrCompare1To2(*this,temp,aCount,aIgnoreCase); } return 0; } @@ -1136,10 +1137,10 @@ PRInt32 nsCString::CompareWithConversion(const char *aCString,PRBool aIgnoreCase if(aCString) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aCString); temp.mStr=(char*)aCString; - return nsStr::StrCompare1To1(*this,temp,aCount,aIgnoreCase); + return nsStrPrivate::StrCompare1To1(*this,temp,aCount,aIgnoreCase); } return 0; } @@ -1315,25 +1316,25 @@ NS_LossyConvertUCS2toASCII::NS_LossyConvertUCS2toASCII( const nsAString& aString * */ nsCAutoString::nsCAutoString() : nsCString(){ - Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); AddNullTerminator(*this); } nsCAutoString::nsCAutoString( const nsCString& aString ) : nsCString(){ - Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); AddNullTerminator(*this); Append(aString); } nsCAutoString::nsCAutoString( const nsACString& aString ) : nsCString(){ - Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); AddNullTerminator(*this); Append(aString); } nsCAutoString::nsCAutoString(const char* aCString) : nsCString() { - Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); AddNullTerminator(*this); Append(aCString); } @@ -1343,7 +1344,7 @@ nsCAutoString::nsCAutoString(const char* aCString) : nsCString() { * @param aCString is a ptr to a 1-byte cstr */ nsCAutoString::nsCAutoString(const char* aCString,PRInt32 aLength) : nsCString() { - Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); AddNullTerminator(*this); Append(aCString,aLength); } @@ -1354,10 +1355,10 @@ nsCAutoString::nsCAutoString(const char* aCString,PRInt32 aLength) : nsCString() */ nsCAutoString::nsCAutoString(const CBufDescriptor& aBuffer) : nsCString() { if(!aBuffer.mBuffer) { - Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); } else { - Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased); + nsStrPrivate::Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased); } if(!aBuffer.mIsConst) AddNullTerminator(*this); //this isn't really needed, but it guarantees that folks don't pass string constants. diff --git a/mozilla/string/obsolete/nsString2.cpp b/mozilla/string/obsolete/nsString2.cpp index 10ef2e510b5..f9d0a9a3f67 100644 --- a/mozilla/string/obsolete/nsString2.cpp +++ b/mozilla/string/obsolete/nsString2.cpp @@ -40,6 +40,7 @@ #include #include #include +#include "nsStrPrivate.h" #include "nsString.h" #include "nsReadableUtils.h" #include "nsDebug.h" @@ -65,11 +66,11 @@ nsString::GetFlatBufferHandle() const * Default constructor. */ nsString::nsString() { - Initialize(*this,eTwoByte); + nsStrPrivate::Initialize(*this,eTwoByte); } nsString::nsString(const PRUnichar* aString) { - Initialize(*this,eTwoByte); + nsStrPrivate::Initialize(*this,eTwoByte); Assign(aString); } @@ -80,7 +81,7 @@ nsString::nsString(const PRUnichar* aString) { * @param aLength tells us how many chars to copy from given aString */ nsString::nsString(const PRUnichar* aString,PRInt32 aCount) { - Initialize(*this,eTwoByte); + nsStrPrivate::Initialize(*this,eTwoByte); Assign(aString,aCount); } @@ -90,16 +91,16 @@ nsString::nsString(const PRUnichar* aString,PRInt32 aCount) { * @param reference to another nsString */ nsString::nsString(const nsString& aString) { - Initialize(*this,eTwoByte); - StrAssign(*this,aString,0,aString.mLength); + nsStrPrivate::Initialize(*this,eTwoByte); + nsStrPrivate::StrAssign(*this,aString,0,aString.mLength); } /** * Destructor - * Make sure we call nsStr::Destroy. + * Make sure we call nsStrPrivate::Destroy. */ nsString::~nsString() { - nsStr::Destroy(*this); + nsStrPrivate::Destroy(*this); } const PRUnichar* nsString::GetReadableFragment( nsReadableFragment& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const { @@ -140,15 +141,15 @@ nsString::do_AppendFromElement( PRUnichar inChar ) buf[0] = inChar; nsStr temp; - nsStr::Initialize(temp, eTwoByte); + nsStrPrivate::Initialize(temp, eTwoByte); temp.mUStr = buf; temp.mLength = 1; - StrAppend(*this, temp, 0, 1); + nsStrPrivate::StrAppend(*this, temp, 0, 1); } nsString::nsString( const nsAString& aReadable ) { - Initialize(*this,eTwoByte); + nsStrPrivate::Initialize(*this,eTwoByte); Assign(aReadable); } @@ -172,7 +173,7 @@ void nsString::SetLength(PRUint32 anIndex) { SetCapacity(anIndex); // |SetCapacity| normally doesn't guarantee the use we are putting it to here (see its interface comment in nsAWritableString.h), // we can only use it since our local implementation, |nsString::SetCapacity|, is known to do what we want - nsStr::StrTruncate(*this,anIndex); + nsStrPrivate::StrTruncate(*this,anIndex); } @@ -188,13 +189,13 @@ nsString::SetCapacity( PRUint32 aNewCapacity ) if ( aNewCapacity ) { if( aNewCapacity > GetCapacity() ) - GrowCapacity(*this, aNewCapacity); + nsStrPrivate::GrowCapacity(*this, aNewCapacity); AddNullTerminator(*this); } else { - nsStr::Destroy(*this); - nsStr::Initialize(*this, eTwoByte); + nsStrPrivate::Destroy(*this); + nsStrPrivate::Initialize(*this, eTwoByte); } } @@ -299,7 +300,7 @@ nsString::StripChar(PRUnichar aChar,PRInt32 anOffset){ */ void nsString::StripChars(const char* aSet){ - nsStr::StripChars2(*this,aSet); + nsStrPrivate::StripChars2(*this,aSet); } @@ -409,19 +410,19 @@ nsString::ReplaceSubstring(const nsString& aTarget,const nsString& aNewValue){ } else { PRInt32 theIndex=0; - while(kNotFound!=(theIndex=nsStr::FindSubstr2in2(*this,aTarget,PR_FALSE,theIndex,mLength))) { + while(kNotFound!=(theIndex=nsStrPrivate::FindSubstr2in2(*this,aTarget,PR_FALSE,theIndex,mLength))) { if(aNewValue.mLength::length(aPtr); // We don't know the capacity, so we'll just have to assume // capacity = length. - nsStr::Initialize(*this, (char*)aPtr, aLength, aLength, eTwoByte, PR_TRUE); + nsStrPrivate::Initialize(*this, (char*)aPtr, aLength, aLength, eTwoByte, PR_TRUE); } @@ -883,10 +884,10 @@ PRInt32 nsString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset, PRInt32 result=kNotFound; if(aCString) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aCString); temp.mStr=(char*)aCString; - result=nsStr::FindSubstr1in2(*this,temp,aIgnoreCase,anOffset,aCount); + result=nsStrPrivate::FindSubstr1in2(*this,temp,aIgnoreCase,anOffset,aCount); } return result; } @@ -907,10 +908,10 @@ PRInt32 nsString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOff PRInt32 result=kNotFound; if(aString) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength=nsCRT::strlen(aString); temp.mUStr=(PRUnichar*)aString; - result=nsStr::FindSubstr2in2(*this,temp,aIgnoreCase,anOffset,aCount); + result=nsStrPrivate::FindSubstr2in2(*this,temp,aIgnoreCase,anOffset,aCount); } return result; } @@ -926,7 +927,7 @@ PRInt32 nsString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOff * @return offset in string, or -1 (kNotFound) */ PRInt32 nsString::Find(const nsCString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::FindSubstr1in2(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::FindSubstr1in2(*this,aString,aIgnoreCase,anOffset,aCount); return result; } @@ -941,7 +942,7 @@ PRInt32 nsString::Find(const nsCString& aString,PRBool aIgnoreCase,PRInt32 anOff * @return offset in string, or -1 (kNotFound) */ PRInt32 nsString::Find(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::FindSubstr2in2(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::FindSubstr2in2(*this,aString,aIgnoreCase,anOffset,aCount); return result; } @@ -960,10 +961,10 @@ PRInt32 nsString::FindCharInSet(const char* aCStringSet,PRInt32 anOffset) const{ PRInt32 result=kNotFound; if(aCStringSet) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aCStringSet); temp.mStr=(char*)aCStringSet; - result=nsStr::FindCharInSet1(*this,temp,PR_FALSE,anOffset); + result=nsStrPrivate::FindCharInSet1(*this,temp,PR_FALSE,anOffset); } return result; } @@ -983,10 +984,10 @@ PRInt32 nsString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) co PRInt32 result=kNotFound; if(aStringSet) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength=nsCRT::strlen(aStringSet); temp.mStr=(char*)aStringSet; - result=nsStr::FindCharInSet2(*this,temp,anOffset); + result=nsStrPrivate::FindCharInSet2(*this,temp,anOffset); } return result; } @@ -1001,12 +1002,12 @@ PRInt32 nsString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) co * @return */ PRInt32 nsString::FindCharInSet(const nsString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::FindCharInSet2(*this,aSet,anOffset); + PRInt32 result=nsStrPrivate::FindCharInSet2(*this,aSet,anOffset); return result; } PRInt32 nsString::FindCharInSet(const nsCString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::FindCharInSet1(*this,aSet,PR_FALSE,anOffset); + PRInt32 result=nsStrPrivate::FindCharInSet1(*this,aSet,PR_FALSE,anOffset); return result; } @@ -1022,7 +1023,7 @@ PRInt32 nsString::FindCharInSet(const nsCString& aSet,PRInt32 anOffset) const{ * @return offset in string, or -1 (kNotFound) */ PRInt32 nsString::RFind(const nsCString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::RFindSubstr1in2(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::RFindSubstr1in2(*this,aString,aIgnoreCase,anOffset,aCount); return result; } @@ -1037,7 +1038,7 @@ PRInt32 nsString::RFind(const nsCString& aString,PRBool aIgnoreCase,PRInt32 anOf * @return offset in string, or -1 (kNotFound) */ PRInt32 nsString::RFind(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::RFindSubstr2in2(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::RFindSubstr2in2(*this,aString,aIgnoreCase,anOffset,aCount); return result; } @@ -1057,10 +1058,10 @@ PRInt32 nsString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset, PRInt32 result=kNotFound; if(aString) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aString); temp.mStr=(char*)aString; - result=nsStr::RFindSubstr1in2(*this,temp,aIgnoreCase,anOffset,aCount); + result=nsStrPrivate::RFindSubstr1in2(*this,temp,aIgnoreCase,anOffset,aCount); } return result; } @@ -1075,7 +1076,7 @@ PRInt32 nsString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset, * @return offset of found char, or -1 (kNotFound) */ PRInt32 nsString::RFindChar(PRUnichar aChar,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::RFindChar2(*this,aChar,anOffset,aCount); + PRInt32 result=nsStrPrivate::RFindChar2(*this,aChar,anOffset,aCount); return result; } @@ -1093,10 +1094,10 @@ PRInt32 nsString::RFindCharInSet(const char* aCStringSet,PRInt32 anOffset) const PRInt32 result=kNotFound; if(aCStringSet) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aCStringSet); temp.mStr=(char*)aCStringSet; - result=nsStr::RFindCharInSet1(*this,temp,PR_FALSE,anOffset); + result=nsStrPrivate::RFindCharInSet1(*this,temp,PR_FALSE,anOffset); } return result; } @@ -1112,12 +1113,12 @@ PRInt32 nsString::RFindCharInSet(const char* aCStringSet,PRInt32 anOffset) const * @return offset of found char, or -1 (kNotFound) */ PRInt32 nsString::RFindCharInSet(const nsString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::RFindCharInSet2(*this,aSet,anOffset); + PRInt32 result=nsStrPrivate::RFindCharInSet2(*this,aSet,anOffset); return result; } PRInt32 nsString::RFindCharInSet(const nsCString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::RFindCharInSet1(*this,aSet,PR_FALSE,anOffset); + PRInt32 result=nsStrPrivate::RFindCharInSet1(*this,aSet,PR_FALSE,anOffset); return result; } @@ -1137,10 +1138,10 @@ PRInt32 nsString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c PRInt32 result=kNotFound; if(aStringSet) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength=nsCRT::strlen(aStringSet); temp.mUStr=(PRUnichar*)aStringSet; - result=nsStr::RFindCharInSet2(*this,temp,anOffset); + result=nsStrPrivate::RFindCharInSet2(*this,temp,anOffset); } return result; } @@ -1163,12 +1164,12 @@ PRInt32 nsString::CompareWithConversion(const char *aCString,PRBool aIgnoreCase, if(aCString) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength= (0>eTwoByte)-1,0,eTwoByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); AddNullTerminator(*this); } nsAutoString::nsAutoString(const PRUnichar* aString) : nsString() { - Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); AddNullTerminator(*this); Append(aString); } @@ -1397,7 +1398,7 @@ nsAutoString::nsAutoString(const PRUnichar* aString) : nsString() { * @param aLength tells us how many chars to copy from aString */ nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString() { - Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); AddNullTerminator(*this); Append(aString,aLength); } @@ -1405,7 +1406,7 @@ nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString( nsAutoString::nsAutoString( const nsString& aString ) : nsString() { - Initialize(*this, mBuffer, (sizeof(mBuffer)>>eTwoByte)-1, 0, eTwoByte, PR_FALSE); + nsStrPrivate::Initialize(*this, mBuffer, (sizeof(mBuffer)>>eTwoByte)-1, 0, eTwoByte, PR_FALSE); AddNullTerminator(*this); Append(aString); } @@ -1413,7 +1414,7 @@ nsAutoString::nsAutoString( const nsString& aString ) nsAutoString::nsAutoString( const nsAString& aString ) : nsString() { - Initialize(*this, mBuffer, (sizeof(mBuffer)>>eTwoByte)-1, 0, eTwoByte, PR_FALSE); + nsStrPrivate::Initialize(*this, mBuffer, (sizeof(mBuffer)>>eTwoByte)-1, 0, eTwoByte, PR_FALSE); AddNullTerminator(*this); Append(aString); } @@ -1426,10 +1427,10 @@ nsAutoString::nsAutoString( const nsAString& aString ) */ nsAutoString::nsAutoString(const CBufDescriptor& aBuffer) : nsString() { if(!aBuffer.mBuffer) { - Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); } else { - Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased); + nsStrPrivate::Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased); } if(!aBuffer.mIsConst) AddNullTerminator(*this); @@ -1544,7 +1545,7 @@ NS_ConvertUTF8toUCS2::Init( const nsACString& aCString ) * Default copy constructor */ nsAutoString::nsAutoString(const nsAutoString& aString) : nsString() { - Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); AddNullTerminator(*this); Append(aString); } @@ -1555,7 +1556,7 @@ nsAutoString::nsAutoString(const nsAutoString& aString) : nsString() { * @param */ nsAutoString::nsAutoString(PRUnichar aChar) : nsString(){ - Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); AddNullTerminator(*this); Append(aChar); } diff --git a/mozilla/xpcom/string/obsolete/MANIFEST b/mozilla/xpcom/string/obsolete/MANIFEST index fdd6d7a70ad..9392a90cf90 100644 --- a/mozilla/xpcom/string/obsolete/MANIFEST +++ b/mozilla/xpcom/string/obsolete/MANIFEST @@ -22,5 +22,6 @@ nsStr.h +nsStrShared.h nsString.h nsString2.h diff --git a/mozilla/xpcom/string/obsolete/Makefile.in b/mozilla/xpcom/string/obsolete/Makefile.in index 7baa1bf7043..330ea73bc09 100644 --- a/mozilla/xpcom/string/obsolete/Makefile.in +++ b/mozilla/xpcom/string/obsolete/Makefile.in @@ -42,6 +42,7 @@ CPPSRCS = \ EXPORTS = \ nsStr.h \ + nsStrShared.h \ nsString.h \ nsString2.h \ $(NULL) diff --git a/mozilla/xpcom/string/obsolete/makefile.win b/mozilla/xpcom/string/obsolete/makefile.win index fe8dc9abd82..fbd3956e446 100644 --- a/mozilla/xpcom/string/obsolete/makefile.win +++ b/mozilla/xpcom/string/obsolete/makefile.win @@ -30,6 +30,7 @@ REQUIRES = unicharutil \ EXPORTS = \ nsStr.h \ + nsStrShared.h \ nsString.h \ nsString2.h \ $(NULL) diff --git a/mozilla/xpcom/string/obsolete/nsStr.cpp b/mozilla/xpcom/string/obsolete/nsStr.cpp index 4acc9ab610d..27b8715df4d 100644 --- a/mozilla/xpcom/string/obsolete/nsStr.cpp +++ b/mozilla/xpcom/string/obsolete/nsStr.cpp @@ -37,6 +37,7 @@ * * ***** END LICENSE BLOCK ***** */ +#include "nsStrPrivate.h" #include "nsStr.h" #include "bufferRoutines.h" #include //only used for printf @@ -71,7 +72,7 @@ static PRBool gStringAcquiredMemory = PR_TRUE; * @param * @return */ -void nsStr::Initialize(nsStr& aDest,eCharSize aCharSize) { +void nsStrPrivate::Initialize(nsStr& aDest,eCharSize aCharSize) { aDest.mStr=(char*)gCommonEmptyBuffer; aDest.mLength=0; aDest.SetInternalCapacity(0); @@ -85,7 +86,7 @@ void nsStr::Initialize(nsStr& aDest,eCharSize aCharSize) { * @param * @return */ -void nsStr::Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 aLength,eCharSize aCharSize,PRBool aOwnsBuffer){ +void nsStrPrivate::Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 aLength,eCharSize aCharSize,PRBool aOwnsBuffer){ aDest.mStr=(aCString) ? aCString : (char*)gCommonEmptyBuffer; aDest.mLength=aLength; aDest.SetInternalCapacity(aCapacity); @@ -99,7 +100,7 @@ void nsStr::Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 a * @param * @return */ -void nsStr::Destroy(nsStr& aDest) { +void nsStrPrivate::Destroy(nsStr& aDest) { if((aDest.mStr) && (aDest.mStr!=(char*)gCommonEmptyBuffer)) { Free(aDest); } @@ -113,7 +114,7 @@ void nsStr::Destroy(nsStr& aDest) { * @param aNewLength -- new capacity of string in charSize units * @return void */ -PRBool nsStr::EnsureCapacity(nsStr& aString,PRUint32 aNewLength) { +PRBool nsStrPrivate::EnsureCapacity(nsStr& aString,PRUint32 aNewLength) { PRBool result=PR_TRUE; if(aNewLength>aString.GetCapacity()) { result=Realloc(aString,aNewLength); @@ -130,11 +131,11 @@ PRBool nsStr::EnsureCapacity(nsStr& aString,PRUint32 aNewLength) { * @param aNewLength -- new capacity of string in charSize units * @return void */ -PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) { +PRBool nsStrPrivate::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) { PRBool result=PR_TRUE; if(aNewLength>aDest.GetCapacity()) { nsStr theTempStr; - nsStr::Initialize(theTempStr,eCharSize(aDest.GetCharSize())); + nsStrPrivate::Initialize(theTempStr,eCharSize(aDest.GetCharSize())); // the new strategy is, allocate exact size, double on grows if ( aDest.GetCapacity() ) { @@ -167,7 +168,7 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) { * @param aSource is where chars are copied from * @param aCount is the number of chars copied from aSource */ -void nsStr::StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){ +void nsStrPrivate::StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){ if(&aDest!=&aSource){ StrTruncate(aDest,0); StrAppend(aDest,aSource,anOffset,aCount); @@ -182,7 +183,7 @@ void nsStr::StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt3 * @param aSource is where char are copied from * @aCount is the number of bytes to be copied */ -void nsStr::StrAppend(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){ +void nsStrPrivate::StrAppend(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){ if(anOffset0) && aSet){ PRInt32 theIndex=-1; @@ -542,7 +543,7 @@ void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool a * @param * @return */ -void nsStr::CompressSet1(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){ +void nsStrPrivate::CompressSet1(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){ NS_ASSERTION(aDest.GetCharSize() == eOneByte, "Must be 1 byte"); Trim(aDest,aSet,aEliminateLeading,aEliminateTrailing); @@ -551,7 +552,7 @@ void nsStr::CompressSet1(nsStr& aDest,const char* aSet,PRBool aEliminateLeading, NSSTR_SEEN(aDest); } -void nsStr::CompressSet2(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){ +void nsStrPrivate::CompressSet2(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){ NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 bytes"); Trim(aDest,aSet,aEliminateLeading,aEliminateTrailing); @@ -567,7 +568,7 @@ void nsStr::CompressSet2(nsStr& aDest,const char* aSet,PRBool aEliminateLeading, * @param * @return */ -void nsStr::StripChars1(nsStr& aDest,const char* aSet){ +void nsStrPrivate::StripChars1(nsStr& aDest,const char* aSet){ NS_ASSERTION(aDest.GetCharSize() == eOneByte, "Must be 1 byte"); if((0aSource=1 */ -PRInt32 nsStr::StrCompare1To1(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { +PRInt32 nsStrPrivate::StrCompare1To1(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { NS_ASSERTION(aDest.GetCharSize() == eOneByte, "Must be 1 byte"); NS_ASSERTION(aSource.GetCharSize() == eOneByte, "Must be 1 byte"); if (aCount) { @@ -1151,7 +1152,7 @@ PRInt32 nsStr::StrCompare1To1(const nsStr& aDest,const nsStr& aSource,PRInt32 aC return 0; } -PRInt32 nsStr::StrCompare1To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { +PRInt32 nsStrPrivate::StrCompare1To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { NS_ASSERTION(aDest.GetCharSize() == eOneByte, "Must be 1 byte"); NS_ASSERTION(aSource.GetCharSize() == eTwoByte, "Must be 2 byte"); @@ -1165,7 +1166,7 @@ PRInt32 nsStr::StrCompare1To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aC return 0; } -PRInt32 nsStr::StrCompare2To1(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { +PRInt32 nsStrPrivate::StrCompare2To1(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 byte"); NS_ASSERTION(aSource.GetCharSize() == eOneByte, "Must be 1 byte"); @@ -1179,7 +1180,7 @@ PRInt32 nsStr::StrCompare2To1(const nsStr& aDest,const nsStr& aSource,PRInt32 aC return 0; } -PRInt32 nsStr::StrCompare2To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { +PRInt32 nsStrPrivate::StrCompare2To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) { NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 byte"); NS_ASSERTION(aSource.GetCharSize() == eTwoByte, "Must be 2 byte"); @@ -1201,7 +1202,7 @@ PRInt32 nsStr::StrCompare2To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aC * @param aDestOffset is the offset within aDest where source should be copied * @return error code */ -void nsStr::Overwrite(nsStr& aDest,const nsStr& aSource,PRInt32 aDestOffset) { +void nsStrPrivate::Overwrite(nsStr& aDest,const nsStr& aSource,PRInt32 aDestOffset) { if(aDest.mLength && aSource.mLength) { if((aDest.mLength-aDestOffset)>=aSource.mLength) { //if you're here, then both dest and source have valid lengths @@ -1213,7 +1214,7 @@ void nsStr::Overwrite(nsStr& aDest,const nsStr& aSource,PRInt32 aDestOffset) { //---------------------------------------------------------------------------------------- // allocate the given bytes, not including the null terminator -PRBool nsStr::Alloc(nsStr& aDest,PRUint32 aCount) { +PRBool nsStrPrivate::Alloc(nsStr& aDest,PRUint32 aCount) { // the new strategy is, allocate exact size, double on grows aDest.SetInternalCapacity(aCount); @@ -1229,7 +1230,7 @@ PRBool nsStr::Alloc(nsStr& aDest,PRUint32 aCount) { return (aDest.mStr != nsnull); } -PRBool nsStr::Free(nsStr& aDest){ +PRBool nsStrPrivate::Free(nsStr& aDest){ if(aDest.mStr){ if(aDest.GetOwnsBuffer()){ nsMemory::Free(aDest.mStr); @@ -1241,7 +1242,7 @@ PRBool nsStr::Free(nsStr& aDest){ return PR_FALSE; } -PRBool nsStr::Realloc(nsStr& aDest,PRUint32 aCount){ +PRBool nsStrPrivate::Realloc(nsStr& aDest,PRUint32 aCount){ nsStr temp; memcpy(&temp,&aDest,sizeof(aDest)); @@ -1263,7 +1264,7 @@ PRBool nsStr::Realloc(nsStr& aDest,PRUint32 aCount){ * @update gess 10/11/99 * @return memory error (usually returns PR_TRUE) */ -PRBool nsStr::DidAcquireMemory(void) { +PRBool nsStrPrivate::DidAcquireMemory(void) { return gStringAcquiredMemory; } #endif @@ -1330,7 +1331,7 @@ CBufDescriptor::CBufDescriptor(const PRUnichar* aString,PRBool aStackBased,PRUin //---------------------------------------------------------------------------------------- PRUint32 -nsStr::HashCode(const nsStr& aDest) +nsStrPrivate::HashCode(const nsStr& aDest) { if (aDest.GetCharSize() == eTwoByte) return nsCRT::HashCode(aDest.mUStr); @@ -1347,7 +1348,7 @@ nsStr::HashCode(const nsStr& aDest) #endif void -nsStr::Print(const nsStr& aDest, FILE* out, PRBool truncate) +nsStrPrivate::Print(const nsStr& aDest, FILE* out, PRBool truncate) { PRInt32 printLen = (PRInt32)aDest.mLength; @@ -1378,9 +1379,9 @@ PRBool gNoStringInfo = PR_FALSE; nsStringInfo::nsStringInfo(nsStr& str) : mCount(0) { - nsStr::Initialize(mStr, str.GetCharSize()); - nsStr::StrAssign(mStr, str, 0, -1); -// nsStr::Print(mStr, stdout); + nsStrPrivate::Initialize(mStr, str.GetCharSize()); + nsStrPrivate::StrAssign(mStr, str, 0, -1); +// nsStrPrivate::Print(mStr, stdout); // fputc('\n', stdout); } @@ -1388,7 +1389,7 @@ PR_EXTERN(PRHashNumber) nsStr_Hash(const void* key) { nsStr* str = (nsStr*)key; - return nsStr::HashCode(*str); + return nsStrPrivate::HashCode(*str); } nsStringInfo* @@ -1446,7 +1447,7 @@ nsStringInfo::ReportEntry(PLHashEntry *he, PRIntn i, void *arg) FILE* out = (FILE*)arg; fprintf(out, "%d ==> (%d) ", entry->mCount, entry->mStr.mLength); - nsStr::Print(entry->mStr, out, PR_TRUE); + nsStrPrivate::Print(entry->mStr, out, PR_TRUE); fputc('\n', out); return HT_ENUMERATE_NEXT; } diff --git a/mozilla/xpcom/string/obsolete/nsStr.h b/mozilla/xpcom/string/obsolete/nsStr.h index 968d6e80f3f..06c0c071c91 100644 --- a/mozilla/xpcom/string/obsolete/nsStr.h +++ b/mozilla/xpcom/string/obsolete/nsStr.h @@ -213,10 +213,9 @@ #include #include #include "plhash.h" +#include "nsStrShared.h" //---------------------------------------------------------------------------------------- - -enum eCharSize {eOneByte=0,eTwoByte=1}; #define kDefaultCharSize eTwoByte #define kRadix10 (10) #define kRadix16 (16) @@ -267,225 +266,6 @@ protected: MOZ_COUNT_DTOR(nsStr); } - /** - * This method initializes an nsStr for use - * - * @update gess 01/04/99 - * @param aString is the nsStr to be initialized - * @param aCharSize tells us the requested char size (1 or 2 bytes) - */ - static void Initialize(nsStr& aDest,eCharSize aCharSize); - - /** - * This method initializes an nsStr for use - * - * @update gess 01/04/99 - * @param aString is the nsStr to be initialized - * @param aCharSize tells us the requested char size (1 or 2 bytes) - */ - static void Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 aLength,eCharSize aCharSize,PRBool aOwnsBuffer); - /** - * This method destroys the given nsStr, and *MAY* - * deallocate it's memory depending on the setting - * of the internal mOwnsBUffer flag. - * - * @update gess 01/04/99 - * @param aString is the nsStr to be manipulated - */ - static void Destroy(nsStr& aDest); - - /** - * These methods are where memory allocation/reallocation occur. - * - * @update gess 01/04/99 - * @param aString is the nsStr to be manipulated - * @return - */ - static PRBool EnsureCapacity(nsStr& aString,PRUint32 aNewLength); - static PRBool GrowCapacity(nsStr& aString,PRUint32 aNewLength); - - /** - * These methods are used to append content to the given nsStr - * - * @update gess 01/04/99 - * @param aDest is the nsStr to be appended to - * @param aSource is the buffer to be copied from - * @param anOffset tells us where in source to start copying - * @param aCount tells us the (max) # of chars to copy - */ - static void StrAppend(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount); - - /** - * These methods are used to assign contents of a source string to dest string - * - * @update gess 01/04/99 - * @param aDest is the nsStr to be appended to - * @param aSource is the buffer to be copied from - * @param anOffset tells us where in source to start copying - * @param aCount tells us the (max) # of chars to copy - */ - static void StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount); - - /** - * These methods are used to insert content from source string to the dest nsStr - * - * @update gess 01/04/99 - * @param aDest is the nsStr to be appended to - * @param aDestOffset tells us where in dest to start insertion - * @param aSource is the buffer to be copied from - * @param aSrcOffset tells us where in source to start copying - * @param aCount tells us the (max) # of chars to insert - */ - static void StrInsert1into1( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount); - static void StrInsert1into2( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount); - static void StrInsert2into1( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount); - static void StrInsert2into2( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount); - - - /** - * Helper routines for StrInsert1into1, etc - */ - static PRInt32 GetSegmentLength(const nsStr& aSource, - PRUint32 aSrcOffset, PRInt32 aCount); - static void AppendForInsert(nsStr& aDest, PRUint32 aDestOffset, const nsStr& aSource, PRUint32 aSrcOffset, PRInt32 theLength); - - /** - * This method deletes chars from the given str. - * The given allocator may choose to resize the str as well. - * - * @update gess 01/04/99 - * @param aDest is the nsStr to be deleted from - * @param aDestOffset tells us where in dest to start deleting - * @param aCount tells us the (max) # of chars to delete - */ - static void Delete1(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount); - static void Delete2(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount); - - /** - * helper routines for Delete1, Delete2 - */ - static PRInt32 GetDeleteLength(const nsStr& aDest, PRUint32 aDestOffset, PRUint32 aCount); - - /** - * This method is used to truncate the given string. - * The given allocator may choose to resize the str as well (but it's not likely). - * - * @update gess 01/04/99 - * @param aDest is the nsStr to be appended to - * @param aDestOffset tells us where in dest to start insertion - * @param aSource is the buffer to be copied from - * @param aSrcOffset tells us where in source to start copying - */ - static void StrTruncate(nsStr& aDest,PRUint32 aDestOffset); - - /** - * This method trims chars (given in aSet) from the edges of given buffer - * - * @update gess 01/04/99 - * @param aDest is the buffer to be manipulated - * @param aSet tells us which chars to remove from given buffer - * @param aEliminateLeading tells us whether to strip chars from the start of the buffer - * @param aEliminateTrailing tells us whether to strip chars from the start of the buffer - */ - static void Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing); - - /** - * This method compresses duplicate runs of a given char from the given buffer - * - * @update gess 01/04/99 - * @param aDest is the buffer to be manipulated - * @param aSet tells us which chars to compress from given buffer - * @param aChar is the replacement char - * @param aEliminateLeading tells us whether to strip chars from the start of the buffer - * @param aEliminateTrailing tells us whether to strip chars from the start of the buffer - */ - static void CompressSet1(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing); - static void CompressSet2(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing); - - /** - * This method removes all occurances of chars in given set from aDest - * - * @update gess 01/04/99 - * @param aDest is the buffer to be manipulated - * @param aSet tells us which chars to compress from given buffer - * @param aChar is the replacement char - * @param aEliminateLeading tells us whether to strip chars from the start of the buffer - * @param aEliminateTrailing tells us whether to strip chars from the start of the buffer - */ - static void StripChars1(nsStr& aDest,const char* aSet); - static void StripChars2(nsStr& aDest,const char* aSet); - - /** - * This method compares the data bewteen two nsStr's - * - * @update gess 01/04/99 - * @param aStr1 is the first buffer to be compared - * @param aStr2 is the 2nd buffer to be compared - * @param aCount is the number of chars to compare - * @param aIgnorecase tells us whether to use a case-sensitive comparison - * @return -1,0,1 depending on <,==,> - */ - static PRInt32 StrCompare1To1(const nsStr& aDest,const nsStr& aSource, - PRInt32 aCount,PRBool aIgnoreCase); - static PRInt32 StrCompare1To2(const nsStr& aDest, const nsStr& aSource, - PRInt32 aCount, PRBool aIgnoreCase); - static PRInt32 StrCompare2To1(const nsStr& aDest, const nsStr& aSource, - PRInt32 aCount, PRBool aIgnoreCase); - static PRInt32 StrCompare2To2(const nsStr& aDest, const nsStr& aSource, - PRInt32 aCount, PRBool aIgnoreCase); - - /** - * These methods scan the given string for 1 or more chars in a given direction - * - * @update gess 01/04/99 - * @param aDest is the nsStr to be searched to - * @param aSource (or aChar) is the substr we're looking to find - * @param aIgnoreCase tells us whether to search in a case-sensitive manner - * @param anOffset tells us where in the dest string to start searching - * @return the index of the source (substr) in dest, or -1 (kNotFound) if not found. - */ - static PRInt32 FindSubstr1in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - static PRInt32 FindSubstr1in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - static PRInt32 FindSubstr2in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - static PRInt32 FindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - - static PRInt32 FindChar1(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount); - static PRInt32 FindChar2(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount); - - static PRInt32 FindCharInSet1(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset); - static PRInt32 FindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRInt32 anOffset); - - static PRInt32 RFindSubstr1in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - static PRInt32 RFindSubstr2in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - static PRInt32 RFindSubstr1in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - static PRInt32 RFindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount); - - static PRInt32 RFindChar1(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount); - static PRInt32 RFindChar2(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount); - - static PRInt32 RFindCharInSet1(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset); - static PRInt32 RFindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRInt32 anOffset); - - static void Overwrite(nsStr& aDest,const nsStr& aSource,PRInt32 anOffset); - -#ifdef NS_STR_STATS - static PRBool DidAcquireMemory(void); -#endif - - /** - * Returns a hash code for the string for use in a PLHashTable. - */ - static PRUint32 HashCode(const nsStr& aDest); - -#ifdef NS_STR_STATS - /** - * Prints an nsStr. If truncate is true, the string is only printed up to - * the first newline. (Note: The current implementation doesn't handle - * non-ascii unicode characters.) - */ - static void Print(const nsStr& aDest, FILE* out, PRBool truncate = PR_FALSE); -#endif - protected: union { char* mStr; @@ -528,16 +308,13 @@ private: (aOwnsBuffer ? 1 : 0) << NSSTR_OWNSBUFFER_BIT); } - static PRBool Alloc(nsStr& aString,PRUint32 aCount); - static PRBool Realloc(nsStr& aString,PRUint32 aCount); - static PRBool Free(nsStr& aString); - public: friend NS_COM char* ToNewUTF8String( const nsAString& aSource ); friend inline void AddNullTerminator(nsStr& aDest); friend inline PRUnichar GetCharAt(const nsStr& aDest,PRUint32 anIndex); + friend class nsStrPrivate; friend class nsString; friend class nsCString; }; diff --git a/mozilla/xpcom/string/obsolete/nsStrPrivate.h b/mozilla/xpcom/string/obsolete/nsStrPrivate.h index 762aedec0fb..0d8d4dea37a 100644 --- a/mozilla/xpcom/string/obsolete/nsStrPrivate.h +++ b/mozilla/xpcom/string/obsolete/nsStrPrivate.h @@ -41,6 +41,7 @@ #define __nsStrPrivate_h #include "nscore.h" +#include "nsStrShared.h" struct nsStr; enum eCharSize; diff --git a/mozilla/xpcom/string/obsolete/nsStrShared.h b/mozilla/xpcom/string/obsolete/nsStrShared.h new file mode 100644 index 00000000000..251c9bfd915 --- /dev/null +++ b/mozilla/xpcom/string/obsolete/nsStrShared.h @@ -0,0 +1,8 @@ + +#ifndef __nsStrShared_h +#define __nsStrShared_h + + +enum eCharSize {eOneByte=0,eTwoByte=1}; + +#endif diff --git a/mozilla/xpcom/string/obsolete/nsString.cpp b/mozilla/xpcom/string/obsolete/nsString.cpp index 1be4da8c3fd..bab9e69e501 100644 --- a/mozilla/xpcom/string/obsolete/nsString.cpp +++ b/mozilla/xpcom/string/obsolete/nsString.cpp @@ -41,6 +41,7 @@ #include #include #include +#include "nsStrPrivate.h" #include "nsString.h" #include "nsReadableUtils.h" #include "nsDebug.h" @@ -66,11 +67,11 @@ nsCString::GetFlatBufferHandle() const * Default constructor. */ nsCString::nsCString() { - Initialize(*this,eOneByte); + nsStrPrivate::Initialize(*this,eOneByte); } nsCString::nsCString(const char* aCString) { - Initialize(*this,eOneByte); + nsStrPrivate::Initialize(*this,eOneByte); Assign(aCString); } @@ -81,7 +82,7 @@ nsCString::nsCString(const char* aCString) { * @param aLength tells us how many chars to copy from given CString */ nsCString::nsCString(const char* aCString,PRInt32 aLength) { - Initialize(*this,eOneByte); + nsStrPrivate::Initialize(*this,eOneByte); Assign(aCString,aLength); } @@ -91,15 +92,15 @@ nsCString::nsCString(const char* aCString,PRInt32 aLength) { * @param reference to another nsCString */ nsCString::nsCString(const nsCString& aString) { - Initialize(*this,aString.GetCharSize()); - StrAssign(*this,aString,0,aString.mLength); + nsStrPrivate::Initialize(*this,aString.GetCharSize()); + nsStrPrivate::StrAssign(*this,aString,0,aString.mLength); } /** * Destructor */ nsCString::~nsCString() { - Destroy(*this); + nsStrPrivate::Destroy(*this); } const char* nsCString::GetReadableFragment( nsReadableFragment& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const { @@ -133,7 +134,7 @@ char* nsCString::GetWritableFragment( nsWritableFragment& aFragment, nsFra } nsCString::nsCString( const nsACString& aReadable ) { - Initialize(*this,eOneByte); + nsStrPrivate::Initialize(*this,eOneByte); Assign(aReadable); } @@ -158,7 +159,7 @@ void nsCString::SetLength(PRUint32 anIndex) { // |SetCapacity| normally doesn't guarantee the use we are putting it to here (see its interface comment in nsAWritableString.h), // we can only use it since our local implementation, |nsCString::SetCapacity|, is known to do what we want - nsStr::StrTruncate(*this,anIndex); + nsStrPrivate::StrTruncate(*this,anIndex); } @@ -174,13 +175,13 @@ nsCString::SetCapacity( PRUint32 aNewCapacity ) if ( aNewCapacity ) { if( aNewCapacity > GetCapacity() ) - GrowCapacity(*this,aNewCapacity); + nsStrPrivate::GrowCapacity(*this,aNewCapacity); AddNullTerminator(*this); } else { - nsStr::Destroy(*this); - nsStr::Initialize(*this, eOneByte); + nsStrPrivate::Destroy(*this); + nsStrPrivate::Initialize(*this, eOneByte); } } @@ -248,7 +249,7 @@ nsCString::StripChar(PRUnichar aChar,PRInt32 anOffset){ */ void nsCString::StripChars(const char* aSet){ - nsStr::StripChars1(*this,aSet); + nsStrPrivate::StripChars1(*this,aSet); } @@ -353,19 +354,19 @@ nsCString::ReplaceSubstring(const nsCString& aTarget,const nsCString& aNewValue) } else { PRInt32 theIndex=0; - while(kNotFound!=(theIndex=nsStr::FindSubstr1in1(*this,aTarget,PR_FALSE,theIndex,mLength))) { + while(kNotFound!=(theIndex=nsStrPrivate::FindSubstr1in1(*this,aTarget,PR_FALSE,theIndex,mLength))) { if(aNewValue.mLength 0 ) { temp.mLength = aLength; - StrAppend(*this, temp, 0, aLength); + nsStrPrivate::StrAppend(*this, temp, 0, aLength); } } @@ -788,7 +789,7 @@ void nsCString::AppendWithConversion(const nsString& aString,PRInt32 aCount) { else aCount=MinInt(aCount,aString.mLength); if(0::length(aPtr); // We don't know the capacity, so we'll just have to assume // capacity = length. - nsStr::Initialize(*this, aPtr, aLength, aLength, eOneByte, PR_TRUE); + nsStrPrivate::Initialize(*this, aPtr, aLength, aLength, eOneByte, PR_TRUE); } /********************************************************************** @@ -840,10 +841,10 @@ PRInt32 nsCString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset PRInt32 result=kNotFound; if(aCString) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength = nsCRT::strlen(aCString); temp.mStr=(char*)aCString; - result=nsStr::FindSubstr1in1(*this,temp,aIgnoreCase,anOffset,aCount); + result=nsStrPrivate::FindSubstr1in1(*this,temp,aIgnoreCase,anOffset,aCount); } return result; } @@ -864,10 +865,10 @@ PRInt32 nsCString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOf PRInt32 result=kNotFound; if(aString) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength = nsCRT::strlen(aString); temp.mUStr=(PRUnichar*)aString; - result=nsStr::FindSubstr2in1(*this,temp,aIgnoreCase,anOffset,aCount); + result=nsStrPrivate::FindSubstr2in1(*this,temp,aIgnoreCase,anOffset,aCount); } return result; } @@ -883,12 +884,12 @@ PRInt32 nsCString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOf * @return offset in string, or -1 (kNotFound) */ PRInt32 nsCString::Find(const nsCString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::FindSubstr1in1(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::FindSubstr1in1(*this,aString,aIgnoreCase,anOffset,aCount); return result; } PRInt32 nsCString::Find(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::FindSubstr1in2(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::FindSubstr1in2(*this,aString,aIgnoreCase,anOffset,aCount); return result; } @@ -904,7 +905,7 @@ PRInt32 nsCString::Find(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOff * @return index in aDest where member of aSet occurs, or -1 if not found */ PRInt32 nsCString::FindChar(PRUnichar aChar,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::FindChar1(*this,aChar,anOffset,aCount); + PRInt32 result=nsStrPrivate::FindChar1(*this,aChar,anOffset,aCount); return result; } @@ -923,10 +924,10 @@ PRInt32 nsCString::FindCharInSet(const char* aCStringSet,PRInt32 anOffset) const PRInt32 result=kNotFound; if(aCStringSet) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aCStringSet); temp.mStr=(char*)aCStringSet; - result=nsStr::FindCharInSet1(*this,temp,PR_FALSE,anOffset); + result=nsStrPrivate::FindCharInSet1(*this,temp,PR_FALSE,anOffset); } return result; } @@ -946,10 +947,10 @@ PRInt32 nsCString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c PRInt32 result=kNotFound; if(aStringSet) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength=nsCRT::strlen(aStringSet); temp.mStr=(char*)aStringSet; - result=nsStr::FindCharInSet2(*this,temp,anOffset); + result=nsStrPrivate::FindCharInSet2(*this,temp,anOffset); } return result; } @@ -964,12 +965,12 @@ PRInt32 nsCString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c * @return */ PRInt32 nsCString::FindCharInSet(const nsCString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::FindCharInSet1(*this,aSet,PR_FALSE,anOffset); + PRInt32 result=nsStrPrivate::FindCharInSet1(*this,aSet,PR_FALSE,anOffset); return result; } PRInt32 nsCString::FindCharInSet(const nsString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::FindCharInSet2(*this,aSet,anOffset); + PRInt32 result=nsStrPrivate::FindCharInSet2(*this,aSet,anOffset); return result; } @@ -984,12 +985,12 @@ PRInt32 nsCString::FindCharInSet(const nsString& aSet,PRInt32 anOffset) const{ * @return offset in string, or -1 (kNotFound) */ PRInt32 nsCString::RFind(const nsCString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::RFindSubstr1in1(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::RFindSubstr1in1(*this,aString,aIgnoreCase,anOffset,aCount); return result; } PRInt32 nsCString::RFind(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::RFindSubstr2in1(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::RFindSubstr2in1(*this,aString,aIgnoreCase,anOffset,aCount); return result; } @@ -1010,10 +1011,10 @@ PRInt32 nsCString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset PRInt32 result=kNotFound; if(aString) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aString); temp.mStr=(char*)aString; - result=nsStr::RFindSubstr1in1(*this,temp,aIgnoreCase,anOffset,aCount); + result=nsStrPrivate::RFindSubstr1in1(*this,temp,aIgnoreCase,anOffset,aCount); } return result; } @@ -1029,7 +1030,7 @@ PRInt32 nsCString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset * @return index in aDest where member of aSet occurs, or -1 if not found */ PRInt32 nsCString::RFindChar(PRUnichar aChar,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::RFindChar1(*this,aChar,anOffset,aCount); + PRInt32 result=nsStrPrivate::RFindChar1(*this,aChar,anOffset,aCount); return result; } @@ -1047,10 +1048,10 @@ PRInt32 nsCString::RFindCharInSet(const char* aCStringSet,PRInt32 anOffset) cons PRInt32 result=kNotFound; if(aCStringSet) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aCStringSet); temp.mStr=(char*)aCStringSet; - result=nsStr::RFindCharInSet1(*this,temp,PR_FALSE,anOffset); + result=nsStrPrivate::RFindCharInSet1(*this,temp,PR_FALSE,anOffset); } return result; } @@ -1069,10 +1070,10 @@ PRInt32 nsCString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) PRInt32 result=kNotFound; if(aStringSet) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength=nsCRT::strlen(aStringSet); temp.mUStr=(PRUnichar*)aStringSet; - result=nsStr::RFindCharInSet2(*this,temp,anOffset); + result=nsStrPrivate::RFindCharInSet2(*this,temp,anOffset); } return result; } @@ -1087,12 +1088,12 @@ PRInt32 nsCString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) * @return offset of found char, or -1 (kNotFound) */ PRInt32 nsCString::RFindCharInSet(const nsCString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::RFindCharInSet1(*this,aSet,PR_FALSE,anOffset); + PRInt32 result=nsStrPrivate::RFindCharInSet1(*this,aSet,PR_FALSE,anOffset); return result; } PRInt32 nsCString::RFindCharInSet(const nsString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::RFindCharInSet2(*this,aSet,anOffset); + PRInt32 result=nsStrPrivate::RFindCharInSet2(*this,aSet,anOffset); return result; } @@ -1115,10 +1116,10 @@ PRInt32 nsCString::CompareWithConversion(const PRUnichar* aString,PRBool aIgnore if(aString) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength=nsCRT::strlen(aString); temp.mUStr=(PRUnichar*)aString; - return nsStr::StrCompare1To2(*this,temp,aCount,aIgnoreCase); + return nsStrPrivate::StrCompare1To2(*this,temp,aCount,aIgnoreCase); } return 0; } @@ -1136,10 +1137,10 @@ PRInt32 nsCString::CompareWithConversion(const char *aCString,PRBool aIgnoreCase if(aCString) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aCString); temp.mStr=(char*)aCString; - return nsStr::StrCompare1To1(*this,temp,aCount,aIgnoreCase); + return nsStrPrivate::StrCompare1To1(*this,temp,aCount,aIgnoreCase); } return 0; } @@ -1315,25 +1316,25 @@ NS_LossyConvertUCS2toASCII::NS_LossyConvertUCS2toASCII( const nsAString& aString * */ nsCAutoString::nsCAutoString() : nsCString(){ - Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); AddNullTerminator(*this); } nsCAutoString::nsCAutoString( const nsCString& aString ) : nsCString(){ - Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); AddNullTerminator(*this); Append(aString); } nsCAutoString::nsCAutoString( const nsACString& aString ) : nsCString(){ - Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); AddNullTerminator(*this); Append(aString); } nsCAutoString::nsCAutoString(const char* aCString) : nsCString() { - Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); AddNullTerminator(*this); Append(aCString); } @@ -1343,7 +1344,7 @@ nsCAutoString::nsCAutoString(const char* aCString) : nsCString() { * @param aCString is a ptr to a 1-byte cstr */ nsCAutoString::nsCAutoString(const char* aCString,PRInt32 aLength) : nsCString() { - Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); AddNullTerminator(*this); Append(aCString,aLength); } @@ -1354,10 +1355,10 @@ nsCAutoString::nsCAutoString(const char* aCString,PRInt32 aLength) : nsCString() */ nsCAutoString::nsCAutoString(const CBufDescriptor& aBuffer) : nsCString() { if(!aBuffer.mBuffer) { - Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); } else { - Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased); + nsStrPrivate::Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased); } if(!aBuffer.mIsConst) AddNullTerminator(*this); //this isn't really needed, but it guarantees that folks don't pass string constants. diff --git a/mozilla/xpcom/string/obsolete/nsString2.cpp b/mozilla/xpcom/string/obsolete/nsString2.cpp index 10ef2e510b5..f9d0a9a3f67 100644 --- a/mozilla/xpcom/string/obsolete/nsString2.cpp +++ b/mozilla/xpcom/string/obsolete/nsString2.cpp @@ -40,6 +40,7 @@ #include #include #include +#include "nsStrPrivate.h" #include "nsString.h" #include "nsReadableUtils.h" #include "nsDebug.h" @@ -65,11 +66,11 @@ nsString::GetFlatBufferHandle() const * Default constructor. */ nsString::nsString() { - Initialize(*this,eTwoByte); + nsStrPrivate::Initialize(*this,eTwoByte); } nsString::nsString(const PRUnichar* aString) { - Initialize(*this,eTwoByte); + nsStrPrivate::Initialize(*this,eTwoByte); Assign(aString); } @@ -80,7 +81,7 @@ nsString::nsString(const PRUnichar* aString) { * @param aLength tells us how many chars to copy from given aString */ nsString::nsString(const PRUnichar* aString,PRInt32 aCount) { - Initialize(*this,eTwoByte); + nsStrPrivate::Initialize(*this,eTwoByte); Assign(aString,aCount); } @@ -90,16 +91,16 @@ nsString::nsString(const PRUnichar* aString,PRInt32 aCount) { * @param reference to another nsString */ nsString::nsString(const nsString& aString) { - Initialize(*this,eTwoByte); - StrAssign(*this,aString,0,aString.mLength); + nsStrPrivate::Initialize(*this,eTwoByte); + nsStrPrivate::StrAssign(*this,aString,0,aString.mLength); } /** * Destructor - * Make sure we call nsStr::Destroy. + * Make sure we call nsStrPrivate::Destroy. */ nsString::~nsString() { - nsStr::Destroy(*this); + nsStrPrivate::Destroy(*this); } const PRUnichar* nsString::GetReadableFragment( nsReadableFragment& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const { @@ -140,15 +141,15 @@ nsString::do_AppendFromElement( PRUnichar inChar ) buf[0] = inChar; nsStr temp; - nsStr::Initialize(temp, eTwoByte); + nsStrPrivate::Initialize(temp, eTwoByte); temp.mUStr = buf; temp.mLength = 1; - StrAppend(*this, temp, 0, 1); + nsStrPrivate::StrAppend(*this, temp, 0, 1); } nsString::nsString( const nsAString& aReadable ) { - Initialize(*this,eTwoByte); + nsStrPrivate::Initialize(*this,eTwoByte); Assign(aReadable); } @@ -172,7 +173,7 @@ void nsString::SetLength(PRUint32 anIndex) { SetCapacity(anIndex); // |SetCapacity| normally doesn't guarantee the use we are putting it to here (see its interface comment in nsAWritableString.h), // we can only use it since our local implementation, |nsString::SetCapacity|, is known to do what we want - nsStr::StrTruncate(*this,anIndex); + nsStrPrivate::StrTruncate(*this,anIndex); } @@ -188,13 +189,13 @@ nsString::SetCapacity( PRUint32 aNewCapacity ) if ( aNewCapacity ) { if( aNewCapacity > GetCapacity() ) - GrowCapacity(*this, aNewCapacity); + nsStrPrivate::GrowCapacity(*this, aNewCapacity); AddNullTerminator(*this); } else { - nsStr::Destroy(*this); - nsStr::Initialize(*this, eTwoByte); + nsStrPrivate::Destroy(*this); + nsStrPrivate::Initialize(*this, eTwoByte); } } @@ -299,7 +300,7 @@ nsString::StripChar(PRUnichar aChar,PRInt32 anOffset){ */ void nsString::StripChars(const char* aSet){ - nsStr::StripChars2(*this,aSet); + nsStrPrivate::StripChars2(*this,aSet); } @@ -409,19 +410,19 @@ nsString::ReplaceSubstring(const nsString& aTarget,const nsString& aNewValue){ } else { PRInt32 theIndex=0; - while(kNotFound!=(theIndex=nsStr::FindSubstr2in2(*this,aTarget,PR_FALSE,theIndex,mLength))) { + while(kNotFound!=(theIndex=nsStrPrivate::FindSubstr2in2(*this,aTarget,PR_FALSE,theIndex,mLength))) { if(aNewValue.mLength::length(aPtr); // We don't know the capacity, so we'll just have to assume // capacity = length. - nsStr::Initialize(*this, (char*)aPtr, aLength, aLength, eTwoByte, PR_TRUE); + nsStrPrivate::Initialize(*this, (char*)aPtr, aLength, aLength, eTwoByte, PR_TRUE); } @@ -883,10 +884,10 @@ PRInt32 nsString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset, PRInt32 result=kNotFound; if(aCString) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aCString); temp.mStr=(char*)aCString; - result=nsStr::FindSubstr1in2(*this,temp,aIgnoreCase,anOffset,aCount); + result=nsStrPrivate::FindSubstr1in2(*this,temp,aIgnoreCase,anOffset,aCount); } return result; } @@ -907,10 +908,10 @@ PRInt32 nsString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOff PRInt32 result=kNotFound; if(aString) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength=nsCRT::strlen(aString); temp.mUStr=(PRUnichar*)aString; - result=nsStr::FindSubstr2in2(*this,temp,aIgnoreCase,anOffset,aCount); + result=nsStrPrivate::FindSubstr2in2(*this,temp,aIgnoreCase,anOffset,aCount); } return result; } @@ -926,7 +927,7 @@ PRInt32 nsString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOff * @return offset in string, or -1 (kNotFound) */ PRInt32 nsString::Find(const nsCString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::FindSubstr1in2(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::FindSubstr1in2(*this,aString,aIgnoreCase,anOffset,aCount); return result; } @@ -941,7 +942,7 @@ PRInt32 nsString::Find(const nsCString& aString,PRBool aIgnoreCase,PRInt32 anOff * @return offset in string, or -1 (kNotFound) */ PRInt32 nsString::Find(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::FindSubstr2in2(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::FindSubstr2in2(*this,aString,aIgnoreCase,anOffset,aCount); return result; } @@ -960,10 +961,10 @@ PRInt32 nsString::FindCharInSet(const char* aCStringSet,PRInt32 anOffset) const{ PRInt32 result=kNotFound; if(aCStringSet) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aCStringSet); temp.mStr=(char*)aCStringSet; - result=nsStr::FindCharInSet1(*this,temp,PR_FALSE,anOffset); + result=nsStrPrivate::FindCharInSet1(*this,temp,PR_FALSE,anOffset); } return result; } @@ -983,10 +984,10 @@ PRInt32 nsString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) co PRInt32 result=kNotFound; if(aStringSet) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength=nsCRT::strlen(aStringSet); temp.mStr=(char*)aStringSet; - result=nsStr::FindCharInSet2(*this,temp,anOffset); + result=nsStrPrivate::FindCharInSet2(*this,temp,anOffset); } return result; } @@ -1001,12 +1002,12 @@ PRInt32 nsString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) co * @return */ PRInt32 nsString::FindCharInSet(const nsString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::FindCharInSet2(*this,aSet,anOffset); + PRInt32 result=nsStrPrivate::FindCharInSet2(*this,aSet,anOffset); return result; } PRInt32 nsString::FindCharInSet(const nsCString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::FindCharInSet1(*this,aSet,PR_FALSE,anOffset); + PRInt32 result=nsStrPrivate::FindCharInSet1(*this,aSet,PR_FALSE,anOffset); return result; } @@ -1022,7 +1023,7 @@ PRInt32 nsString::FindCharInSet(const nsCString& aSet,PRInt32 anOffset) const{ * @return offset in string, or -1 (kNotFound) */ PRInt32 nsString::RFind(const nsCString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::RFindSubstr1in2(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::RFindSubstr1in2(*this,aString,aIgnoreCase,anOffset,aCount); return result; } @@ -1037,7 +1038,7 @@ PRInt32 nsString::RFind(const nsCString& aString,PRBool aIgnoreCase,PRInt32 anOf * @return offset in string, or -1 (kNotFound) */ PRInt32 nsString::RFind(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::RFindSubstr2in2(*this,aString,aIgnoreCase,anOffset,aCount); + PRInt32 result=nsStrPrivate::RFindSubstr2in2(*this,aString,aIgnoreCase,anOffset,aCount); return result; } @@ -1057,10 +1058,10 @@ PRInt32 nsString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset, PRInt32 result=kNotFound; if(aString) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aString); temp.mStr=(char*)aString; - result=nsStr::RFindSubstr1in2(*this,temp,aIgnoreCase,anOffset,aCount); + result=nsStrPrivate::RFindSubstr1in2(*this,temp,aIgnoreCase,anOffset,aCount); } return result; } @@ -1075,7 +1076,7 @@ PRInt32 nsString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset, * @return offset of found char, or -1 (kNotFound) */ PRInt32 nsString::RFindChar(PRUnichar aChar,PRInt32 anOffset,PRInt32 aCount) const{ - PRInt32 result=nsStr::RFindChar2(*this,aChar,anOffset,aCount); + PRInt32 result=nsStrPrivate::RFindChar2(*this,aChar,anOffset,aCount); return result; } @@ -1093,10 +1094,10 @@ PRInt32 nsString::RFindCharInSet(const char* aCStringSet,PRInt32 anOffset) const PRInt32 result=kNotFound; if(aCStringSet) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength=nsCRT::strlen(aCStringSet); temp.mStr=(char*)aCStringSet; - result=nsStr::RFindCharInSet1(*this,temp,PR_FALSE,anOffset); + result=nsStrPrivate::RFindCharInSet1(*this,temp,PR_FALSE,anOffset); } return result; } @@ -1112,12 +1113,12 @@ PRInt32 nsString::RFindCharInSet(const char* aCStringSet,PRInt32 anOffset) const * @return offset of found char, or -1 (kNotFound) */ PRInt32 nsString::RFindCharInSet(const nsString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::RFindCharInSet2(*this,aSet,anOffset); + PRInt32 result=nsStrPrivate::RFindCharInSet2(*this,aSet,anOffset); return result; } PRInt32 nsString::RFindCharInSet(const nsCString& aSet,PRInt32 anOffset) const{ - PRInt32 result=nsStr::RFindCharInSet1(*this,aSet,PR_FALSE,anOffset); + PRInt32 result=nsStrPrivate::RFindCharInSet1(*this,aSet,PR_FALSE,anOffset); return result; } @@ -1137,10 +1138,10 @@ PRInt32 nsString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c PRInt32 result=kNotFound; if(aStringSet) { nsStr temp; - nsStr::Initialize(temp,eTwoByte); + nsStrPrivate::Initialize(temp,eTwoByte); temp.mLength=nsCRT::strlen(aStringSet); temp.mUStr=(PRUnichar*)aStringSet; - result=nsStr::RFindCharInSet2(*this,temp,anOffset); + result=nsStrPrivate::RFindCharInSet2(*this,temp,anOffset); } return result; } @@ -1163,12 +1164,12 @@ PRInt32 nsString::CompareWithConversion(const char *aCString,PRBool aIgnoreCase, if(aCString) { nsStr temp; - nsStr::Initialize(temp,eOneByte); + nsStrPrivate::Initialize(temp,eOneByte); temp.mLength= (0>eTwoByte)-1,0,eTwoByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); AddNullTerminator(*this); } nsAutoString::nsAutoString(const PRUnichar* aString) : nsString() { - Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); AddNullTerminator(*this); Append(aString); } @@ -1397,7 +1398,7 @@ nsAutoString::nsAutoString(const PRUnichar* aString) : nsString() { * @param aLength tells us how many chars to copy from aString */ nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString() { - Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); AddNullTerminator(*this); Append(aString,aLength); } @@ -1405,7 +1406,7 @@ nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString( nsAutoString::nsAutoString( const nsString& aString ) : nsString() { - Initialize(*this, mBuffer, (sizeof(mBuffer)>>eTwoByte)-1, 0, eTwoByte, PR_FALSE); + nsStrPrivate::Initialize(*this, mBuffer, (sizeof(mBuffer)>>eTwoByte)-1, 0, eTwoByte, PR_FALSE); AddNullTerminator(*this); Append(aString); } @@ -1413,7 +1414,7 @@ nsAutoString::nsAutoString( const nsString& aString ) nsAutoString::nsAutoString( const nsAString& aString ) : nsString() { - Initialize(*this, mBuffer, (sizeof(mBuffer)>>eTwoByte)-1, 0, eTwoByte, PR_FALSE); + nsStrPrivate::Initialize(*this, mBuffer, (sizeof(mBuffer)>>eTwoByte)-1, 0, eTwoByte, PR_FALSE); AddNullTerminator(*this); Append(aString); } @@ -1426,10 +1427,10 @@ nsAutoString::nsAutoString( const nsAString& aString ) */ nsAutoString::nsAutoString(const CBufDescriptor& aBuffer) : nsString() { if(!aBuffer.mBuffer) { - Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); } else { - Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased); + nsStrPrivate::Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased); } if(!aBuffer.mIsConst) AddNullTerminator(*this); @@ -1544,7 +1545,7 @@ NS_ConvertUTF8toUCS2::Init( const nsACString& aCString ) * Default copy constructor */ nsAutoString::nsAutoString(const nsAutoString& aString) : nsString() { - Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); AddNullTerminator(*this); Append(aString); } @@ -1555,7 +1556,7 @@ nsAutoString::nsAutoString(const nsAutoString& aString) : nsString() { * @param */ nsAutoString::nsAutoString(PRUnichar aChar) : nsString(){ - Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + nsStrPrivate::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); AddNullTerminator(*this); Append(aChar); }