зеркало из https://github.com/mozilla/gecko-dev.git
Fixed some sign extension bugs
This commit is contained in:
Родитель
bc3dc4eb39
Коммит
001700f459
|
@ -633,8 +633,11 @@ nsString& nsString::SetString(const char* anISOLatin1,PRInt32 aLength) {
|
||||||
PRInt32 len=(aLength<0) ? nsCRT::strlen(anISOLatin1) : aLength;
|
PRInt32 len=(aLength<0) ? nsCRT::strlen(anISOLatin1) : aLength;
|
||||||
if(mCapacity<=len)
|
if(mCapacity<=len)
|
||||||
EnsureCapacityFor(len);
|
EnsureCapacityFor(len);
|
||||||
for(int i=0;i<len;i++) {
|
const unsigned char* from = (const unsigned char*) anISOLatin1;
|
||||||
mStr[i]=chartype(anISOLatin1[i]);
|
const unsigned char* end = from + len;
|
||||||
|
PRUnichar* dst = mStr;
|
||||||
|
while (from < end) {
|
||||||
|
*dst++ = PRUnichar(*from++);
|
||||||
}
|
}
|
||||||
mLength=len;
|
mLength=len;
|
||||||
mStr[mLength]=0;
|
mStr[mLength]=0;
|
||||||
|
@ -725,8 +728,11 @@ nsString& nsString::Append(const char* anISOLatin1,PRInt32 aLength) {
|
||||||
if(mLength+len >= mCapacity) {
|
if(mLength+len >= mCapacity) {
|
||||||
EnsureCapacityFor(mLength+len);
|
EnsureCapacityFor(mLength+len);
|
||||||
}
|
}
|
||||||
for(int i=0;i<len;i++) {
|
const unsigned char* from = (const unsigned char*) anISOLatin1;
|
||||||
mStr[mLength+i]=chartype(anISOLatin1[i]);
|
const unsigned char* end = from + len;
|
||||||
|
PRUnichar* to = mStr + mLength;
|
||||||
|
while (from < end) {
|
||||||
|
*to++ = PRUnichar(*from++);
|
||||||
}
|
}
|
||||||
mLength+=len;
|
mLength+=len;
|
||||||
mStr[mLength]=0;
|
mStr[mLength]=0;
|
||||||
|
@ -1113,8 +1119,8 @@ PRBool nsString::IsSpace(PRUnichar aChar) {
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
nsString& nsString::Trim(const char* aTrimSet,
|
nsString& nsString::Trim(const char* aTrimSet,
|
||||||
PRBool aEliminateLeading,
|
PRBool aEliminateLeading,
|
||||||
PRBool aEliminateTrailing)
|
PRBool aEliminateTrailing)
|
||||||
{
|
{
|
||||||
PRUnichar* from = mStr;
|
PRUnichar* from = mStr;
|
||||||
PRUnichar* end = mStr + mLength-1;
|
PRUnichar* end = mStr + mLength-1;
|
||||||
|
|
|
@ -633,8 +633,11 @@ nsString& nsString::SetString(const char* anISOLatin1,PRInt32 aLength) {
|
||||||
PRInt32 len=(aLength<0) ? nsCRT::strlen(anISOLatin1) : aLength;
|
PRInt32 len=(aLength<0) ? nsCRT::strlen(anISOLatin1) : aLength;
|
||||||
if(mCapacity<=len)
|
if(mCapacity<=len)
|
||||||
EnsureCapacityFor(len);
|
EnsureCapacityFor(len);
|
||||||
for(int i=0;i<len;i++) {
|
const unsigned char* from = (const unsigned char*) anISOLatin1;
|
||||||
mStr[i]=chartype(anISOLatin1[i]);
|
const unsigned char* end = from + len;
|
||||||
|
PRUnichar* dst = mStr;
|
||||||
|
while (from < end) {
|
||||||
|
*dst++ = PRUnichar(*from++);
|
||||||
}
|
}
|
||||||
mLength=len;
|
mLength=len;
|
||||||
mStr[mLength]=0;
|
mStr[mLength]=0;
|
||||||
|
@ -725,8 +728,11 @@ nsString& nsString::Append(const char* anISOLatin1,PRInt32 aLength) {
|
||||||
if(mLength+len >= mCapacity) {
|
if(mLength+len >= mCapacity) {
|
||||||
EnsureCapacityFor(mLength+len);
|
EnsureCapacityFor(mLength+len);
|
||||||
}
|
}
|
||||||
for(int i=0;i<len;i++) {
|
const unsigned char* from = (const unsigned char*) anISOLatin1;
|
||||||
mStr[mLength+i]=chartype(anISOLatin1[i]);
|
const unsigned char* end = from + len;
|
||||||
|
PRUnichar* to = mStr + mLength;
|
||||||
|
while (from < end) {
|
||||||
|
*to++ = PRUnichar(*from++);
|
||||||
}
|
}
|
||||||
mLength+=len;
|
mLength+=len;
|
||||||
mStr[mLength]=0;
|
mStr[mLength]=0;
|
||||||
|
@ -1113,8 +1119,8 @@ PRBool nsString::IsSpace(PRUnichar aChar) {
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
nsString& nsString::Trim(const char* aTrimSet,
|
nsString& nsString::Trim(const char* aTrimSet,
|
||||||
PRBool aEliminateLeading,
|
PRBool aEliminateLeading,
|
||||||
PRBool aEliminateTrailing)
|
PRBool aEliminateTrailing)
|
||||||
{
|
{
|
||||||
PRUnichar* from = mStr;
|
PRUnichar* from = mStr;
|
||||||
PRUnichar* end = mStr + mLength-1;
|
PRUnichar* end = mStr + mLength-1;
|
||||||
|
|
|
@ -633,8 +633,11 @@ nsString& nsString::SetString(const char* anISOLatin1,PRInt32 aLength) {
|
||||||
PRInt32 len=(aLength<0) ? nsCRT::strlen(anISOLatin1) : aLength;
|
PRInt32 len=(aLength<0) ? nsCRT::strlen(anISOLatin1) : aLength;
|
||||||
if(mCapacity<=len)
|
if(mCapacity<=len)
|
||||||
EnsureCapacityFor(len);
|
EnsureCapacityFor(len);
|
||||||
for(int i=0;i<len;i++) {
|
const unsigned char* from = (const unsigned char*) anISOLatin1;
|
||||||
mStr[i]=chartype(anISOLatin1[i]);
|
const unsigned char* end = from + len;
|
||||||
|
PRUnichar* dst = mStr;
|
||||||
|
while (from < end) {
|
||||||
|
*dst++ = PRUnichar(*from++);
|
||||||
}
|
}
|
||||||
mLength=len;
|
mLength=len;
|
||||||
mStr[mLength]=0;
|
mStr[mLength]=0;
|
||||||
|
@ -725,8 +728,11 @@ nsString& nsString::Append(const char* anISOLatin1,PRInt32 aLength) {
|
||||||
if(mLength+len >= mCapacity) {
|
if(mLength+len >= mCapacity) {
|
||||||
EnsureCapacityFor(mLength+len);
|
EnsureCapacityFor(mLength+len);
|
||||||
}
|
}
|
||||||
for(int i=0;i<len;i++) {
|
const unsigned char* from = (const unsigned char*) anISOLatin1;
|
||||||
mStr[mLength+i]=chartype(anISOLatin1[i]);
|
const unsigned char* end = from + len;
|
||||||
|
PRUnichar* to = mStr + mLength;
|
||||||
|
while (from < end) {
|
||||||
|
*to++ = PRUnichar(*from++);
|
||||||
}
|
}
|
||||||
mLength+=len;
|
mLength+=len;
|
||||||
mStr[mLength]=0;
|
mStr[mLength]=0;
|
||||||
|
@ -1113,8 +1119,8 @@ PRBool nsString::IsSpace(PRUnichar aChar) {
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
nsString& nsString::Trim(const char* aTrimSet,
|
nsString& nsString::Trim(const char* aTrimSet,
|
||||||
PRBool aEliminateLeading,
|
PRBool aEliminateLeading,
|
||||||
PRBool aEliminateTrailing)
|
PRBool aEliminateTrailing)
|
||||||
{
|
{
|
||||||
PRUnichar* from = mStr;
|
PRUnichar* from = mStr;
|
||||||
PRUnichar* end = mStr + mLength-1;
|
PRUnichar* end = mStr + mLength-1;
|
||||||
|
|
|
@ -633,8 +633,11 @@ nsString& nsString::SetString(const char* anISOLatin1,PRInt32 aLength) {
|
||||||
PRInt32 len=(aLength<0) ? nsCRT::strlen(anISOLatin1) : aLength;
|
PRInt32 len=(aLength<0) ? nsCRT::strlen(anISOLatin1) : aLength;
|
||||||
if(mCapacity<=len)
|
if(mCapacity<=len)
|
||||||
EnsureCapacityFor(len);
|
EnsureCapacityFor(len);
|
||||||
for(int i=0;i<len;i++) {
|
const unsigned char* from = (const unsigned char*) anISOLatin1;
|
||||||
mStr[i]=chartype(anISOLatin1[i]);
|
const unsigned char* end = from + len;
|
||||||
|
PRUnichar* dst = mStr;
|
||||||
|
while (from < end) {
|
||||||
|
*dst++ = PRUnichar(*from++);
|
||||||
}
|
}
|
||||||
mLength=len;
|
mLength=len;
|
||||||
mStr[mLength]=0;
|
mStr[mLength]=0;
|
||||||
|
@ -725,8 +728,11 @@ nsString& nsString::Append(const char* anISOLatin1,PRInt32 aLength) {
|
||||||
if(mLength+len >= mCapacity) {
|
if(mLength+len >= mCapacity) {
|
||||||
EnsureCapacityFor(mLength+len);
|
EnsureCapacityFor(mLength+len);
|
||||||
}
|
}
|
||||||
for(int i=0;i<len;i++) {
|
const unsigned char* from = (const unsigned char*) anISOLatin1;
|
||||||
mStr[mLength+i]=chartype(anISOLatin1[i]);
|
const unsigned char* end = from + len;
|
||||||
|
PRUnichar* to = mStr + mLength;
|
||||||
|
while (from < end) {
|
||||||
|
*to++ = PRUnichar(*from++);
|
||||||
}
|
}
|
||||||
mLength+=len;
|
mLength+=len;
|
||||||
mStr[mLength]=0;
|
mStr[mLength]=0;
|
||||||
|
@ -1113,8 +1119,8 @@ PRBool nsString::IsSpace(PRUnichar aChar) {
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
nsString& nsString::Trim(const char* aTrimSet,
|
nsString& nsString::Trim(const char* aTrimSet,
|
||||||
PRBool aEliminateLeading,
|
PRBool aEliminateLeading,
|
||||||
PRBool aEliminateTrailing)
|
PRBool aEliminateTrailing)
|
||||||
{
|
{
|
||||||
PRUnichar* from = mStr;
|
PRUnichar* from = mStr;
|
||||||
PRUnichar* end = mStr + mLength-1;
|
PRUnichar* end = mStr + mLength-1;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче