Bug 96710: Misuse of string.Mid() - uses should be string.Right().

r=kin, sr=jst
This commit is contained in:
rjesup%wgate.com 2001-09-06 19:38:20 +00:00
Родитель e245ea9fe9
Коммит f8b915228e
12 изменённых файлов: 15 добавлений и 15 удалений

Просмотреть файл

@ -3129,7 +3129,7 @@ nsGenericHTMLElement::ParseStyleAttribute(const nsAReadableString& aValue, nsHTM
PRInt32 charsetOffset = styleType.Find(charsetStr, PR_TRUE); PRInt32 charsetOffset = styleType.Find(charsetStr, PR_TRUE);
if (charsetOffset > 0) { if (charsetOffset > 0) {
nsString charset; nsString charset;
styleType.Mid(charset, charsetOffset + sizeof(charsetStr) - 1, -1); styleType.Right(charset, charsetOffset + sizeof(charsetStr) - 1);
(void)cssLoader->SetCharset(charset); (void)cssLoader->SetCharset(charset);
} }
} }

Просмотреть файл

@ -1659,7 +1659,7 @@ nsresult CSSLoaderImpl::SetCharset(/*in*/ const nsString &aHTTPHeader,
PRInt32 charsetOffset; PRInt32 charsetOffset;
static const char charsetStr[] = "charset="; static const char charsetStr[] = "charset=";
if ((charsetOffset = aHTTPHeader.Find(charsetStr,PR_TRUE)) > 0) { if ((charsetOffset = aHTTPHeader.Find(charsetStr,PR_TRUE)) > 0) {
aHTTPHeader.Mid(str, charsetOffset + sizeof(charsetStr)-1, -1); aHTTPHeader.Right(str, charsetOffset + sizeof(charsetStr)-1);
setCharset = PR_TRUE; setCharset = PR_TRUE;
} }
} else if (aStyleSheetData.Length() > 0) { } else if (aStyleSheetData.Length() > 0) {
@ -1667,7 +1667,7 @@ nsresult CSSLoaderImpl::SetCharset(/*in*/ const nsString &aHTTPHeader,
if (aStyleSheetData.Find(atCharsetStr) > -1) { if (aStyleSheetData.Find(atCharsetStr) > -1) {
nsString strValue; nsString strValue;
// skip past the ident // skip past the ident
aStyleSheetData.Mid(str,sizeof(atCharsetStr)-1,-1); aStyleSheetData.Right(str,sizeof(atCharsetStr)-1);
// strip any whitespace // strip any whitespace
str.StripWhitespace(); str.StripWhitespace();
// truncate everything past the delimiter (semicolon) // truncate everything past the delimiter (semicolon)

Просмотреть файл

@ -1659,7 +1659,7 @@ nsresult CSSLoaderImpl::SetCharset(/*in*/ const nsString &aHTTPHeader,
PRInt32 charsetOffset; PRInt32 charsetOffset;
static const char charsetStr[] = "charset="; static const char charsetStr[] = "charset=";
if ((charsetOffset = aHTTPHeader.Find(charsetStr,PR_TRUE)) > 0) { if ((charsetOffset = aHTTPHeader.Find(charsetStr,PR_TRUE)) > 0) {
aHTTPHeader.Mid(str, charsetOffset + sizeof(charsetStr)-1, -1); aHTTPHeader.Right(str, charsetOffset + sizeof(charsetStr)-1);
setCharset = PR_TRUE; setCharset = PR_TRUE;
} }
} else if (aStyleSheetData.Length() > 0) { } else if (aStyleSheetData.Length() > 0) {
@ -1667,7 +1667,7 @@ nsresult CSSLoaderImpl::SetCharset(/*in*/ const nsString &aHTTPHeader,
if (aStyleSheetData.Find(atCharsetStr) > -1) { if (aStyleSheetData.Find(atCharsetStr) > -1) {
nsString strValue; nsString strValue;
// skip past the ident // skip past the ident
aStyleSheetData.Mid(str,sizeof(atCharsetStr)-1,-1); aStyleSheetData.Right(str,sizeof(atCharsetStr)-1);
// strip any whitespace // strip any whitespace
str.StripWhitespace(); str.StripWhitespace();
// truncate everything past the delimiter (semicolon) // truncate everything past the delimiter (semicolon)

Просмотреть файл

@ -207,7 +207,7 @@ nsresult nsAddbookUrl::ParseUrl()
if (startOfSearchPart > 0) if (startOfSearchPart > 0)
{ {
// now parse out the search field... // now parse out the search field...
PRUint32 numExtraChars = mOperationPart.Mid(searchPart, startOfSearchPart, -1); PRUint32 numExtraChars = mOperationPart.Right(searchPart, startOfSearchPart);
if (!searchPart.IsEmpty()) if (!searchPart.IsEmpty())
{ {
// now we need to strip off the search part from the // now we need to strip off the search part from the

Просмотреть файл

@ -604,7 +604,7 @@ NS_IMETHODIMP nsMsgMailNewsUrl::GetFileExtension(char * *aFileExtension)
nsCAutoString extension; nsCAutoString extension;
PRInt32 pos = mAttachmentFileName.RFindCharInSet("."); PRInt32 pos = mAttachmentFileName.RFindCharInSet(".");
if (pos > 0) if (pos > 0)
mAttachmentFileName.Mid(extension, pos + 1 /* skip the '.' */, -1); mAttachmentFileName.Right(extension, pos + 1 /* skip the '.' */);
*aFileExtension = extension.ToNewCString(); *aFileExtension = extension.ToNewCString();
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -233,7 +233,7 @@ nsresult nsMailtoUrl::ParseUrl()
{ {
// now parse out the search field... // now parse out the search field...
nsCAutoString searchPart; nsCAutoString searchPart;
PRUint32 numExtraChars = m_toPart.Mid(searchPart, startOfSearchPart, -1); PRUint32 numExtraChars = m_toPart.Right(searchPart, startOfSearchPart);
if (!searchPart.IsEmpty()) if (!searchPart.IsEmpty())
{ {
ParseMailtoUrl(NS_CONST_CAST(char*, searchPart.get())); ParseMailtoUrl(NS_CONST_CAST(char*, searchPart.get()));

Просмотреть файл

@ -59,7 +59,7 @@ nsAboutBloat::NewChannel(nsIURI *aURI, nsIChannel **result)
PRInt32 pos = p.Find("?"); PRInt32 pos = p.Find("?");
if (pos > 0) { if (pos > 0) {
nsCAutoString param; nsCAutoString param;
(void)p.Mid(param, pos+1, -1); (void)p.Right(param, pos+1);
if (param.Equals("new")) if (param.Equals("new"))
statType = nsTraceRefcnt::NEW_STATS; statType = nsTraceRefcnt::NEW_STATS;
else if (param.Equals("clear")) else if (param.Equals("clear"))

Просмотреть файл

@ -74,7 +74,7 @@ nsAboutCache::NewChannel(nsIURI *aURI, nsIChannel **result)
PRInt32 pos = p.Find("?"); PRInt32 pos = p.Find("?");
if (pos > 0) { if (pos > 0) {
nsCAutoString param; nsCAutoString param;
(void)p.Mid(param, pos+1, -1); (void)p.Right(param, pos+1);
if (param.Equals("new")) if (param.Equals("new"))
statType = nsTraceRefcnt::NEW_STATS; statType = nsTraceRefcnt::NEW_STATS;
else if (param.Equals("clear")) else if (param.Equals("clear"))

Просмотреть файл

@ -723,7 +723,7 @@ void nsExternalAppHandler::ExtractSuggestedFileNameFromChannel(nsIChannel* aChan
{ {
// extract everything after the filename= part and treat that as the file name... // extract everything after the filename= part and treat that as the file name...
nsCAutoString dispFileName; nsCAutoString dispFileName;
dispositionValue.Mid(dispFileName, pos + nsCRT::strlen("filename="), -1); dispositionValue.Right(dispFileName, pos + nsCRT::strlen("filename="));
if (!dispFileName.IsEmpty()) // if we got a file name back.. if (!dispFileName.IsEmpty()) // if we got a file name back..
{ {
pos = dispFileName.FindChar(';', PR_TRUE); pos = dispFileName.FindChar(';', PR_TRUE);
@ -1156,7 +1156,7 @@ NS_IMETHODIMP nsExternalAppHandler::SaveToDisk(nsIFile * aNewFileLocation, PRBoo
nsAutoString fileExt; nsAutoString fileExt;
PRInt32 pos = mSuggestedFileName.RFindChar(PRUnichar('.')); PRInt32 pos = mSuggestedFileName.RFindChar(PRUnichar('.'));
if (pos >= 0) if (pos >= 0)
mSuggestedFileName.Mid(fileExt, pos, -1); mSuggestedFileName.Right(fileExt, pos);
if (fileExt.IsEmpty()) if (fileExt.IsEmpty())
fileExt = NS_ConvertASCIItoUCS2(mTempFileExtension).get(); fileExt = NS_ConvertASCIItoUCS2(mTempFileExtension).get();

Просмотреть файл

@ -167,7 +167,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval)
PRInt32 extIndex = mDefault.RFind("."); PRInt32 extIndex = mDefault.RFind(".");
if ( extIndex >= 0) { if ( extIndex >= 0) {
nsAutoString ext; nsAutoString ext;
mDefault.Mid(ext, extIndex, -1); mDefault.Right(ext, extIndex);
// Should we test for ".cgi", ".asp", ".jsp" and other "generated" html pages? // Should we test for ".cgi", ".asp", ".jsp" and other "generated" html pages?
if ( ext.EqualsIgnoreCase(".htm") || if ( ext.EqualsIgnoreCase(".htm") ||
ext.EqualsIgnoreCase(".html") || ext.EqualsIgnoreCase(".html") ||

Просмотреть файл

@ -580,7 +580,7 @@ nsInstall::AddSubcomponent(const nsString& aRegName,
if ( pos == kNotFound ) if ( pos == kNotFound )
tempTargetName = aJarSource; tempTargetName = aJarSource;
else else
aJarSource.Mid(tempTargetName, pos+1, -1); aJarSource.Right(tempTargetName, pos+1);
} }
if (qualifiedVersion.IsEmpty()) if (qualifiedVersion.IsEmpty())

Просмотреть файл

@ -554,7 +554,7 @@ nsInstallFolder::AppendXPPath(const nsString& aRelativePath)
else if ( curr == kNotFound ) else if ( curr == kNotFound )
{ {
// last segment // last segment
aRelativePath.Mid(segment,start,-1); aRelativePath.Right(segment,start);
start = aRelativePath.Length(); start = aRelativePath.Length();
} }
else else