odd 'n' ends

This commit is contained in:
rickg%netscape.com 1999-07-25 17:21:34 +00:00
parent b396c554b0
commit d9e840013c
7 changed files with 87 additions and 76 deletions

View File

@ -651,7 +651,7 @@ PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnor
if(0<aDest.mLength) {
while(--index>=0) {
PRUnichar theChar=GetCharAt(aDest,index);
thePos=gRFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
if(kNotFound!=thePos)
return index;
} //while
@ -691,7 +691,7 @@ PRInt32 nsStr::Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PR
//----------------------------------------------------------------------------------------
CSharedStrBuffer::CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
CBufDescriptor::CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
mBuffer=aString;
mCharSize=eOneByte;
mStackBased=aStackBased;
@ -704,7 +704,7 @@ CSharedStrBuffer::CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCa
}
}
CSharedStrBuffer::CSharedStrBuffer(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
CBufDescriptor::CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
mBuffer=(char*)aString;
mCharSize=eTwoByte;
mStackBased=aStackBased;

View File

@ -43,7 +43,7 @@
#define _nsStr
#include "nscore.h"
#include "nsCppSharedAllocator.h"
#include "nsIAllocator.h"
//----------------------------------------------------------------------------------------
@ -60,10 +60,10 @@ class nsIMemoryAgent;
//----------------------------------------------------------------------------------------
class NS_COM CSharedStrBuffer {
class NS_COM CBufDescriptor {
public:
CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
CSharedStrBuffer(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
char* mBuffer;
eCharSize mCharSize;
@ -311,11 +311,8 @@ public:
}
aDest.mCapacity=theNewCapacity++;
size_t theSize=(theNewCapacity<<aDest.mCharSize);
// aDest.mStr=new char[theSize];
nsCppSharedAllocator<char> shared_allocator;
aDest.mStr = shared_allocator.allocate(theSize);
PRUint32 theSize=(theNewCapacity<<aDest.mCharSize);
aDest.mStr = (char*)nsAllocator::Alloc(theSize);
aDest.mOwnsBuffer=1;
return PR_TRUE;
@ -324,9 +321,7 @@ public:
virtual PRBool Free(nsStr& aDest){
if(aDest.mStr){
if(aDest.mOwnsBuffer){
// delete [] aDest.mStr;
nsCppSharedAllocator<char> shared_allocator;
shared_allocator.deallocate(aDest.mStr, aDest.mCapacity);
nsAllocator::Free(aDest.mStr);
}
aDest.mStr=0;
aDest.mOwnsBuffer=0;

View File

@ -1,4 +1,3 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
@ -286,15 +285,21 @@ CopyChars gCopyChars[2][2]={
* @return index of pos if found, else -1 (kNotFound)
*/
inline PRInt32 FindChar1(const char* aDest,PRUint32 aLength,PRUint32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase) {
PRUnichar theCmpChar=(aIgnoreCase ? nsCRT::ToUpper(aChar) : aChar);
PRInt32 theIndex=0;
PRInt32 theLength=(PRInt32)aLength;
for(theIndex=(PRInt32)anOffset;theIndex<theLength;theIndex++){
PRUnichar theChar=aDest[theIndex];
if(aIgnoreCase)
theChar=nsCRT::ToUpper(theChar);
if(theChar==theCmpChar)
return theIndex;
if(aIgnoreCase) {
PRUnichar theChar=nsCRT::ToUpper(aChar);
for(theIndex=(PRInt32)anOffset;theIndex<theLength;theIndex++){
if(nsCRT::ToUpper(aDest[theIndex])==theChar)
return theIndex;
}
}
else {
for(theIndex=(PRInt32)anOffset;theIndex<theLength;theIndex++){
if(aDest[theIndex]==aChar)
return theIndex;
}
}
return kNotFound;
}
@ -311,17 +316,24 @@ inline PRInt32 FindChar1(const char* aDest,PRUint32 aLength,PRUint32 anOffset,co
* @return index of pos if found, else -1 (kNotFound)
*/
inline PRInt32 FindChar2(const char* aDest,PRUint32 aLength,PRUint32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase) {
PRUnichar theCmpChar=(aIgnoreCase ? nsCRT::ToUpper(aChar) : aChar);
PRInt32 theIndex=0;
PRInt32 theLength=(PRInt32)aLength;
PRUnichar* theBuf=(PRUnichar*)aDest;
for(theIndex=(PRInt32)anOffset;theIndex<theLength;theIndex++){
PRUnichar theChar=theBuf[theIndex];
if(aIgnoreCase)
theChar=nsCRT::ToUpper(theChar);
if(theChar==theCmpChar)
return theIndex;
if(aIgnoreCase) {
PRUnichar theChar=nsCRT::ToUpper(aChar);
for(theIndex=(PRInt32)anOffset;theIndex<theLength;theIndex++){
if(nsCRT::ToUpper(theBuf[theIndex])==theChar)
return theIndex;
}
}
else {
for(theIndex=(PRInt32)anOffset;theIndex<theLength;theIndex++){
if(theBuf[theIndex]==aChar)
return theIndex;
}
}
return kNotFound;
}
@ -338,16 +350,22 @@ inline PRInt32 FindChar2(const char* aDest,PRUint32 aLength,PRUint32 anOffset,co
* @return index of pos if found, else -1 (kNotFound)
*/
inline PRInt32 RFindChar1(const char* aDest,PRUint32 aDestLength,PRUint32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase) {
PRUnichar theCmpChar=(aIgnoreCase ? nsCRT::ToUpper(aChar) : aChar);
PRInt32 theIndex=0;
PRInt32 thePos=(PRInt32)anOffset;
for(theIndex=thePos;theIndex>=0;theIndex--){
PRUnichar theChar=GetCharAt(aDest,theIndex);
if(aIgnoreCase)
theChar=nsCRT::ToUpper(theChar);
if(theChar==theCmpChar)
return theIndex;
if(aIgnoreCase) {
PRUnichar theChar=nsCRT::ToUpper(aChar);
for(theIndex=(PRInt32)anOffset;theIndex>=0;theIndex--){
if(nsCRT::ToUpper(aDest[theIndex])==theChar)
return theIndex;
}
}
else {
for(theIndex=(PRInt32)anOffset;theIndex>=0;theIndex--){
if(aDest[theIndex]==aChar)
return theIndex;
}
}
return kNotFound;
}
@ -364,16 +382,24 @@ inline PRInt32 RFindChar1(const char* aDest,PRUint32 aDestLength,PRUint32 anOffs
* @return index of pos if found, else -1 (kNotFound)
*/
inline PRInt32 RFindChar2(const char* aDest,PRUint32 aDestLength,PRUint32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase) {
PRUnichar theCmpChar=(aIgnoreCase ? nsCRT::ToUpper(aChar) : aChar);
PRInt32 theIndex=0;
PRInt32 thePos=(PRInt32)anOffset;
for(theIndex=thePos;theIndex>=0;theIndex--){
PRUnichar theChar=GetUnicharAt(aDest,theIndex);
if(aIgnoreCase)
theChar=nsCRT::ToUpper(theChar);
if(theChar==theCmpChar)
return theIndex;
PRUnichar* theBuf=(PRUnichar*)aDest;
if(aIgnoreCase) {
PRUnichar theChar=nsCRT::ToUpper(aChar);
for(theIndex=(PRInt32)anOffset;theIndex>=0;theIndex--){
if(nsCRT::ToUpper(theBuf[theIndex])==theChar)
return theIndex;
}
}
else {
for(theIndex=(PRInt32)anOffset;theIndex>=0;theIndex--){
if(theBuf[theIndex]==aChar)
return theIndex;
}
}
return kNotFound;
}

View File

@ -651,7 +651,7 @@ PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnor
if(0<aDest.mLength) {
while(--index>=0) {
PRUnichar theChar=GetCharAt(aDest,index);
thePos=gRFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
if(kNotFound!=thePos)
return index;
} //while
@ -691,7 +691,7 @@ PRInt32 nsStr::Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PR
//----------------------------------------------------------------------------------------
CSharedStrBuffer::CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
CBufDescriptor::CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
mBuffer=aString;
mCharSize=eOneByte;
mStackBased=aStackBased;
@ -704,7 +704,7 @@ CSharedStrBuffer::CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCa
}
}
CSharedStrBuffer::CSharedStrBuffer(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
CBufDescriptor::CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
mBuffer=(char*)aString;
mCharSize=eTwoByte;
mStackBased=aStackBased;

View File

@ -43,7 +43,7 @@
#define _nsStr
#include "nscore.h"
#include "nsCppSharedAllocator.h"
#include "nsIAllocator.h"
//----------------------------------------------------------------------------------------
@ -60,10 +60,10 @@ class nsIMemoryAgent;
//----------------------------------------------------------------------------------------
class NS_COM CSharedStrBuffer {
class NS_COM CBufDescriptor {
public:
CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
CSharedStrBuffer(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
char* mBuffer;
eCharSize mCharSize;
@ -311,11 +311,8 @@ public:
}
aDest.mCapacity=theNewCapacity++;
size_t theSize=(theNewCapacity<<aDest.mCharSize);
// aDest.mStr=new char[theSize];
nsCppSharedAllocator<char> shared_allocator;
aDest.mStr = shared_allocator.allocate(theSize);
PRUint32 theSize=(theNewCapacity<<aDest.mCharSize);
aDest.mStr = (char*)nsAllocator::Alloc(theSize);
aDest.mOwnsBuffer=1;
return PR_TRUE;
@ -324,9 +321,7 @@ public:
virtual PRBool Free(nsStr& aDest){
if(aDest.mStr){
if(aDest.mOwnsBuffer){
// delete [] aDest.mStr;
nsCppSharedAllocator<char> shared_allocator;
shared_allocator.deallocate(aDest.mStr, aDest.mCapacity);
nsAllocator::Free(aDest.mStr);
}
aDest.mStr=0;
aDest.mOwnsBuffer=0;

View File

@ -651,7 +651,7 @@ PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnor
if(0<aDest.mLength) {
while(--index>=0) {
PRUnichar theChar=GetCharAt(aDest,index);
thePos=gRFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
if(kNotFound!=thePos)
return index;
} //while
@ -691,7 +691,7 @@ PRInt32 nsStr::Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PR
//----------------------------------------------------------------------------------------
CSharedStrBuffer::CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
CBufDescriptor::CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
mBuffer=aString;
mCharSize=eOneByte;
mStackBased=aStackBased;
@ -704,7 +704,7 @@ CSharedStrBuffer::CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCa
}
}
CSharedStrBuffer::CSharedStrBuffer(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
CBufDescriptor::CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
mBuffer=(char*)aString;
mCharSize=eTwoByte;
mStackBased=aStackBased;

View File

@ -43,7 +43,7 @@
#define _nsStr
#include "nscore.h"
#include "nsCppSharedAllocator.h"
#include "nsIAllocator.h"
//----------------------------------------------------------------------------------------
@ -60,10 +60,10 @@ class nsIMemoryAgent;
//----------------------------------------------------------------------------------------
class NS_COM CSharedStrBuffer {
class NS_COM CBufDescriptor {
public:
CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
CSharedStrBuffer(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
char* mBuffer;
eCharSize mCharSize;
@ -311,11 +311,8 @@ public:
}
aDest.mCapacity=theNewCapacity++;
size_t theSize=(theNewCapacity<<aDest.mCharSize);
// aDest.mStr=new char[theSize];
nsCppSharedAllocator<char> shared_allocator;
aDest.mStr = shared_allocator.allocate(theSize);
PRUint32 theSize=(theNewCapacity<<aDest.mCharSize);
aDest.mStr = (char*)nsAllocator::Alloc(theSize);
aDest.mOwnsBuffer=1;
return PR_TRUE;
@ -324,9 +321,7 @@ public:
virtual PRBool Free(nsStr& aDest){
if(aDest.mStr){
if(aDest.mOwnsBuffer){
// delete [] aDest.mStr;
nsCppSharedAllocator<char> shared_allocator;
shared_allocator.deallocate(aDest.mStr, aDest.mCapacity);
nsAllocator::Free(aDest.mStr);
}
aDest.mStr=0;
aDest.mOwnsBuffer=0;