From 502fc9123428f85071c97c10058e95bf3f2cd47e Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Thu, 29 Apr 2004 01:54:55 +0000 Subject: [PATCH] Fix RFindCharInSet to work again. Bug 240837, r+sr=darin, a=asa git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_7_BRANCH@155670 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/string/src/nsStringObsolete.cpp | 2 +- mozilla/xpcom/string/src/nsTStringObsolete.cpp | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mozilla/xpcom/string/src/nsStringObsolete.cpp b/mozilla/xpcom/string/src/nsStringObsolete.cpp index a3d55db8bf6..e6c6c849b20 100644 --- a/mozilla/xpcom/string/src/nsStringObsolete.cpp +++ b/mozilla/xpcom/string/src/nsStringObsolete.cpp @@ -780,7 +780,7 @@ RFindCharInSet( const CharT* data, PRUint32 dataLen, const SetCharT* set ) { CharT filter = nsBufferRoutines::get_find_in_set_filter(set); - for (const CharT* iter = data + dataLen; iter >= data; --iter) + for (const CharT* iter = data + dataLen - 1; iter >= data; --iter) { CharT currentChar = *iter; if (currentChar & filter) diff --git a/mozilla/xpcom/string/src/nsTStringObsolete.cpp b/mozilla/xpcom/string/src/nsTStringObsolete.cpp index 96d10d46f70..5ed065ad2e8 100644 --- a/mozilla/xpcom/string/src/nsTStringObsolete.cpp +++ b/mozilla/xpcom/string/src/nsTStringObsolete.cpp @@ -127,15 +127,13 @@ nsTString_CharT::FindCharInSet( const char* aSet, PRInt32 aOffset ) const PRInt32 nsTString_CharT::RFindCharInSet( const CharT* aSet, PRInt32 aOffset ) const { - if (aOffset < 0) - aOffset = 0; - else if (aOffset >= PRInt32(mLength)) - return kNotFound; - - PRInt32 result = ::RFindCharInSet(mData + aOffset, mLength - aOffset, aSet); - if (result != kNotFound) - result += aOffset; - return result; + // We want to pass a "data length" to ::RFindCharInSet + if (aOffset < 0 || aOffset > PRInt32(mLength)) + aOffset = mLength; + else + ++aOffset; + + return ::RFindCharInSet(mData, aOffset, aSet); }