From ffdfa54db5f018fec86cdab42ec6f98630d35857 Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Tue, 16 Oct 2001 05:35:38 +0000 Subject: [PATCH] Remove overloaded fputs functions, DebugDump, and (from nsCString only) ToCString). b=104763 r=jag rs=scc --- string/obsolete/nsString.cpp | 96 +---------------------------- string/obsolete/nsString.h | 16 ----- string/obsolete/nsString2.cpp | 78 ----------------------- string/obsolete/nsString2.h | 6 -- xpcom/string/obsolete/nsString.cpp | 96 +---------------------------- xpcom/string/obsolete/nsString.h | 16 ----- xpcom/string/obsolete/nsString2.cpp | 78 ----------------------- xpcom/string/obsolete/nsString2.h | 6 -- 8 files changed, 4 insertions(+), 388 deletions(-) diff --git a/string/obsolete/nsString.cpp b/string/obsolete/nsString.cpp index aea581b1ef8..cdb6f1a4d5d 100644 --- a/string/obsolete/nsString.cpp +++ b/string/obsolete/nsString.cpp @@ -526,31 +526,6 @@ nsCString::CompressWhitespace( PRBool aEliminateLeading,PRBool aEliminateTrailin string conversion methods... *********************************************************************/ -/** - * Copies contents of this string into he given buffer - * Note that if you provide me a buffer that is smaller than the length of - * this string, only the number of bytes that will fit are copied. - * - * @update gess 01/04/99 - * @param aBuf - * @param aBufLength - * @param anOffset - * @return - */ -char* nsCString::ToCString(char* aBuf, PRUint32 aBufLength,PRUint32 anOffset) const{ - if(aBuf) { - - // NS_ASSERTION(mLength<=aBufLength,"buffer smaller than string"); - - CBufDescriptor theDescr(aBuf,PR_TRUE,aBufLength,0); - nsCAutoString temp(theDescr); - temp.Assign(mStr, PR_MIN(mLength, aBufLength-1)); - temp.mStr=0; - } - return aBuf; -} - - /** * Perform string to float conversion. * @update gess 01/04/99 @@ -563,7 +538,8 @@ float nsCString::ToFloat(PRInt32* aErrorCode) const { *aErrorCode = (PRInt32) NS_ERROR_ILLEGAL_VALUE; return 0.0f; } - char* cp = ToCString(buf, sizeof(buf)); + char *cp = strncpy(buf, get(), sizeof(buf) - 1); + buf[sizeof(buf)-1] = '\0'; float f = (float) PR_strtod(cp, &cp); if (*cp != 0) { *aErrorCode = (PRInt32) NS_ERROR_ILLEGAL_VALUE; @@ -1251,75 +1227,7 @@ PRBool nsCString::EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCa PRBool result=PRBool(0==theAnswer); return result; } - -#if 0 -/** - * - * @update gess8/8/98 - * @param - * @return - */ -ostream& operator<<(ostream& aStream,const nsCString& aString){ - if(eOneByte==aString.mCharSize) { - aStream<= PRInt32(sizeof(buf))) { - cp = ToNewCString(aString); - } else { - aString.ToCString(cp, len + 1); - } - if(len>0) - ::fwrite(cp, 1, len, out); - if (cp != buf) { - delete[] cp; - } - return (int) len; -} - -#ifdef DEBUG -/** - * Dumps the contents of the string to stdout - * @update gess 11/15/99 - */ -void nsCString::DebugDump(void) const { - if(mStr && (eOneByte==mCharSize)) { - printf("\n%s",mStr); - } -} -#endif - //---------------------------------------------------------------------- NS_ConvertUCS2toUTF8::NS_ConvertUCS2toUTF8( const nsAString& aString ) diff --git a/string/obsolete/nsString.h b/string/obsolete/nsString.h index b4462221be1..8914e958f5c 100644 --- a/string/obsolete/nsString.h +++ b/string/obsolete/nsString.h @@ -246,16 +246,6 @@ public: operator const char*() const {return (const char*)mStr;} //#endif - - /** - * Copies data from internal buffer onto given char* buffer - * NOTE: This only copies as many chars as will fit in given buffer (clips) - * @param aBuf is the buffer where data is stored - * @param aBuflength is the max # of chars to move to buffer - * @return ptr to given buffer - */ - char* ToCString(char* aBuf,PRUint32 aBufLength,PRUint32 anOffset=0) const; - /** * Perform string to float conversion. * @param aErrorCode will contain error if one occurs @@ -438,8 +428,6 @@ public: * @return string length */ virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const; - - void DebugDump(void) const; #endif private: @@ -455,10 +443,6 @@ private: // NS_DEF_STRING_COMPARISON_OPERATORS(nsCString, char) // NS_DEF_DERIVED_STRING_OPERATOR_PLUS(nsCString, char) -extern NS_COM int fputs(const nsCString& aString, FILE* out); -//ostream& operator<<(ostream& aStream,const nsCString& aString); -//virtual void DebugDump(ostream& aStream) const; - /************************************************************** Here comes the AutoString class which uses internal memory diff --git a/string/obsolete/nsString2.cpp b/string/obsolete/nsString2.cpp index 70aea893b80..59c055ebd7d 100644 --- a/string/obsolete/nsString2.cpp +++ b/string/obsolete/nsString2.cpp @@ -1435,84 +1435,6 @@ PRBool nsString::IsDigit(PRUnichar aChar) { return PRBool((aChar >= '0') && (aChar <= '9')); } -#if 0 - -/** - * - * @update gess8/8/98 - * @param - * @return - */ -ostream& operator<<(ostream& aStream,const nsString& aString){ - if(eOneByte==aString.mCharSize) { - aStream<= PRInt32(sizeof(buf))) { - cp = ToNewCString(aString); - } else { - aString.ToCString(cp, len + 1); - } - if(len>0) - ::fwrite(cp, 1, len, out); - if (cp != buf) { - Recycle(cp); - } - return (int) len; -} - -/** - * Dumps the contents of the string to stdout - * @update gess 11/15/99 - */ -void nsString::DebugDump(void) const { -#ifdef DEBUG - const char* theBuffer=mStr; - nsCAutoString temp; - - if(eTwoByte==mCharSize) { - nsStr::StrAssign(temp, *this, 0, mLength); - theBuffer=temp.get(); - } - - if(theBuffer) { - printf("\n%s",theBuffer); - } -#endif -} - - /*********************************************************************** IMPLEMENTATION NOTES: AUTOSTRING... diff --git a/string/obsolete/nsString2.h b/string/obsolete/nsString2.h index 30178c0f8f2..fa7f3ed4b61 100644 --- a/string/obsolete/nsString2.h +++ b/string/obsolete/nsString2.h @@ -453,8 +453,6 @@ public: */ PRBool IsASCII(const PRUnichar* aBuffer=0); - void DebugDump(void) const; - /** * Determine if given char is a valid space character * @@ -501,10 +499,6 @@ private: // NS_DEF_STRING_COMPARISON_OPERATORS(nsString, PRUnichar) // NS_DEF_DERIVED_STRING_OPERATOR_PLUS(nsString, PRUnichar) -extern NS_COM int fputs(const nsString& aString, FILE* out); -//ostream& operator<<(ostream& aStream,const nsString& aString); -//virtual void DebugDump(ostream& aStream) const; - /************************************************************** Here comes the AutoString class which uses internal memory (typically found on the stack) for its default buffer. diff --git a/xpcom/string/obsolete/nsString.cpp b/xpcom/string/obsolete/nsString.cpp index aea581b1ef8..cdb6f1a4d5d 100644 --- a/xpcom/string/obsolete/nsString.cpp +++ b/xpcom/string/obsolete/nsString.cpp @@ -526,31 +526,6 @@ nsCString::CompressWhitespace( PRBool aEliminateLeading,PRBool aEliminateTrailin string conversion methods... *********************************************************************/ -/** - * Copies contents of this string into he given buffer - * Note that if you provide me a buffer that is smaller than the length of - * this string, only the number of bytes that will fit are copied. - * - * @update gess 01/04/99 - * @param aBuf - * @param aBufLength - * @param anOffset - * @return - */ -char* nsCString::ToCString(char* aBuf, PRUint32 aBufLength,PRUint32 anOffset) const{ - if(aBuf) { - - // NS_ASSERTION(mLength<=aBufLength,"buffer smaller than string"); - - CBufDescriptor theDescr(aBuf,PR_TRUE,aBufLength,0); - nsCAutoString temp(theDescr); - temp.Assign(mStr, PR_MIN(mLength, aBufLength-1)); - temp.mStr=0; - } - return aBuf; -} - - /** * Perform string to float conversion. * @update gess 01/04/99 @@ -563,7 +538,8 @@ float nsCString::ToFloat(PRInt32* aErrorCode) const { *aErrorCode = (PRInt32) NS_ERROR_ILLEGAL_VALUE; return 0.0f; } - char* cp = ToCString(buf, sizeof(buf)); + char *cp = strncpy(buf, get(), sizeof(buf) - 1); + buf[sizeof(buf)-1] = '\0'; float f = (float) PR_strtod(cp, &cp); if (*cp != 0) { *aErrorCode = (PRInt32) NS_ERROR_ILLEGAL_VALUE; @@ -1251,75 +1227,7 @@ PRBool nsCString::EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCa PRBool result=PRBool(0==theAnswer); return result; } - -#if 0 -/** - * - * @update gess8/8/98 - * @param - * @return - */ -ostream& operator<<(ostream& aStream,const nsCString& aString){ - if(eOneByte==aString.mCharSize) { - aStream<= PRInt32(sizeof(buf))) { - cp = ToNewCString(aString); - } else { - aString.ToCString(cp, len + 1); - } - if(len>0) - ::fwrite(cp, 1, len, out); - if (cp != buf) { - delete[] cp; - } - return (int) len; -} - -#ifdef DEBUG -/** - * Dumps the contents of the string to stdout - * @update gess 11/15/99 - */ -void nsCString::DebugDump(void) const { - if(mStr && (eOneByte==mCharSize)) { - printf("\n%s",mStr); - } -} -#endif - //---------------------------------------------------------------------- NS_ConvertUCS2toUTF8::NS_ConvertUCS2toUTF8( const nsAString& aString ) diff --git a/xpcom/string/obsolete/nsString.h b/xpcom/string/obsolete/nsString.h index b4462221be1..8914e958f5c 100644 --- a/xpcom/string/obsolete/nsString.h +++ b/xpcom/string/obsolete/nsString.h @@ -246,16 +246,6 @@ public: operator const char*() const {return (const char*)mStr;} //#endif - - /** - * Copies data from internal buffer onto given char* buffer - * NOTE: This only copies as many chars as will fit in given buffer (clips) - * @param aBuf is the buffer where data is stored - * @param aBuflength is the max # of chars to move to buffer - * @return ptr to given buffer - */ - char* ToCString(char* aBuf,PRUint32 aBufLength,PRUint32 anOffset=0) const; - /** * Perform string to float conversion. * @param aErrorCode will contain error if one occurs @@ -438,8 +428,6 @@ public: * @return string length */ virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const; - - void DebugDump(void) const; #endif private: @@ -455,10 +443,6 @@ private: // NS_DEF_STRING_COMPARISON_OPERATORS(nsCString, char) // NS_DEF_DERIVED_STRING_OPERATOR_PLUS(nsCString, char) -extern NS_COM int fputs(const nsCString& aString, FILE* out); -//ostream& operator<<(ostream& aStream,const nsCString& aString); -//virtual void DebugDump(ostream& aStream) const; - /************************************************************** Here comes the AutoString class which uses internal memory diff --git a/xpcom/string/obsolete/nsString2.cpp b/xpcom/string/obsolete/nsString2.cpp index 70aea893b80..59c055ebd7d 100644 --- a/xpcom/string/obsolete/nsString2.cpp +++ b/xpcom/string/obsolete/nsString2.cpp @@ -1435,84 +1435,6 @@ PRBool nsString::IsDigit(PRUnichar aChar) { return PRBool((aChar >= '0') && (aChar <= '9')); } -#if 0 - -/** - * - * @update gess8/8/98 - * @param - * @return - */ -ostream& operator<<(ostream& aStream,const nsString& aString){ - if(eOneByte==aString.mCharSize) { - aStream<= PRInt32(sizeof(buf))) { - cp = ToNewCString(aString); - } else { - aString.ToCString(cp, len + 1); - } - if(len>0) - ::fwrite(cp, 1, len, out); - if (cp != buf) { - Recycle(cp); - } - return (int) len; -} - -/** - * Dumps the contents of the string to stdout - * @update gess 11/15/99 - */ -void nsString::DebugDump(void) const { -#ifdef DEBUG - const char* theBuffer=mStr; - nsCAutoString temp; - - if(eTwoByte==mCharSize) { - nsStr::StrAssign(temp, *this, 0, mLength); - theBuffer=temp.get(); - } - - if(theBuffer) { - printf("\n%s",theBuffer); - } -#endif -} - - /*********************************************************************** IMPLEMENTATION NOTES: AUTOSTRING... diff --git a/xpcom/string/obsolete/nsString2.h b/xpcom/string/obsolete/nsString2.h index 30178c0f8f2..fa7f3ed4b61 100644 --- a/xpcom/string/obsolete/nsString2.h +++ b/xpcom/string/obsolete/nsString2.h @@ -453,8 +453,6 @@ public: */ PRBool IsASCII(const PRUnichar* aBuffer=0); - void DebugDump(void) const; - /** * Determine if given char is a valid space character * @@ -501,10 +499,6 @@ private: // NS_DEF_STRING_COMPARISON_OPERATORS(nsString, PRUnichar) // NS_DEF_DERIVED_STRING_OPERATOR_PLUS(nsString, PRUnichar) -extern NS_COM int fputs(const nsString& aString, FILE* out); -//ostream& operator<<(ostream& aStream,const nsString& aString); -//virtual void DebugDump(ostream& aStream) const; - /************************************************************** Here comes the AutoString class which uses internal memory (typically found on the stack) for its default buffer.