зеркало из https://github.com/mozilla/pjs.git
a further nsString api reduction: remove the last case-insensitive PRUnichar*-to-PRUnichar* comparisons, moving to new API, and remove old methods from nsString. r=dougt, sr=jag a=scc
This commit is contained in:
Родитель
579ca31d56
Коммит
ecdb77e394
|
@ -310,7 +310,7 @@ nsresult nsCopySupport::IsPlainTextContext(nsISelection *aSel, nsIDocument *aDoc
|
|||
nsCOMPtr<nsIDOMElement> bodyElem = do_QueryInterface(selContent);
|
||||
nsAutoString wsVal;
|
||||
rv = bodyElem->GetAttribute(NS_LITERAL_STRING("style"), wsVal);
|
||||
if (NS_SUCCEEDED(rv) && (kNotFound != wsVal.Find(NS_LITERAL_STRING("-moz-pre-wrap").get())))
|
||||
if (NS_SUCCEEDED(rv) && (kNotFound != wsVal.Find(NS_LITERAL_STRING("-moz-pre-wrap"))))
|
||||
{
|
||||
*aIsPlainTextContext = PR_TRUE;
|
||||
break;
|
||||
|
|
|
@ -1144,7 +1144,7 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
|
|||
nsCOMPtr<nsIDOMElement> bodyElem = do_QueryInterface(selContent);
|
||||
nsAutoString wsVal;
|
||||
rv = bodyElem->GetAttribute(NS_LITERAL_STRING("style"), wsVal);
|
||||
if (NS_SUCCEEDED(rv) && (kNotFound != wsVal.Find(NS_LITERAL_STRING("-moz-pre-wrap").get())))
|
||||
if (NS_SUCCEEDED(rv) && (kNotFound != wsVal.Find(NS_LITERAL_STRING("-moz-pre-wrap"))))
|
||||
{
|
||||
mIsTextWidget = PR_TRUE;
|
||||
break;
|
||||
|
|
|
@ -75,7 +75,7 @@ nsParserUtils::GetQuotedAttributeValue(nsString& aSource,
|
|||
// While there are more characters to look at
|
||||
while (startOfAttribute != -1) {
|
||||
// Find the attribute starting at offset
|
||||
startOfAttribute = aSource.Find(aAttribute.get(), PR_FALSE, startOfAttribute);
|
||||
startOfAttribute = aSource.Find(aAttribute, startOfAttribute);
|
||||
// If attribute found
|
||||
if (startOfAttribute != -1) {
|
||||
// Find the '=' character while skipping whitespace
|
||||
|
|
|
@ -748,7 +748,8 @@ nsPlainTextSerializer::DoOpenContainer(PRInt32 aTag)
|
|||
nsAutoString value;
|
||||
nsresult rv = GetAttributeValue(nsHTMLAtoms::type, value);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && value.EqualsIgnoreCase("cite")) {
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
NS_LossyConvertUCS2toASCII(value).Equals("cite", nsCaseInsensitiveCStringComparator())) {
|
||||
mCiteQuoteLevel++;
|
||||
}
|
||||
else {
|
||||
|
@ -905,7 +906,8 @@ nsPlainTextSerializer::DoCloseContainer(PRInt32 aTag)
|
|||
nsAutoString value;
|
||||
nsresult rv = GetAttributeValue(nsHTMLAtoms::type, value);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && value.EqualsIgnoreCase("cite")) {
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
NS_LossyConvertUCS2toASCII(value).Equals("cite", nsCaseInsensitiveCStringComparator())) {
|
||||
mCiteQuoteLevel--;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -3681,7 +3681,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
|||
result = PRBool(localTrue == value.Equals(attr->mValue));
|
||||
}
|
||||
else {
|
||||
result = PRBool(localTrue == value.EqualsIgnoreCase(attr->mValue));
|
||||
result = PRBool(localTrue == value.Equals(attr->mValue, nsCaseInsensitiveStringComparator()));
|
||||
}
|
||||
break;
|
||||
case NS_ATTR_FUNC_INCLUDES:
|
||||
|
@ -3738,7 +3738,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
|||
}
|
||||
break;
|
||||
case NS_ATTR_FUNC_CONTAINSMATCH:
|
||||
result = PRBool(localTrue == (-1 != value.Find(attr->mValue, isCaseSensitive)));
|
||||
result = PRBool(localTrue == (FindInReadable(attr->mValue, value, nsCaseInsensitiveStringComparator())));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1387,7 +1387,7 @@ nsXBLBinding::IsInExcludesList(nsIAtom* aTag, const nsString& aList)
|
|||
if (aList == NS_LITERAL_STRING("*"))
|
||||
return PR_TRUE; // match _everything_!
|
||||
|
||||
PRInt32 indx = aList.Find(element);
|
||||
PRInt32 indx = aList.Find(element, 0);
|
||||
if (indx == -1)
|
||||
return PR_FALSE; // not in the list at all
|
||||
|
||||
|
|
|
@ -367,6 +367,10 @@ nsXMLElement::MaybeTriggerAutoLink(nsIWebShell *aShell)
|
|||
nsresult rv = NS_OK;
|
||||
|
||||
if (mIsLink) {
|
||||
// preload and precalculate length of atom outside of loop
|
||||
const PRUnichar *onloadUnicode;
|
||||
kOnLoadAtom->GetUnicode(&onloadUnicode);
|
||||
nsDependentString onloadString(onloadUnicode);
|
||||
do {
|
||||
// actuate="onLoad" ?
|
||||
nsAutoString value;
|
||||
|
@ -374,7 +378,7 @@ nsXMLElement::MaybeTriggerAutoLink(nsIWebShell *aShell)
|
|||
kActuateAtom,
|
||||
value);
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE &&
|
||||
value.EqualsAtom(kOnLoadAtom, PR_FALSE)) {
|
||||
value.Equals(onloadString)) {
|
||||
|
||||
// show= ?
|
||||
nsLinkVerb verb = eLinkVerb_Undefined;
|
||||
|
|
|
@ -390,7 +390,7 @@ nsXULCommandDispatcher::Matches(const nsString& aList,
|
|||
if (aList.Equals(NS_LITERAL_STRING("*")))
|
||||
return PR_TRUE; // match _everything_!
|
||||
|
||||
PRInt32 indx = aList.Find((const PRUnichar *)PromiseFlatString(aElement).get());
|
||||
PRInt32 indx = aList.Find(PromiseFlatString(aElement));
|
||||
if (indx == -1)
|
||||
return PR_FALSE; // not in the list at all
|
||||
|
||||
|
|
|
@ -6374,7 +6374,7 @@ nsXULDocument::CheckTemplateBuilder(nsIContent* aElement)
|
|||
if ((nameSpaceID == kNameSpaceID_XUL) && (baseTag == nsXULAtoms::outliner)) {
|
||||
nsAutoString flags;
|
||||
aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::flags, flags);
|
||||
if (flags.Find(NS_LITERAL_STRING("dont-build-content").get()) >= 0) {
|
||||
if (flags.Find(NS_LITERAL_STRING("dont-build-content")) >= 0) {
|
||||
nsCOMPtr<nsIXULTemplateBuilder> builder =
|
||||
do_CreateInstance("@mozilla.org/xul/xul-outliner-builder;1");
|
||||
|
||||
|
|
|
@ -1482,7 +1482,7 @@ nsXULTemplateBuilder::InitializeRuleNetwork()
|
|||
nsAutoString flags;
|
||||
mRoot->GetAttr(kNameSpaceID_None, nsXULAtoms::flags, flags);
|
||||
|
||||
if (flags.Find(NS_LITERAL_STRING("dont-test-empty").get()) >= 0)
|
||||
if (flags.Find(NS_LITERAL_STRING("dont-test-empty")) >= 0)
|
||||
mFlags |= eDontTestEmpty;
|
||||
|
||||
// Initialize the rule network
|
||||
|
|
|
@ -99,6 +99,7 @@
|
|||
#include "nsIPref.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
#include "nsAOLCiter.h"
|
||||
#include "nsInternetCiter.h"
|
||||
|
@ -262,7 +263,6 @@ nsPlaintextEditor::SetDocumentCharacterSet(const nsAReadableString & characterSe
|
|||
nsCOMPtr<nsIDOMDocument>domdoc;
|
||||
result = GetDocument(getter_AddRefs(domdoc));
|
||||
if (NS_SUCCEEDED(result) && domdoc) {
|
||||
nsAutoString newMetaString;
|
||||
nsCOMPtr<nsIDOMNodeList>metaList;
|
||||
nsCOMPtr<nsIDOMNode>metaNode;
|
||||
nsCOMPtr<nsIDOMElement>metaElement;
|
||||
|
@ -280,20 +280,26 @@ nsPlaintextEditor::SetDocumentCharacterSet(const nsAReadableString & characterSe
|
|||
metaElement = do_QueryInterface(metaNode);
|
||||
if (!metaElement) continue;
|
||||
|
||||
nsString currentValue;
|
||||
nsAutoString currentValue;
|
||||
if (NS_FAILED(metaElement->GetAttribute(NS_LITERAL_STRING("http-equiv"), currentValue))) continue;
|
||||
|
||||
if (kNotFound != currentValue.Find("content-type", PR_TRUE)) {
|
||||
if (FindInReadable(NS_LITERAL_STRING("content-type"),
|
||||
currentValue,
|
||||
nsCaseInsensitiveStringComparator())) {
|
||||
NS_NAMED_LITERAL_STRING(content, "content");
|
||||
if (NS_FAILED(metaElement->GetAttribute(content, currentValue))) continue;
|
||||
|
||||
NS_NAMED_LITERAL_STRING(charset, "charset=");
|
||||
PRInt32 offset = currentValue.Find(charset.get(), PR_TRUE);
|
||||
if (kNotFound != offset) {
|
||||
currentValue.Left(newMetaString, offset); // copy current value before "charset=" (e.g. text/html)
|
||||
newMetaString.Append(charset);
|
||||
newMetaString.Append(characterSet);
|
||||
result = nsEditor::SetAttribute(metaElement, content, newMetaString);
|
||||
NS_NAMED_LITERAL_STRING(charsetEquals, "charset=");
|
||||
nsAString::const_iterator originalStart, start, end;
|
||||
currentValue.BeginReading(start);
|
||||
currentValue.EndReading(end);
|
||||
if (FindInReadable(charsetEquals, start, end,
|
||||
nsCaseInsensitiveStringComparator())) {
|
||||
|
||||
// set attribute to <original prefix> charset=text/html
|
||||
result = nsEditor::SetAttribute(metaElement, content,
|
||||
Substring(originalStart, start) +
|
||||
charsetEquals + characterSet);
|
||||
if (NS_SUCCEEDED(result))
|
||||
newMetaCharset = PR_FALSE;
|
||||
break;
|
||||
|
@ -322,10 +328,9 @@ nsPlaintextEditor::SetDocumentCharacterSet(const nsAReadableString & characterSe
|
|||
// not undoable, undo should undo CreateNode
|
||||
result = metaElement->SetAttribute(NS_LITERAL_STRING("http-equiv"), NS_LITERAL_STRING("Content-Type"));
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
newMetaString.Assign(NS_LITERAL_STRING("text/html;charset="));
|
||||
newMetaString.Append(characterSet);
|
||||
// not undoable, undo should undo CreateNode
|
||||
result = metaElement->SetAttribute(NS_LITERAL_STRING("content"), newMetaString);
|
||||
result = metaElement->SetAttribute(NS_LITERAL_STRING("content"),
|
||||
NS_LITERAL_STRING("text/html;charset=") + characterSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = embedcomponents
|
||||
MODULE = webbrowserpersist
|
||||
LIBRARY_NAME = webbrowserpersist_s
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
|
@ -36,8 +36,8 @@ REQUIRES = xpcom \
|
|||
exthandler \
|
||||
uriloader \
|
||||
mimetype \
|
||||
webbrowserpersist \
|
||||
intl \
|
||||
unicharutil \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = nsWebBrowserPersist.cpp \
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "nsIHttpChannel.h"
|
||||
#include "nsIUploadChannel.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
#include "nsCExternalHandlerService.h"
|
||||
|
||||
|
@ -1119,7 +1120,7 @@ nsWebBrowserPersist::GetDocEncoderContentType(nsIDOMDocument *aDocument, const P
|
|||
// text/plain
|
||||
|
||||
if (contentType.Length() > 0 &&
|
||||
!contentType.EqualsIgnoreCase(defaultContentType))
|
||||
!contentType.Equals(defaultContentType, nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
// Check if there is an encoder for the desired content type
|
||||
nsCAutoString contractID(NS_DOC_ENCODER_CONTRACTID_BASE);
|
||||
|
|
|
@ -523,7 +523,7 @@ PRInt32 String::indexOf(const String& data, PRInt32 offset) const
|
|||
|
||||
nsString nsStrData((PRUnichar *)data.toUnicode());
|
||||
|
||||
return ptrNSString->Find(nsStrData, PR_FALSE, searchIndex);
|
||||
return ptrNSString->Find(nsStrData, searchIndex);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -553,7 +553,7 @@ MBool String::isEqualIgnoreCase(const String& data) const
|
|||
return MB_FALSE;
|
||||
else
|
||||
{
|
||||
if (ptrNSString->EqualsIgnoreCase(data.getConstNSString()) == PR_TRUE)
|
||||
if (ptrNSString->Equals(data.getConstNSString(), nsCaseInsensitiveStringComparator()) == PR_TRUE)
|
||||
return MB_TRUE;
|
||||
else
|
||||
return MB_FALSE;
|
||||
|
@ -597,7 +597,7 @@ PRInt32 String::lastIndexOf(const String& data, PRInt32 offset) const
|
|||
{
|
||||
nsString nsData((PRUnichar *)data.toUnicode(), data.length());
|
||||
|
||||
return ptrNSString->RFind(nsData, PR_FALSE, offset);
|
||||
return ptrNSString->RFind(nsData, offset);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -113,7 +113,7 @@ nsAcceptLang::GetAcceptLangFromLocale(const PRUnichar *aLocale, PRUnichar **_ret
|
|||
|
||||
/* not in languageNames.properties; lang only?
|
||||
*/
|
||||
PRInt32 dash = lc_tmp.FindCharInSet("-");
|
||||
PRInt32 dash = lc_tmp.FindChar('-');
|
||||
nsAutoString lang;
|
||||
nsAutoString country;
|
||||
if (dash > 0) {
|
||||
|
@ -167,7 +167,7 @@ nsAcceptLang::GetLocaleFromAcceptLang(const PRUnichar *aName, PRUnichar **_retva
|
|||
|
||||
/* always return lang-country
|
||||
*/
|
||||
PRInt32 dash = acceptLang.FindCharInSet("-");
|
||||
PRInt32 dash = acceptLang.FindChar('-');
|
||||
if (dash > 0) {
|
||||
/* lang-country already */
|
||||
*_retval = ToNewUnicode(acceptLang);
|
||||
|
|
|
@ -82,7 +82,7 @@ getCountry(PRUnichar *lc_name_unichar, PRUnichar **aCountry)
|
|||
lc_name.Assign(lc_name_unichar);
|
||||
// nsMemory::Free(lc_name_unichar);
|
||||
|
||||
PRInt32 dash = lc_name.FindCharInSet("-");
|
||||
PRInt32 dash = lc_name.FindChar('-');
|
||||
if (dash > 0) {
|
||||
/*
|
||||
*/
|
||||
|
|
|
@ -68,7 +68,7 @@ nsEntityConverter::~nsEntityConverter()
|
|||
NS_IMETHODIMP
|
||||
nsEntityConverter::LoadVersionPropertyFile()
|
||||
{
|
||||
nsString aUrl(NS_LITERAL_STRING("resource:/res/entityTables/htmlEntityVersions.properties"));
|
||||
NS_NAMED_LITERAL_STRING(aUrl, "resource:/res/entityTables/htmlEntityVersions.properties");
|
||||
nsIPersistentProperties* entityProperties = NULL;
|
||||
nsIURI* url = NULL;
|
||||
nsIInputStream* in = NULL;
|
||||
|
|
|
@ -241,7 +241,9 @@ nsCaseInsensitiveStringComparator::operator()( const PRUnichar* lhs, const PRUni
|
|||
int
|
||||
nsCaseInsensitiveStringComparator::operator()( PRUnichar lhs, PRUnichar rhs ) const
|
||||
{
|
||||
// see if they're an exact match first
|
||||
if (lhs == rhs) return 0;
|
||||
|
||||
NS_InitCaseConversion();
|
||||
|
||||
gCaseConv->ToLower(lhs, &lhs);
|
||||
|
|
|
@ -310,7 +310,7 @@ nsresult nsCopySupport::IsPlainTextContext(nsISelection *aSel, nsIDocument *aDoc
|
|||
nsCOMPtr<nsIDOMElement> bodyElem = do_QueryInterface(selContent);
|
||||
nsAutoString wsVal;
|
||||
rv = bodyElem->GetAttribute(NS_LITERAL_STRING("style"), wsVal);
|
||||
if (NS_SUCCEEDED(rv) && (kNotFound != wsVal.Find(NS_LITERAL_STRING("-moz-pre-wrap").get())))
|
||||
if (NS_SUCCEEDED(rv) && (kNotFound != wsVal.Find(NS_LITERAL_STRING("-moz-pre-wrap"))))
|
||||
{
|
||||
*aIsPlainTextContext = PR_TRUE;
|
||||
break;
|
||||
|
|
|
@ -288,29 +288,21 @@ nsPageFrame::IsPercentageBase(PRBool& aBase) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// helper function for converting from char * to unichar
|
||||
static PRUnichar *
|
||||
GetUStr(const char * aCStr)
|
||||
{
|
||||
return ToNewUnicode(nsDependentCString(aCStr));
|
||||
}
|
||||
|
||||
// Remove fix below when string gets fixed
|
||||
#define WORKAROUND_FOR_BUG_110335
|
||||
// replace the &<code> with the value, but if the value is empty
|
||||
// set the string to zero length
|
||||
static void
|
||||
SubstValueForCode(nsString& aStr, PRUnichar * aUKey, PRUnichar * aUStr)
|
||||
SubstValueForCode(nsString& aStr, const PRUnichar * aUKey, const PRUnichar * aUStr)
|
||||
{
|
||||
#ifdef WORKAROUND_FOR_BUG_110335
|
||||
PRUnichar* uKeyStr = aUKey;
|
||||
const PRUnichar* uKeyStr = aUKey;
|
||||
|
||||
// Check to make sure our subst code &<code> isn't in the data string
|
||||
// for example &T for title is in QB&T
|
||||
nsAutoString dataStr(aUStr);
|
||||
nsAutoString newKey(aUKey);
|
||||
PRBool fixingSubstr = dataStr.Find(newKey) > -1;
|
||||
PRBool fixingSubstr = (dataStr.Find(newKey) != kNotFound);
|
||||
if (fixingSubstr) {
|
||||
// well, the code is in the data str so make up a new code
|
||||
// but make sure it it isn't in either substs string or the data string
|
||||
|
@ -329,14 +321,11 @@ SubstValueForCode(nsString& aStr, PRUnichar * aUKey, PRUnichar * aUStr)
|
|||
|
||||
// Ok, we have the new code, so repplace the old code
|
||||
// in the dest str with the new code
|
||||
nsAutoString oldKey(aUKey);
|
||||
aStr.ReplaceSubstring(oldKey, newKey);
|
||||
aStr.ReplaceSubstring(aUKey, newKey.get());
|
||||
uKeyStr = ToNewUnicode(newKey);
|
||||
}
|
||||
|
||||
nsAutoString str;
|
||||
str = aUStr;
|
||||
if (str.Length() == 0) {
|
||||
if (nsCRT::strlen(aUStr) == 0) {
|
||||
aStr.SetLength(0);
|
||||
} else {
|
||||
aStr.ReplaceSubstring(uKeyStr, aUStr);
|
||||
|
@ -344,12 +333,11 @@ SubstValueForCode(nsString& aStr, PRUnichar * aUKey, PRUnichar * aUStr)
|
|||
|
||||
// Free uKeyStr only if we fixed the string.
|
||||
if (fixingSubstr) {
|
||||
nsMemory::Free(uKeyStr);
|
||||
nsMemory::Free(NS_CONST_CAST(PRUnichar*, uKeyStr));
|
||||
}
|
||||
#else
|
||||
nsAutoString str;
|
||||
str = aUStr;
|
||||
if (str.Length() == 0) {
|
||||
|
||||
if (nsCRT::strlen(aUStr) == 0) {
|
||||
aStr.SetLength(0);
|
||||
} else {
|
||||
aStr.ReplaceSubstring(aUKey, aUStr);
|
||||
|
@ -368,74 +356,53 @@ nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr)
|
|||
|
||||
// Search to see if the &D code is in the string
|
||||
// then subst in the current date/time
|
||||
PRUnichar * kDate = GetUStr("&D");
|
||||
if (kDate != nsnull) {
|
||||
if (aStr.Find(kDate) > -1) {
|
||||
if (mPD->mDateTimeStr != nsnull) {
|
||||
aNewStr.ReplaceSubstring(kDate, mPD->mDateTimeStr);
|
||||
} else {
|
||||
aNewStr.ReplaceSubstring(kDate, NS_LITERAL_STRING("").get());
|
||||
}
|
||||
nsMemory::Free(kDate);
|
||||
return;
|
||||
NS_NAMED_LITERAL_STRING(kDate, "&D");
|
||||
if (aStr.Find(kDate) != kNotFound) {
|
||||
if (mPD->mDateTimeStr != nsnull) {
|
||||
aNewStr.ReplaceSubstring(kDate.get(), mPD->mDateTimeStr);
|
||||
} else {
|
||||
aNewStr.ReplaceSubstring(kDate.get(), NS_LITERAL_STRING("").get());
|
||||
}
|
||||
nsMemory::Free(kDate);
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: Must search for &PT before searching for &P
|
||||
//
|
||||
// Search to see if the "page number and page" total code are in the string
|
||||
// and replace the page number and page total code with the actual values
|
||||
PRUnichar * kPage = GetUStr("&PT");
|
||||
if (kPage != nsnull) {
|
||||
if (aStr.Find(kPage) > -1) {
|
||||
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumAndTotalsFormat, mPageNum, mTotNumPages);
|
||||
aNewStr.ReplaceSubstring(kPage, uStr);
|
||||
nsMemory::Free(uStr);
|
||||
nsMemory::Free(kPage);
|
||||
return;
|
||||
}
|
||||
nsMemory::Free(kPage);
|
||||
// and replace the page number and page total code with the actual
|
||||
// values
|
||||
NS_NAMED_LITERAL_STRING(kPageAndTotal, "&PT");
|
||||
if (aStr.Find(kPageAndTotal) != kNotFound) {
|
||||
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumAndTotalsFormat, mPageNum, mTotNumPages);
|
||||
aNewStr.ReplaceSubstring(kPageAndTotal.get(), uStr);
|
||||
nsMemory::Free(uStr);
|
||||
return;
|
||||
}
|
||||
|
||||
// Search to see if the page number code is in the string
|
||||
// and replace the page number code with the actual values
|
||||
kPage = GetUStr("&P");
|
||||
if (kPage != nsnull) {
|
||||
if (aStr.Find(kPage) > -1) {
|
||||
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumFormat, mPageNum);
|
||||
aNewStr.ReplaceSubstring(kPage, uStr);
|
||||
nsMemory::Free(uStr);
|
||||
nsMemory::Free(kPage);
|
||||
return;
|
||||
}
|
||||
nsMemory::Free(kPage);
|
||||
// and replace the page number code with the actual value
|
||||
NS_NAMED_LITERAL_STRING(kPage, "&P");
|
||||
if (aStr.Find(kPage) != kNotFound) {
|
||||
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumFormat, mPageNum);
|
||||
aNewStr.ReplaceSubstring(kPage.get(), uStr);
|
||||
nsMemory::Free(uStr);
|
||||
return;
|
||||
}
|
||||
|
||||
PRUnichar * kTitle = GetUStr("&T");
|
||||
if (kTitle != nsnull) {
|
||||
if (aStr.Find(kTitle) > -1) {
|
||||
PRUnichar * uTitle;
|
||||
mPD->mPrintOptions->GetTitle(&uTitle); // creates memory
|
||||
SubstValueForCode(aNewStr, kTitle, uTitle);
|
||||
nsMemory::Free(uTitle);
|
||||
nsMemory::Free(kTitle);
|
||||
return;
|
||||
}
|
||||
nsMemory::Free(kTitle);
|
||||
NS_NAMED_LITERAL_STRING(kTitle, "&T");
|
||||
if (aStr.Find(kTitle) != kNotFound) {
|
||||
nsXPIDLString uTitle;
|
||||
mPD->mPrintOptions->GetTitle(getter_Copies(uTitle));
|
||||
SubstValueForCode(aNewStr, kTitle.get(), uTitle.get());
|
||||
return;
|
||||
}
|
||||
|
||||
PRUnichar * kDocURL = GetUStr("&U");
|
||||
if (kDocURL != nsnull) {
|
||||
if (aStr.Find(kDocURL) > -1) {
|
||||
PRUnichar * uDocURL;
|
||||
mPD->mPrintOptions->GetDocURL(&uDocURL); // creates memory
|
||||
SubstValueForCode(aNewStr, kDocURL, uDocURL);
|
||||
nsMemory::Free(uDocURL);
|
||||
nsMemory::Free(kDocURL);
|
||||
return;
|
||||
}
|
||||
nsMemory::Free(kDocURL);
|
||||
NS_NAMED_LITERAL_STRING(kDocURL, "&U");
|
||||
if (aStr.Find(kDocURL) != kNotFound) {
|
||||
nsXPIDLString uDocURL;
|
||||
mPD->mPrintOptions->GetDocURL(getter_Copies(uDocURL));
|
||||
SubstValueForCode(aNewStr, kDocURL.get(), uDocURL.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -288,29 +288,21 @@ nsPageFrame::IsPercentageBase(PRBool& aBase) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// helper function for converting from char * to unichar
|
||||
static PRUnichar *
|
||||
GetUStr(const char * aCStr)
|
||||
{
|
||||
return ToNewUnicode(nsDependentCString(aCStr));
|
||||
}
|
||||
|
||||
// Remove fix below when string gets fixed
|
||||
#define WORKAROUND_FOR_BUG_110335
|
||||
// replace the &<code> with the value, but if the value is empty
|
||||
// set the string to zero length
|
||||
static void
|
||||
SubstValueForCode(nsString& aStr, PRUnichar * aUKey, PRUnichar * aUStr)
|
||||
SubstValueForCode(nsString& aStr, const PRUnichar * aUKey, const PRUnichar * aUStr)
|
||||
{
|
||||
#ifdef WORKAROUND_FOR_BUG_110335
|
||||
PRUnichar* uKeyStr = aUKey;
|
||||
const PRUnichar* uKeyStr = aUKey;
|
||||
|
||||
// Check to make sure our subst code &<code> isn't in the data string
|
||||
// for example &T for title is in QB&T
|
||||
nsAutoString dataStr(aUStr);
|
||||
nsAutoString newKey(aUKey);
|
||||
PRBool fixingSubstr = dataStr.Find(newKey) > -1;
|
||||
PRBool fixingSubstr = (dataStr.Find(newKey) != kNotFound);
|
||||
if (fixingSubstr) {
|
||||
// well, the code is in the data str so make up a new code
|
||||
// but make sure it it isn't in either substs string or the data string
|
||||
|
@ -329,14 +321,11 @@ SubstValueForCode(nsString& aStr, PRUnichar * aUKey, PRUnichar * aUStr)
|
|||
|
||||
// Ok, we have the new code, so repplace the old code
|
||||
// in the dest str with the new code
|
||||
nsAutoString oldKey(aUKey);
|
||||
aStr.ReplaceSubstring(oldKey, newKey);
|
||||
aStr.ReplaceSubstring(aUKey, newKey.get());
|
||||
uKeyStr = ToNewUnicode(newKey);
|
||||
}
|
||||
|
||||
nsAutoString str;
|
||||
str = aUStr;
|
||||
if (str.Length() == 0) {
|
||||
if (nsCRT::strlen(aUStr) == 0) {
|
||||
aStr.SetLength(0);
|
||||
} else {
|
||||
aStr.ReplaceSubstring(uKeyStr, aUStr);
|
||||
|
@ -344,12 +333,11 @@ SubstValueForCode(nsString& aStr, PRUnichar * aUKey, PRUnichar * aUStr)
|
|||
|
||||
// Free uKeyStr only if we fixed the string.
|
||||
if (fixingSubstr) {
|
||||
nsMemory::Free(uKeyStr);
|
||||
nsMemory::Free(NS_CONST_CAST(PRUnichar*, uKeyStr));
|
||||
}
|
||||
#else
|
||||
nsAutoString str;
|
||||
str = aUStr;
|
||||
if (str.Length() == 0) {
|
||||
|
||||
if (nsCRT::strlen(aUStr) == 0) {
|
||||
aStr.SetLength(0);
|
||||
} else {
|
||||
aStr.ReplaceSubstring(aUKey, aUStr);
|
||||
|
@ -368,74 +356,53 @@ nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr)
|
|||
|
||||
// Search to see if the &D code is in the string
|
||||
// then subst in the current date/time
|
||||
PRUnichar * kDate = GetUStr("&D");
|
||||
if (kDate != nsnull) {
|
||||
if (aStr.Find(kDate) > -1) {
|
||||
if (mPD->mDateTimeStr != nsnull) {
|
||||
aNewStr.ReplaceSubstring(kDate, mPD->mDateTimeStr);
|
||||
} else {
|
||||
aNewStr.ReplaceSubstring(kDate, NS_LITERAL_STRING("").get());
|
||||
}
|
||||
nsMemory::Free(kDate);
|
||||
return;
|
||||
NS_NAMED_LITERAL_STRING(kDate, "&D");
|
||||
if (aStr.Find(kDate) != kNotFound) {
|
||||
if (mPD->mDateTimeStr != nsnull) {
|
||||
aNewStr.ReplaceSubstring(kDate.get(), mPD->mDateTimeStr);
|
||||
} else {
|
||||
aNewStr.ReplaceSubstring(kDate.get(), NS_LITERAL_STRING("").get());
|
||||
}
|
||||
nsMemory::Free(kDate);
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: Must search for &PT before searching for &P
|
||||
//
|
||||
// Search to see if the "page number and page" total code are in the string
|
||||
// and replace the page number and page total code with the actual values
|
||||
PRUnichar * kPage = GetUStr("&PT");
|
||||
if (kPage != nsnull) {
|
||||
if (aStr.Find(kPage) > -1) {
|
||||
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumAndTotalsFormat, mPageNum, mTotNumPages);
|
||||
aNewStr.ReplaceSubstring(kPage, uStr);
|
||||
nsMemory::Free(uStr);
|
||||
nsMemory::Free(kPage);
|
||||
return;
|
||||
}
|
||||
nsMemory::Free(kPage);
|
||||
// and replace the page number and page total code with the actual
|
||||
// values
|
||||
NS_NAMED_LITERAL_STRING(kPageAndTotal, "&PT");
|
||||
if (aStr.Find(kPageAndTotal) != kNotFound) {
|
||||
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumAndTotalsFormat, mPageNum, mTotNumPages);
|
||||
aNewStr.ReplaceSubstring(kPageAndTotal.get(), uStr);
|
||||
nsMemory::Free(uStr);
|
||||
return;
|
||||
}
|
||||
|
||||
// Search to see if the page number code is in the string
|
||||
// and replace the page number code with the actual values
|
||||
kPage = GetUStr("&P");
|
||||
if (kPage != nsnull) {
|
||||
if (aStr.Find(kPage) > -1) {
|
||||
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumFormat, mPageNum);
|
||||
aNewStr.ReplaceSubstring(kPage, uStr);
|
||||
nsMemory::Free(uStr);
|
||||
nsMemory::Free(kPage);
|
||||
return;
|
||||
}
|
||||
nsMemory::Free(kPage);
|
||||
// and replace the page number code with the actual value
|
||||
NS_NAMED_LITERAL_STRING(kPage, "&P");
|
||||
if (aStr.Find(kPage) != kNotFound) {
|
||||
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumFormat, mPageNum);
|
||||
aNewStr.ReplaceSubstring(kPage.get(), uStr);
|
||||
nsMemory::Free(uStr);
|
||||
return;
|
||||
}
|
||||
|
||||
PRUnichar * kTitle = GetUStr("&T");
|
||||
if (kTitle != nsnull) {
|
||||
if (aStr.Find(kTitle) > -1) {
|
||||
PRUnichar * uTitle;
|
||||
mPD->mPrintOptions->GetTitle(&uTitle); // creates memory
|
||||
SubstValueForCode(aNewStr, kTitle, uTitle);
|
||||
nsMemory::Free(uTitle);
|
||||
nsMemory::Free(kTitle);
|
||||
return;
|
||||
}
|
||||
nsMemory::Free(kTitle);
|
||||
NS_NAMED_LITERAL_STRING(kTitle, "&T");
|
||||
if (aStr.Find(kTitle) != kNotFound) {
|
||||
nsXPIDLString uTitle;
|
||||
mPD->mPrintOptions->GetTitle(getter_Copies(uTitle));
|
||||
SubstValueForCode(aNewStr, kTitle.get(), uTitle.get());
|
||||
return;
|
||||
}
|
||||
|
||||
PRUnichar * kDocURL = GetUStr("&U");
|
||||
if (kDocURL != nsnull) {
|
||||
if (aStr.Find(kDocURL) > -1) {
|
||||
PRUnichar * uDocURL;
|
||||
mPD->mPrintOptions->GetDocURL(&uDocURL); // creates memory
|
||||
SubstValueForCode(aNewStr, kDocURL, uDocURL);
|
||||
nsMemory::Free(uDocURL);
|
||||
nsMemory::Free(kDocURL);
|
||||
return;
|
||||
}
|
||||
nsMemory::Free(kDocURL);
|
||||
NS_NAMED_LITERAL_STRING(kDocURL, "&U");
|
||||
if (aStr.Find(kDocURL) != kNotFound) {
|
||||
nsXPIDLString uDocURL;
|
||||
mPD->mPrintOptions->GetDocURL(getter_Copies(uDocURL));
|
||||
SubstValueForCode(aNewStr, kDocURL.get(), uDocURL.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3681,7 +3681,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
|||
result = PRBool(localTrue == value.Equals(attr->mValue));
|
||||
}
|
||||
else {
|
||||
result = PRBool(localTrue == value.EqualsIgnoreCase(attr->mValue));
|
||||
result = PRBool(localTrue == value.Equals(attr->mValue, nsCaseInsensitiveStringComparator()));
|
||||
}
|
||||
break;
|
||||
case NS_ATTR_FUNC_INCLUDES:
|
||||
|
@ -3738,7 +3738,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
|||
}
|
||||
break;
|
||||
case NS_ATTR_FUNC_CONTAINSMATCH:
|
||||
result = PRBool(localTrue == (-1 != value.Find(attr->mValue, isCaseSensitive)));
|
||||
result = PRBool(localTrue == (FindInReadable(attr->mValue, value, nsCaseInsensitiveStringComparator())));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -709,7 +709,7 @@ nsTextBoxFrame::UpdateAccessTitle()
|
|||
nsMenuBarListener::GetMenuAccessKey(&menuAccessKey);
|
||||
if (menuAccessKey) {
|
||||
if (!mAccessKey.IsEmpty()) {
|
||||
if ((mTitle.Find(mAccessKey, PR_TRUE) == kNotFound)
|
||||
if (( !FindInReadable(mAccessKey, mTitle, nsCaseInsensitiveStringComparator()))
|
||||
|| AlwaysAppendAccessKey())
|
||||
{
|
||||
nsAutoString tmpstring(NS_LITERAL_STRING("("));
|
||||
|
@ -747,17 +747,34 @@ nsTextBoxFrame::UpdateAccessIndex()
|
|||
if (!mAccessKeyInfo)
|
||||
mAccessKeyInfo = new nsAccessKeyInfo();
|
||||
|
||||
nsAString::const_iterator start, end;
|
||||
|
||||
mCroppedTitle.BeginReading(start);
|
||||
mCroppedTitle.EndReading(end);
|
||||
|
||||
// remember the beginning of the string
|
||||
nsAString::const_iterator originalStart = start;
|
||||
|
||||
PRBool found;
|
||||
if (!AlwaysAppendAccessKey()) {
|
||||
// not appending access key - do case-sensitive search first
|
||||
mAccessKeyInfo->mAccesskeyIndex = mCroppedTitle.Find(mAccessKey, PR_FALSE);
|
||||
if (mAccessKeyInfo->mAccesskeyIndex == kNotFound) {
|
||||
// not appending access key - do case-sensitive search
|
||||
// first
|
||||
found = FindInReadable(mAccessKey, start, end);
|
||||
if (!found) {
|
||||
// didn't find it - perform a case-insensitive search
|
||||
mAccessKeyInfo->mAccesskeyIndex = mCroppedTitle.Find(mAccessKey, PR_TRUE);
|
||||
start = originalStart;
|
||||
found = FindInReadable(mAccessKey, start, end,
|
||||
nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
} else {
|
||||
// use case-insensitive, reverse find for appended access keys
|
||||
mAccessKeyInfo->mAccesskeyIndex = mCroppedTitle.RFind(mAccessKey, PR_TRUE);
|
||||
found = RFindInReadable(mAccessKey, start, end,
|
||||
nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
|
||||
if (found)
|
||||
mAccessKeyInfo->mAccesskeyIndex = Distance(originalStart, start);
|
||||
else
|
||||
mAccessKeyInfo->mAccesskeyIndex = kNotFound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,8 +243,8 @@ nsAbAutoCompleteSession::AddToResult(const PRUnichar* pNickNameStr,
|
|||
if (type != DEFAULT_MATCH && !bIsMailList)
|
||||
{
|
||||
nsAutoString emailaddr(pEmailStr);
|
||||
PRInt32 foundIndex = emailaddr.Find(mDefaultDomain, PR_TRUE);
|
||||
if (foundIndex > 0)
|
||||
if (FindInReadable(mDefaultDomain, emailaddr,
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
// okay the match contains the default domain, we want to insert it
|
||||
// AFTER any exisiting matches of the same type which also have a domain
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbDirectoryQuerySimpleBooleanExpression, nsIAbBooleanExpression)
|
||||
|
@ -618,28 +619,38 @@ nsresult nsAbDirectoryQuery::matchCardCondition (nsIAbCard* card,
|
|||
*matchFound = PR_TRUE;
|
||||
break;
|
||||
case nsIAbBooleanConditionTypes::Contains:
|
||||
*matchFound = value.Find (matchValue.get(), PR_TRUE) >= 0;
|
||||
*matchFound = FindInReadable(matchValue, value, nsCaseInsensitiveStringComparator());
|
||||
break;
|
||||
case nsIAbBooleanConditionTypes::DoesNotContain:
|
||||
*matchFound = value.Find (matchValue.get(), PR_TRUE) < 0;
|
||||
*matchFound = !FindInReadable(matchValue, value, nsCaseInsensitiveStringComparator());
|
||||
break;
|
||||
case nsIAbBooleanConditionTypes::Is:
|
||||
*matchFound = value.CompareWithConversion (matchValue, PR_TRUE) == 0;
|
||||
*matchFound = value.Equals (matchValue, nsCaseInsensitiveStringComparator());
|
||||
break;
|
||||
case nsIAbBooleanConditionTypes::IsNot:
|
||||
*matchFound = value.CompareWithConversion (matchValue, PR_TRUE) != 0;
|
||||
*matchFound = !value.Equals (matchValue, nsCaseInsensitiveStringComparator());
|
||||
break;
|
||||
case nsIAbBooleanConditionTypes::BeginsWith:
|
||||
*matchFound = value.Find (matchValue.get(), PR_TRUE) == 0;
|
||||
{
|
||||
if (value.Length() < matchValue.Length()) {
|
||||
*matchFound = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
*matchFound =
|
||||
matchValue.Equals(Substring(value, 0,
|
||||
matchValue.Length()),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
break;
|
||||
case nsIAbBooleanConditionTypes::LessThan:
|
||||
*matchFound = value.CompareWithConversion (matchValue, PR_TRUE) < 0;
|
||||
*matchFound = Compare(value, matchValue, nsCaseInsensitiveStringComparator()) < 0;
|
||||
break;
|
||||
case nsIAbBooleanConditionTypes::GreaterThan:
|
||||
*matchFound = value.CompareWithConversion (matchValue, PR_TRUE) > 0;
|
||||
*matchFound = Compare(value, matchValue, nsCaseInsensitiveStringComparator()) > 0;
|
||||
break;
|
||||
case nsIAbBooleanConditionTypes::EndsWith:
|
||||
{
|
||||
|
||||
PRInt32 vl = value.Length ();
|
||||
PRInt32 mvl = matchValue.Length ();
|
||||
|
||||
|
@ -649,7 +660,8 @@ nsresult nsAbDirectoryQuery::matchCardCondition (nsIAbCard* card,
|
|||
break;
|
||||
}
|
||||
|
||||
*matchFound = value.Find (matchValue.get(), PR_TRUE, vl - mvl) == (vl - mvl);
|
||||
*matchFound = matchValue.Equals(Substring(value, vl - mvl, mvl),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
break;
|
||||
}
|
||||
case nsIAbBooleanConditionTypes::SoundsLike:
|
||||
|
|
|
@ -2960,10 +2960,13 @@ nsMsgCompose::LoadDataFromFile(nsFileSpec& fSpec, nsString &sigData)
|
|||
nsAutoString metaCharset;
|
||||
metaCharset.Assign(NS_LITERAL_STRING("charset="));
|
||||
metaCharset.AppendWithConversion(sigEncoding.get());
|
||||
PRInt32 metaCharsetOffset = sigData.Find(metaCharset,PR_TRUE,0,-1);
|
||||
|
||||
if (metaCharsetOffset != kNotFound)
|
||||
sigData.Cut(metaCharsetOffset, metaCharset.Length());
|
||||
nsAString::const_iterator realstart, start, end;
|
||||
sigData.BeginReading(start);
|
||||
sigData.EndReading(end);
|
||||
realstart = start;
|
||||
if (FindInReadable(metaCharset, start, end,
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
sigData.Cut(Distance(realstart, start), Distance(start, end));
|
||||
}
|
||||
|
||||
PR_FREEIF(readBuf);
|
||||
|
@ -3453,7 +3456,7 @@ nsresult nsMsgCompose::GetMailListAddresses(nsString& name, nsISupportsArray* ma
|
|||
rv = enumerator->CurrentItem((nsISupports**)&mailList);
|
||||
if (NS_SUCCEEDED(rv) && mailList)
|
||||
{
|
||||
if (name.EqualsIgnoreCase(mailList->mFullName))
|
||||
if (name.Equals(mailList->mFullName, nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
if (!mailList->mDirectory)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -3763,10 +3766,10 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
|
|||
if (atPos >= 0)
|
||||
{
|
||||
recipient->mEmail.Right(domain, recipient->mEmail.Length() - atPos - 1);
|
||||
if (plaintextDomains.Find(domain, PR_TRUE) >= 0)
|
||||
if (FindInReadable(domain, plaintextDomains, nsCaseInsensitiveStringComparator()))
|
||||
recipient->mPreferFormat = nsIAbPreferMailFormat::plaintext;
|
||||
else
|
||||
if (htmlDomains.Find(domain, PR_TRUE) >= 0)
|
||||
if (FindInReadable(domain, htmlDomains, nsCaseInsensitiveStringComparator()))
|
||||
recipient->mPreferFormat = nsIAbPreferMailFormat::html;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,8 +173,7 @@ nsTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsISupports *aContext,
|
|||
}
|
||||
}
|
||||
|
||||
PRInt32 end = mBuffer.RFind(TOKEN_DELIMITERS,
|
||||
PR_FALSE, mBuffer.Length());
|
||||
PRInt32 end = mBuffer.RFind(TOKEN_DELIMITERS, mBuffer.Length());
|
||||
mBuffer.Left(pushBuffer, PR_MAX(cursor, end));
|
||||
mBuffer.Cut(0, PR_MAX(cursor, end));
|
||||
cursor = 0;
|
||||
|
@ -242,7 +241,7 @@ nsTXTToHTMLConv::FindToken(PRInt32 cursor, convToken* *_retval) {
|
|||
PRInt32 loc = -1, firstToken = mBuffer.Length();
|
||||
PRInt8 token = -1;
|
||||
for (PRInt8 i=0; i < mTokens.Count(); i++) {
|
||||
loc = mBuffer.Find(((convToken*)mTokens[i])->token, PR_FALSE, cursor);
|
||||
loc = mBuffer.Find(((convToken*)mTokens[i])->token, cursor);
|
||||
if (loc != -1)
|
||||
if (loc < firstToken) {
|
||||
firstToken = loc;
|
||||
|
|
|
@ -68,7 +68,6 @@
|
|||
#include "nsIStreamListener.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIBookmarksService.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsICookieService.h"
|
||||
|
@ -178,7 +177,6 @@ static nsIAtom* sApp_MessengerFolderCache50 = nsnull;
|
|||
|
||||
// IID and CIDs of all the services needed
|
||||
static NS_DEFINE_CID(kIProfileIID, NS_IPROFILE_IID);
|
||||
static NS_DEFINE_CID(kBookmarksCID, NS_BOOKMARKS_SERVICE_CID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kRegistryCID, NS_REGISTRY_CID);
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
|
|
|
@ -229,7 +229,7 @@ static const char kApostrophe = '\'';
|
|||
PRInt32 endOffset = -1;
|
||||
nsresult result = NS_OK;
|
||||
|
||||
offset = aSource.Find(aAttribute);
|
||||
offset = aSource.Find(aAttribute, 0);
|
||||
if (-1 != offset) {
|
||||
offset = aSource.FindChar('=', offset);
|
||||
|
||||
|
|
|
@ -1,727 +0,0 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape security libraries.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ian McGreer <mcgreer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU General Public License Version 2 or later (the
|
||||
* "GPL"), in which case the provisions of the GPL are applicable
|
||||
* instead of those above. If you wish to allow use of your
|
||||
* version of this file only under the terms of the GPL and not to
|
||||
* allow others to use your version of this file under the MPL,
|
||||
* indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by
|
||||
* the GPL. If you do not delete the provisions above, a recipient
|
||||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsNSSComponent.h" // for PIPNSS string bundle calls.
|
||||
#include "nsCertOutliner.h"
|
||||
#include "nsIX509Cert.h"
|
||||
#include "nsIX509CertDB.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include "prlog.h"
|
||||
#ifdef PR_LOGGING
|
||||
extern PRLogModuleInfo* gPIPNSSLog;
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kNSSComponentCID, NS_NSSCOMPONENT_CID);
|
||||
|
||||
// outlinerArrayElStr
|
||||
//
|
||||
// structure used to hold map of outliner. Each thread (an organization
|
||||
// field from a cert) has an element in the array. The numChildren field
|
||||
// stores the number of certs corresponding to that thread.
|
||||
struct outlinerArrayElStr {
|
||||
PRUnichar *orgName; /* heading for thread */
|
||||
PRBool open; /* toggle open state for thread */
|
||||
PRInt32 certIndex; /* index into cert array for 1st cert */
|
||||
PRInt32 numChildren; /* number of chidren (certs) for thread */
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsCertOutliner, nsICertOutliner, nsIOutlinerView)
|
||||
|
||||
nsCertOutliner::nsCertOutliner() : mOutlinerArray(NULL)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsCertOutliner::~nsCertOutliner()
|
||||
{
|
||||
if (mOutlinerArray)
|
||||
nsMemory::Free(mOutlinerArray);
|
||||
}
|
||||
|
||||
void
|
||||
nsCertOutliner::FreeCertArray()
|
||||
{
|
||||
if (mCertArray) {
|
||||
PRUint32 count;
|
||||
nsresult rv = mCertArray->Count(&count);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Count failed");
|
||||
PRInt32 i;
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
mCertArray->RemoveElementAt(i);
|
||||
}
|
||||
mCertArray = nsnull;
|
||||
}
|
||||
|
||||
// CmpByToken
|
||||
//
|
||||
// Compare two certificate by their token name. Returns -1, 0, 1 as
|
||||
// in strcmp. No token name (null) is treated as <.
|
||||
PRInt32
|
||||
nsCertOutliner::CmpByToken(nsIX509Cert *a, nsIX509Cert *b)
|
||||
{
|
||||
PRInt32 cmp1;
|
||||
nsXPIDLString aTok, bTok;
|
||||
a->GetTokenName(getter_Copies(aTok));
|
||||
b->GetTokenName(getter_Copies(bTok));
|
||||
if (aTok != nsnull && bTok != nsnull) {
|
||||
nsAutoString aStr(aTok);
|
||||
cmp1 = aStr.CompareWithConversion(bTok);
|
||||
} else {
|
||||
cmp1 = (aTok == nsnull) ? -1 : 1;
|
||||
}
|
||||
return cmp1;
|
||||
}
|
||||
|
||||
// CmpByIssuerOrg
|
||||
//
|
||||
// Compare two certificates by their O= field. Returns -1, 0, 1 as
|
||||
// in strcmp. No organization (null) is treated as <.
|
||||
PRInt32
|
||||
nsCertOutliner::CmpByIssuerOrg(nsIX509Cert *a, nsIX509Cert *b)
|
||||
{
|
||||
PRInt32 cmp1;
|
||||
nsXPIDLString aOrg, bOrg;
|
||||
a->GetIssuerOrganization(getter_Copies(aOrg));
|
||||
b->GetIssuerOrganization(getter_Copies(bOrg));
|
||||
if (aOrg != nsnull && bOrg != nsnull) {
|
||||
nsAutoString aStr(aOrg);
|
||||
cmp1 = aStr.CompareWithConversion(bOrg);
|
||||
} else {
|
||||
cmp1 = (aOrg == nsnull) ? -1 : 1;
|
||||
}
|
||||
return cmp1;
|
||||
}
|
||||
|
||||
// CmpByName
|
||||
//
|
||||
// Compare two certificates by their CN= field. Returns -1, 0, 1 as
|
||||
// in strcmp. No common name (null) is treated as <.
|
||||
PRInt32
|
||||
nsCertOutliner::CmpByName(nsIX509Cert *a, nsIX509Cert *b)
|
||||
{
|
||||
PRInt32 cmp1;
|
||||
nsXPIDLString aName, bName;
|
||||
a->GetOrganization(getter_Copies(aName));
|
||||
b->GetOrganization(getter_Copies(bName));
|
||||
if (aName != nsnull && bName != nsnull) {
|
||||
nsAutoString aStr(aName);
|
||||
cmp1 = aStr.CompareWithConversion(bName);
|
||||
} else {
|
||||
cmp1 = (aName == nsnull) ? -1 : 1;
|
||||
}
|
||||
return cmp1;
|
||||
}
|
||||
|
||||
// CmpByTok_IssuerOrg_Name
|
||||
//
|
||||
// Compare two certificates by token name, issuer organization,
|
||||
// and common name, in that order. Used to sort cert list.
|
||||
PRInt32
|
||||
nsCertOutliner::CmpByTok_IssuerOrg_Name(nsIX509Cert *a, nsIX509Cert *b)
|
||||
{
|
||||
PRInt32 cmp;
|
||||
cmp = CmpByToken(a, b);
|
||||
if (cmp != 0) return cmp;
|
||||
cmp = CmpByIssuerOrg(a, b);
|
||||
if (cmp != 0) return cmp;
|
||||
return CmpByName(a, b);
|
||||
}
|
||||
|
||||
// CountOrganizations
|
||||
//
|
||||
// Count the number of different organizations encountered in the cert
|
||||
// list. Note that the same organization of a different token is counted
|
||||
// seperately.
|
||||
PRInt32
|
||||
nsCertOutliner::CountOrganizations()
|
||||
{
|
||||
PRUint32 i, certCount;
|
||||
nsresult rv = mCertArray->Count(&certCount);
|
||||
if (NS_FAILED(rv)) return -1;
|
||||
if (certCount == 0) return 0;
|
||||
nsCOMPtr<nsISupports> isupport = dont_AddRef(mCertArray->ElementAt(0));
|
||||
nsCOMPtr<nsIX509Cert> orgCert = do_QueryInterface(isupport);
|
||||
nsCOMPtr<nsIX509Cert> nextCert = nsnull;
|
||||
PRInt32 orgCount = 1;
|
||||
for (i=1; i<certCount; i++) {
|
||||
isupport = dont_AddRef(mCertArray->ElementAt(i));
|
||||
nextCert = do_QueryInterface(isupport);
|
||||
if (!(CmpByToken(orgCert, nextCert) == 0 &&
|
||||
CmpByIssuerOrg(orgCert, nextCert) == 0)) {
|
||||
orgCert = nextCert;
|
||||
orgCount++;
|
||||
}
|
||||
}
|
||||
return orgCount;
|
||||
}
|
||||
|
||||
// GetThreadDescAtIndex
|
||||
//
|
||||
// If the row at index is an organization thread, return the collection
|
||||
// associated with that thread. Otherwise, return null.
|
||||
outlinerArrayEl *
|
||||
nsCertOutliner::GetThreadDescAtIndex(PRInt32 index)
|
||||
{
|
||||
int i, idx=0;
|
||||
if (index < 0) return nsnull;
|
||||
for (i=0; i<mNumOrgs; i++) {
|
||||
if (index == idx) {
|
||||
return &mOutlinerArray[i];
|
||||
}
|
||||
if (mOutlinerArray[i].open == PR_FALSE) {
|
||||
idx++;
|
||||
} else {
|
||||
idx += mOutlinerArray[i].numChildren + 1;
|
||||
}
|
||||
if (idx > index) break;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// GetCertAtIndex
|
||||
//
|
||||
// If the row at index is a cert, return that cert. Otherwise, return null.
|
||||
nsIX509Cert *
|
||||
nsCertOutliner::GetCertAtIndex(PRInt32 index)
|
||||
{
|
||||
int i, idx = 0, cIndex = 0, nc;
|
||||
nsIX509Cert *rawPtr = nsnull;
|
||||
if (index < 0) return nsnull;
|
||||
// Loop over the threads
|
||||
for (i=0; i<mNumOrgs; i++) {
|
||||
if (index == idx) return nsnull; // index is for thread
|
||||
idx++; // get past the thread
|
||||
nc = (mOutlinerArray[i].open) ? mOutlinerArray[i].numChildren : 0;
|
||||
if (index < idx + nc) { // cert is within range of this thread
|
||||
PRInt32 certIndex = cIndex + index - idx;
|
||||
nsCOMPtr<nsISupports> isupport =
|
||||
dont_AddRef(mCertArray->ElementAt(certIndex));
|
||||
nsCOMPtr<nsIX509Cert> cert = do_QueryInterface(isupport);
|
||||
rawPtr = cert;
|
||||
NS_IF_ADDREF(rawPtr);
|
||||
break;
|
||||
}
|
||||
if (mOutlinerArray[i].open)
|
||||
idx += mOutlinerArray[i].numChildren;
|
||||
cIndex += mOutlinerArray[i].numChildren;
|
||||
if (idx > index) break;
|
||||
}
|
||||
return rawPtr;
|
||||
}
|
||||
|
||||
// LoadCerts
|
||||
//
|
||||
// Load all of the certificates in the DB for this type. Sort them
|
||||
// by token, organization, then common name.
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::LoadCerts(PRUint32 aType)
|
||||
{
|
||||
nsresult rv;
|
||||
PRBool rowsChanged = PR_FALSE;
|
||||
PRInt32 numChanged = 0;
|
||||
if (mOutlinerArray) {
|
||||
FreeCertArray();
|
||||
nsMemory::Free(mOutlinerArray);
|
||||
mOutlinerArray = NULL;
|
||||
rowsChanged = PR_TRUE;
|
||||
numChanged = mNumRows;
|
||||
mNumRows = 0;
|
||||
}
|
||||
nsCOMPtr<nsIX509CertDB> certdb = do_GetService(NS_X509CERTDB_CONTRACTID);
|
||||
if (certdb == nsnull) return NS_ERROR_FAILURE;
|
||||
rv = certdb->GetCertsByType(aType,
|
||||
CmpByTok_IssuerOrg_Name,
|
||||
getter_AddRefs(mCertArray));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUint32 count;
|
||||
rv = mCertArray->Count(&count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mNumOrgs = CountOrganizations();
|
||||
mOutlinerArray = (outlinerArrayEl *)nsMemory::Alloc(
|
||||
sizeof(outlinerArrayEl) * mNumOrgs);
|
||||
PRUint32 j = 0;
|
||||
nsCOMPtr<nsISupports> isupport = dont_AddRef(mCertArray->ElementAt(j));
|
||||
nsCOMPtr<nsIX509Cert> orgCert = do_QueryInterface(isupport);
|
||||
for (PRInt32 i=0; i<mNumOrgs; i++) {
|
||||
orgCert->GetIssuerOrganization(&mOutlinerArray[i].orgName);
|
||||
mOutlinerArray[i].open = PR_TRUE;
|
||||
mOutlinerArray[i].certIndex = j;
|
||||
mOutlinerArray[i].numChildren = 1;
|
||||
if (++j >= count) break;
|
||||
isupport = dont_AddRef(mCertArray->ElementAt(j));
|
||||
nsCOMPtr<nsIX509Cert> nextCert = do_QueryInterface(isupport);
|
||||
while (CmpByIssuerOrg(orgCert, nextCert) == 0) {
|
||||
mOutlinerArray[i].numChildren++;
|
||||
if (++j >= count) break;
|
||||
isupport = dont_AddRef(mCertArray->ElementAt(j));
|
||||
nextCert = do_QueryInterface(isupport);
|
||||
}
|
||||
orgCert = nextCert;
|
||||
}
|
||||
mNumRows = count + mNumOrgs;
|
||||
if (rowsChanged) {
|
||||
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("[%d,%d]", mNumRows, numChanged));
|
||||
numChanged = mNumRows - numChanged;
|
||||
if (mOutliner) mOutliner->RowCountChanged(0, numChanged);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Begin nsIOutlinerView methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* nsIX509Cert getCert(in unsigned long index); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::GetCert(PRUint32 aIndex, nsIX509Cert **_cert)
|
||||
{
|
||||
NS_ENSURE_ARG(_cert);
|
||||
*_cert = GetCertAtIndex(aIndex);
|
||||
//nsCOMPtr<nsIX509Cert> cert = GetCertAtIndex(aIndex);
|
||||
//if (cert) {
|
||||
//*_cert = cert;
|
||||
//NS_ADDREF(*_cert);
|
||||
//}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute long rowCount; */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::GetRowCount(PRInt32 *aRowCount)
|
||||
{
|
||||
PRUint32 count = 0;
|
||||
for (PRInt32 i=0; i<mNumOrgs; i++) {
|
||||
if (mOutlinerArray[i].open == PR_TRUE) {
|
||||
count += mOutlinerArray[i].numChildren + 1;
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
*aRowCount = count;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute nsIOutlinerSelection selection; */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::GetSelection(nsIOutlinerSelection * *aSelection)
|
||||
{
|
||||
*aSelection = mSelection;
|
||||
NS_IF_ADDREF(*aSelection);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::SetSelection(nsIOutlinerSelection * aSelection)
|
||||
{
|
||||
mSelection = aSelection;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getRowProperties (in long index, in nsISupportsArray properties); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::GetRowProperties(PRInt32 index, nsISupportsArray *properties)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getCellProperties (in long row, in wstring colID,
|
||||
* in nsISupportsArray properties);
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::GetCellProperties(PRInt32 row, const PRUnichar *colID,
|
||||
nsISupportsArray *properties)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getColumnProperties (in wstring colID,
|
||||
* in nsIDOMElement colElt,
|
||||
* in nsISupportsArray properties);
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::GetColumnProperties(const PRUnichar *colID,
|
||||
nsIDOMElement *colElt,
|
||||
nsISupportsArray *properties)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isContainer (in long index); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::IsContainer(PRInt32 index, PRBool *_retval)
|
||||
{
|
||||
outlinerArrayEl *el = GetThreadDescAtIndex(index);
|
||||
if (el) {
|
||||
*_retval = PR_TRUE;
|
||||
} else {
|
||||
*_retval = PR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isContainerOpen (in long index); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::IsContainerOpen(PRInt32 index, PRBool *_retval)
|
||||
{
|
||||
outlinerArrayEl *el = GetThreadDescAtIndex(index);
|
||||
if (el && el->open == PR_TRUE) {
|
||||
*_retval = PR_TRUE;
|
||||
} else {
|
||||
*_retval = PR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isContainerEmpty (in long index); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::IsContainerEmpty(PRInt32 index, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isSeparator (in long index); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::IsSeparator(PRInt32 index, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* long getParentIndex (in long rowIndex); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::GetParentIndex(PRInt32 rowIndex, PRInt32 *_retval)
|
||||
{
|
||||
int i, idx = 0;
|
||||
for (i=0; i<mNumOrgs; i++) {
|
||||
if (rowIndex == idx) break; // index is for thread
|
||||
if (rowIndex < idx + mOutlinerArray[i].numChildren + 1) {
|
||||
*_retval = idx;
|
||||
return NS_OK;
|
||||
}
|
||||
idx += mOutlinerArray[i].numChildren + 1;
|
||||
if (idx > rowIndex) break;
|
||||
}
|
||||
*_retval = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean hasNextSibling (in long rowIndex, in long afterIndex); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::HasNextSibling(PRInt32 rowIndex, PRInt32 afterIndex,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* long getLevel (in long index); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::GetLevel(PRInt32 index, PRInt32 *_retval)
|
||||
{
|
||||
outlinerArrayEl *el = GetThreadDescAtIndex(index);
|
||||
if (el) {
|
||||
*_retval = 0;
|
||||
} else {
|
||||
*_retval = 1;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* wstring getCellText (in long row, in wstring colID); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID,
|
||||
nsAString& _retval)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ConvertUCS2toUTF8 aUtf8ColID(colID);
|
||||
const char *col = aUtf8ColID.get();
|
||||
outlinerArrayEl *el = GetThreadDescAtIndex(row);
|
||||
if (el != nsnull) {
|
||||
if (strcmp(col, "certcol") == 0)
|
||||
_retval.Assign(el->orgName);
|
||||
else
|
||||
_retval.SetCapacity(0);
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIX509Cert> cert = GetCertAtIndex(row);
|
||||
if (cert == nsnull) return NS_ERROR_FAILURE;
|
||||
char *str = NULL;
|
||||
PRUnichar *wstr = NULL;
|
||||
if (strcmp(col, "certcol") == 0) {
|
||||
rv = cert->GetCommonName(&wstr);
|
||||
if (NS_FAILED(rv) || !wstr) {
|
||||
// can this be fixed to not do copying?
|
||||
PRUnichar *tmp = nsnull;
|
||||
rv = cert->GetNickname(&tmp);
|
||||
nsAutoString nick(tmp);
|
||||
char *tmps = ToNewCString(nick);
|
||||
char *mark = strchr(tmps, ':');
|
||||
if (mark) {
|
||||
str = PL_strdup(mark + 1);
|
||||
} else {
|
||||
wstr = ToNewUnicode(nick);
|
||||
}
|
||||
nsMemory::Free(tmp);
|
||||
nsMemory::Free(tmps);
|
||||
}
|
||||
} else if (strcmp(col, "tokencol") == 0) {
|
||||
rv = cert->GetTokenName(&wstr);
|
||||
} else if (strcmp(col, "emailcol") == 0) {
|
||||
rv = cert->GetEmailAddress(&wstr);
|
||||
} else if (strcmp(col, "verifiedcol") == 0) {
|
||||
PRUint32 verified;
|
||||
nsCOMPtr<nsINSSComponent> nssComponent(
|
||||
do_GetService(kNSSComponentCID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRBool ocspEnabled;
|
||||
cert->GetUsesOCSP(&ocspEnabled);
|
||||
if (ocspEnabled) {
|
||||
nssComponent->DisableOCSP();
|
||||
}
|
||||
rv = cert->GetPurposes(&verified, NULL);
|
||||
if (verified == nsIX509Cert::VERIFIED_OK) {
|
||||
nsAutoString vfy;
|
||||
rv = nssComponent->GetPIPNSSBundleString(
|
||||
NS_LITERAL_STRING("VerifiedTrue").get(), vfy);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
wstr = ToNewUnicode(vfy);
|
||||
} else {
|
||||
nsAutoString vfy;
|
||||
rv = nssComponent->GetPIPNSSBundleString(
|
||||
NS_LITERAL_STRING("VerifiedFalse").get(), vfy);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
wstr = ToNewUnicode(vfy);
|
||||
}
|
||||
if (ocspEnabled) {
|
||||
nssComponent->EnableOCSP();
|
||||
}
|
||||
} else if (strcmp(col, "purposecol") == 0) {
|
||||
PRUint32 verified;
|
||||
PRBool ocspEnabled;
|
||||
nsCOMPtr<nsINSSComponent> nssComponent(
|
||||
do_GetService(kNSSComponentCID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
cert->GetUsesOCSP(&ocspEnabled);
|
||||
if (ocspEnabled) {
|
||||
nssComponent->DisableOCSP();
|
||||
}
|
||||
rv = cert->GetPurposes(&verified, &wstr);
|
||||
if (ocspEnabled) {
|
||||
nssComponent->EnableOCSP();
|
||||
}
|
||||
} else if (strcmp(col, "issuedcol") == 0) {
|
||||
rv = cert->GetIssuedDate(&wstr);
|
||||
} else if (strcmp(col, "expiredcol") == 0) {
|
||||
rv = cert->GetExpiresDate(&wstr);
|
||||
} else if (strcmp(col, "serialnumcol") == 0) {
|
||||
rv = cert->GetSerialNumber(&wstr);
|
||||
/*
|
||||
} else if (strcmp(col, "certdbkeycol") == 0) {
|
||||
rv = cert->GetDbKey(&str);
|
||||
*/
|
||||
} else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (str) {
|
||||
nsAutoString astr = NS_ConvertASCIItoUCS2(str);
|
||||
wstr = ToNewUnicode(astr);
|
||||
}
|
||||
_retval = wstr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void setOutliner (in nsIOutlinerBoxObject outliner); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::SetOutliner(nsIOutlinerBoxObject *outliner)
|
||||
{
|
||||
mOutliner = outliner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void toggleOpenState (in long index); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::ToggleOpenState(PRInt32 index)
|
||||
{
|
||||
outlinerArrayEl *el = GetThreadDescAtIndex(index);
|
||||
if (el) el->open = !el->open;
|
||||
PRInt32 fac = (el->open) ? 1 : -1;
|
||||
if (mOutliner) mOutliner->RowCountChanged(index, fac * el->numChildren);
|
||||
mSelection->Select(index);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void cycleHeader (in wstring colID, in nsIDOMElement elt); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::CycleHeader(const PRUnichar *colID, nsIDOMElement *elt)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void selectionChanged (); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::SelectionChanged()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void cycleCell (in long row, in wstring colID); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::CycleCell(PRInt32 row, const PRUnichar *colID)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isEditable (in long row, in wstring colID); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::IsEditable(PRInt32 row, const PRUnichar *colID, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setCellText (in long row, in wstring colID, in wstring value); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::SetCellText(PRInt32 row, const PRUnichar *colID,
|
||||
const PRUnichar *value)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void performAction (in wstring action); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::PerformAction(const PRUnichar *action)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void performActionOnRow (in wstring action, in long row); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::PerformActionOnRow(const PRUnichar *action, PRInt32 row)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void performActionOnCell (in wstring action, in long row,
|
||||
* in wstring colID);
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::PerformActionOnCell(const PRUnichar *action, PRInt32 row,
|
||||
const PRUnichar *colID)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CERT_OUTLINER
|
||||
void
|
||||
nsCertOutliner::dumpMap()
|
||||
{
|
||||
for (int i=0; i<mNumOrgs; i++) {
|
||||
nsAutoString org(mOutlinerArray[i].orgName);
|
||||
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("ORG[%s]", NS_LossyConvertUCS2toASCII(org).get()));
|
||||
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("OPEN[%d]", mOutlinerArray[i].open));
|
||||
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("INDEX[%d]", mOutlinerArray[i].certIndex));
|
||||
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("NCHILD[%d]", mOutlinerArray[i].numChildren));
|
||||
}
|
||||
for (int i=0; i<mNumRows; i++) {
|
||||
outlinerArrayEl *el = GetThreadDescAtIndex(i);
|
||||
if (el != nsnull) {
|
||||
nsAutoString td(el->orgName);
|
||||
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("thread desc[%d]: %s", i, NS_LossyConvertUCS2toASCII(td).get()));
|
||||
}
|
||||
nsCOMPtr<nsIX509Cert> ct = GetCertAtIndex(i);
|
||||
if (ct != nsnull) {
|
||||
PRUnichar *goo;
|
||||
ct->GetCommonName(&goo);
|
||||
nsAutoString doo(goo);
|
||||
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("cert [%d]: %s", i, NS_LossyConvertUCS2toASCII(doo).get()));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// CanDropOn
|
||||
//
|
||||
// Can't drop on the thread pane.
|
||||
//
|
||||
NS_IMETHODIMP nsCertOutliner::CanDropOn(PRInt32 index, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// CanDropBeforeAfter
|
||||
//
|
||||
// Can't drop on the thread pane.
|
||||
//
|
||||
NS_IMETHODIMP nsCertOutliner::CanDropBeforeAfter(PRInt32 index, PRBool before, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Drop
|
||||
//
|
||||
// Can't drop on the thread pane.
|
||||
//
|
||||
NS_IMETHODIMP nsCertOutliner::Drop(PRInt32 row, PRInt32 orient)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// IsSorted
|
||||
//
|
||||
// ...
|
||||
//
|
||||
NS_IMETHODIMP nsCertOutliner::IsSorted(PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
|
@ -98,8 +98,7 @@ nsCertOutliner::CmpByToken(nsIX509Cert *a, nsIX509Cert *b)
|
|||
a->GetTokenName(getter_Copies(aTok));
|
||||
b->GetTokenName(getter_Copies(bTok));
|
||||
if (aTok != nsnull && bTok != nsnull) {
|
||||
nsAutoString aStr(aTok);
|
||||
cmp1 = aStr.CompareWithConversion(bTok);
|
||||
cmp1 = Compare(aTok, bTok);
|
||||
} else {
|
||||
cmp1 = (aTok == nsnull) ? -1 : 1;
|
||||
}
|
||||
|
@ -118,8 +117,7 @@ nsCertOutliner::CmpByIssuerOrg(nsIX509Cert *a, nsIX509Cert *b)
|
|||
a->GetIssuerOrganization(getter_Copies(aOrg));
|
||||
b->GetIssuerOrganization(getter_Copies(bOrg));
|
||||
if (aOrg != nsnull && bOrg != nsnull) {
|
||||
nsAutoString aStr(aOrg);
|
||||
cmp1 = aStr.CompareWithConversion(bOrg);
|
||||
cmp1 = Compare(aOrg, bOrg);
|
||||
} else {
|
||||
cmp1 = (aOrg == nsnull) ? -1 : 1;
|
||||
}
|
||||
|
@ -138,8 +136,7 @@ nsCertOutliner::CmpByName(nsIX509Cert *a, nsIX509Cert *b)
|
|||
a->GetOrganization(getter_Copies(aName));
|
||||
b->GetOrganization(getter_Copies(bName));
|
||||
if (aName != nsnull && bName != nsnull) {
|
||||
nsAutoString aStr(aName);
|
||||
cmp1 = aStr.CompareWithConversion(bName);
|
||||
cmp1 = Compare(aName, bName);
|
||||
} else {
|
||||
cmp1 = (aName == nsnull) ? -1 : 1;
|
||||
}
|
||||
|
|
|
@ -3545,8 +3545,7 @@ PRInt32 nsOCSPResponder::CmpCAName(nsIOCSPResponder *a, nsIOCSPResponder *b)
|
|||
a->GetResponseSigner(getter_Copies(aTok));
|
||||
b->GetResponseSigner(getter_Copies(bTok));
|
||||
if (aTok != nsnull && bTok != nsnull) {
|
||||
nsAutoString aStr(aTok);
|
||||
cmp1 = aStr.CompareWithConversion(bTok);
|
||||
cmp1 = Compare(aTok, bTok);
|
||||
} else {
|
||||
cmp1 = (aTok == nsnull) ? 1 : -1;
|
||||
}
|
||||
|
|
|
@ -693,17 +693,9 @@ PRInt32 Compare1To1(const char* aStr1,const char* aStr2,PRUint32 aCount,PRBool a
|
|||
* @param aIgnorecase tells us whether to use a case-sensitive comparison
|
||||
* @return -1,0,1 depending on <,==,>
|
||||
*/
|
||||
PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCount,PRBool aIgnoreCase);
|
||||
PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCount,PRBool aIgnoreCase){
|
||||
PRInt32 result=0;
|
||||
#ifndef XPCOM_STANDALONE
|
||||
if(aIgnoreCase && NS_SUCCEEDED(NS_InitCaseConversion()))
|
||||
gCaseConv->CaseInsensitiveCompare(aStr1, aStr2, aCount, &result);
|
||||
else result=nsCRT::strncmp(aStr1,aStr2,aCount);
|
||||
#else
|
||||
NS_ERROR("call not supported in XPCOM_STANDALONE");
|
||||
#endif
|
||||
return result;
|
||||
PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCount);
|
||||
PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCount){
|
||||
return nsCRT::strncmp(aStr1, aStr2, aCount * sizeof(PRUnichar));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -647,7 +647,7 @@ PRInt32 nsStrPrivate::FindSubstr1in2(const nsStr& aDest,const nsStr& aTarget, PR
|
|||
return kNotFound;
|
||||
}
|
||||
|
||||
PRInt32 nsStrPrivate::FindSubstr2in2(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) {
|
||||
PRInt32 nsStrPrivate::FindSubstr2in2(const nsStr& aDest,const nsStr& aTarget, PRInt32 anOffset,PRInt32 aCount) {
|
||||
|
||||
NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
NS_ASSERTION(aTarget.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
|
@ -675,7 +675,7 @@ PRInt32 nsStrPrivate::FindSubstr2in2(const nsStr& aDest,const nsStr& aTarget, PR
|
|||
const PRUnichar* right = (last<max) ? last : max;
|
||||
|
||||
while(left<=right){
|
||||
PRInt32 cmp=Compare2To2(left,aTarget.mUStr,aTarget.mLength,aIgnoreCase);
|
||||
PRInt32 cmp=Compare2To2(left,aTarget.mUStr,aTarget.mLength);
|
||||
if(0==cmp) {
|
||||
return (left-root);
|
||||
}
|
||||
|
@ -857,7 +857,7 @@ PRInt32 nsStrPrivate::RFindSubstr1in2(const nsStr& aDest,const nsStr& aTarget,PR
|
|||
return kNotFound;
|
||||
}
|
||||
|
||||
PRInt32 nsStrPrivate::RFindSubstr2in2(const nsStr& aDest,const nsStr& aTarget,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) {
|
||||
PRInt32 nsStrPrivate::RFindSubstr2in2(const nsStr& aDest,const nsStr& aTarget,PRInt32 anOffset,PRInt32 aCount) {
|
||||
|
||||
NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
NS_ASSERTION(aTarget.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
|
@ -885,7 +885,7 @@ PRInt32 nsStrPrivate::RFindSubstr2in2(const nsStr& aDest,const nsStr& aTarget,PR
|
|||
while(leftmost<=rightmost) {
|
||||
//don't forget to divide by delta in next text (bug found by rhp)...
|
||||
if(aTarget.mLength<=PRUint32(destLast-rightmost)) {
|
||||
PRInt32 result = Compare2To2(rightmost,aTarget.mUStr,aTarget.mLength,aIgnoreCase);
|
||||
PRInt32 result = Compare2To2(rightmost,aTarget.mUStr,aTarget.mLength);
|
||||
|
||||
if(0==result) {
|
||||
return (rightmost-root);
|
||||
|
@ -1048,13 +1048,13 @@ PRInt32 nsStrPrivate::StrCompare2To1(const nsStr& aDest,const nsStr& aSource,PRI
|
|||
return 0;
|
||||
}
|
||||
|
||||
PRInt32 nsStrPrivate::StrCompare2To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
|
||||
PRInt32 nsStrPrivate::StrCompare2To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount) {
|
||||
NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
NS_ASSERTION(aSource.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
|
||||
if (aCount) {
|
||||
PRInt32 theCount = GetCompareCount(aDest.mLength, aSource.mLength, aCount);
|
||||
PRInt32 result = Compare2To2(aDest.mUStr, aSource.mUStr, theCount, aIgnoreCase);
|
||||
PRInt32 result = Compare2To2(aDest.mUStr, aSource.mUStr, theCount);
|
||||
result = TranslateCompareResult(aDest.mLength, aSource.mLength, result, aCount);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ class nsStrPrivate {
|
|||
static PRInt32 StrCompare2To1(const nsStr& aDest, const nsStr& aSource,
|
||||
PRInt32 aCount, PRBool aIgnoreCase);
|
||||
static PRInt32 StrCompare2To2(const nsStr& aDest, const nsStr& aSource,
|
||||
PRInt32 aCount, PRBool aIgnoreCase);
|
||||
PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* These methods scan the given string for 1 or more chars in a given direction
|
||||
|
@ -224,7 +224,7 @@ class nsStrPrivate {
|
|||
*/
|
||||
static PRInt32 FindSubstr1in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 FindSubstr1in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 FindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 FindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRInt32 anOffset,PRInt32 aCount);
|
||||
|
||||
static PRInt32 FindChar1(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 FindChar2(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount);
|
||||
|
@ -234,7 +234,7 @@ class nsStrPrivate {
|
|||
|
||||
static PRInt32 RFindSubstr1in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindSubstr1in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRInt32 anOffset,PRInt32 aCount);
|
||||
|
||||
static PRInt32 RFindChar1(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindChar2(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount);
|
||||
|
|
|
@ -410,7 +410,7 @@ nsString::ReplaceSubstring(const nsString& aTarget,const nsString& aNewValue){
|
|||
}
|
||||
else {
|
||||
PRInt32 theIndex=0;
|
||||
while(kNotFound!=(theIndex=nsStrPrivate::FindSubstr2in2(*this,aTarget,PR_FALSE,theIndex,mLength))) {
|
||||
while(kNotFound!=(theIndex=nsStrPrivate::FindSubstr2in2(*this,aTarget,theIndex,mLength))) {
|
||||
if(aNewValue.mLength<aTarget.mLength) {
|
||||
//Since target is longer than newValue, we should delete a few chars first, then overwrite.
|
||||
PRInt32 theDelLen=aTarget.mLength-aNewValue.mLength;
|
||||
|
@ -703,7 +703,7 @@ void nsString::AppendWithConversion(const char* aCString,PRInt32 aCount) {
|
|||
if(aCString && aCount){ //if astring is null or count==0 there's nothing to do
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eOneByte);
|
||||
temp.mStr=(char*)aCString;
|
||||
temp.mStr = NS_CONST_CAST(char*, aCString);
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=aCount;
|
||||
|
@ -796,7 +796,7 @@ void nsString::InsertWithConversion(const char* aCString,PRUint32 anOffset,PRInt
|
|||
if(aCString && aCount){
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eOneByte);
|
||||
temp.mStr=(char*)aCString;
|
||||
temp.mStr = NS_CONST_CAST(char*, aCString);
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=aCount;
|
||||
|
@ -852,7 +852,7 @@ PRInt32 nsString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset,
|
|||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eOneByte);
|
||||
temp.mLength=strlen(aCString);
|
||||
temp.mStr=(char*)aCString;
|
||||
temp.mStr = NS_CONST_CAST(char*, aCString);
|
||||
result=nsStrPrivate::FindSubstr1in2(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
|
@ -868,16 +868,16 @@ PRInt32 nsString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset,
|
|||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 nsString::Find(const PRUnichar* aString,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
NS_ASSERTION(0!=aString,kNullPointerError);
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
if(aString) {
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aString);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
result=nsStrPrivate::FindSubstr2in2(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
temp.mLength = nsCRT::strlen(aString);
|
||||
temp.mUStr = NS_CONST_CAST(PRUnichar*, aString);
|
||||
result=nsStrPrivate::FindSubstr2in2(*this,temp,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -892,8 +892,14 @@ PRInt32 nsString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOff
|
|||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::Find(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStrPrivate::FindSubstr2in2(*this,aString,aIgnoreCase,anOffset,aCount);
|
||||
PRInt32 nsString::Find(const nsAFlatString& aString,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp, eTwoByte);
|
||||
temp.mLength = aString.Length();
|
||||
temp.mUStr = NS_CONST_CAST(PRUnichar*, aString.get());
|
||||
|
||||
PRInt32 result=nsStrPrivate::FindSubstr2in2(*this,temp,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -914,7 +920,7 @@ PRInt32 nsString::FindCharInSet(const char* aCStringSet,PRInt32 anOffset) const{
|
|||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eOneByte);
|
||||
temp.mLength=strlen(aCStringSet);
|
||||
temp.mStr=(char*)aCStringSet;
|
||||
temp.mStr = NS_CONST_CAST(char*, aCStringSet);
|
||||
result=nsStrPrivate::FindCharInSet1(*this,temp,PR_FALSE,anOffset);
|
||||
}
|
||||
return result;
|
||||
|
@ -937,7 +943,7 @@ PRInt32 nsString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) co
|
|||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aStringSet);
|
||||
temp.mStr=(char*)aStringSet;
|
||||
temp.mUStr=NS_CONST_CAST(PRUnichar*, aStringSet);
|
||||
result=nsStrPrivate::FindCharInSet2(*this,temp,anOffset);
|
||||
}
|
||||
return result;
|
||||
|
@ -953,12 +959,17 @@ PRInt32 nsString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) co
|
|||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::RFind(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStrPrivate::RFindSubstr2in2(*this,aString,aIgnoreCase,anOffset,aCount);
|
||||
PRInt32 nsString::RFind(const nsAFlatString& aString,PRInt32 anOffset,PRInt32 aCount) const
|
||||
{
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp, eTwoByte);
|
||||
temp.mLength = aString.Length();
|
||||
temp.mUStr = NS_CONST_CAST(PRUnichar*, aString.get());
|
||||
PRInt32 result=nsStrPrivate::RFindSubstr2in2(*this,temp,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
PRInt32 nsString::RFind(const PRUnichar* aString, PRBool aIgnoreCase, PRInt32 anOffset, PRInt32 aCount) const
|
||||
PRInt32 nsString::RFind(const PRUnichar* aString, PRInt32 anOffset, PRInt32 aCount) const
|
||||
{
|
||||
PRInt32 result=kNotFound;
|
||||
if (aString) {
|
||||
|
@ -966,7 +977,7 @@ PRInt32 nsString::RFind(const PRUnichar* aString, PRBool aIgnoreCase, PRInt32 an
|
|||
nsStrPrivate::Initialize(temp, eTwoByte);
|
||||
temp.mLength = nsCRT::strlen(aString);
|
||||
temp.mUStr = NS_CONST_CAST(PRUnichar*, aString);
|
||||
result=nsStrPrivate::RFindSubstr2in2(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
result=nsStrPrivate::RFindSubstr2in2(*this,temp,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -989,7 +1000,7 @@ PRInt32 nsString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset,
|
|||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eOneByte);
|
||||
temp.mLength=strlen(aString);
|
||||
temp.mStr=(char*)aString;
|
||||
temp.mStr = NS_CONST_CAST(char*, aString);
|
||||
result=nsStrPrivate::RFindSubstr1in2(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
|
@ -1026,8 +1037,8 @@ PRInt32 nsString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c
|
|||
if(aStringSet) {
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aStringSet);
|
||||
temp.mUStr=(PRUnichar*)aStringSet;
|
||||
temp.mLength = nsCRT::strlen(aStringSet);
|
||||
temp.mUStr = NS_CONST_CAST(PRUnichar*, aStringSet);
|
||||
result=nsStrPrivate::RFindCharInSet2(*this,temp,anOffset);
|
||||
}
|
||||
return result;
|
||||
|
@ -1055,39 +1066,13 @@ PRInt32 nsString::CompareWithConversion(const char *aCString,PRBool aIgnoreCase,
|
|||
|
||||
temp.mLength= (0<aCount) ? aCount : strlen(aCString);
|
||||
|
||||
temp.mStr=(char*)aCString;
|
||||
temp.mStr = NS_CONST_CAST(char*, aCString);
|
||||
return nsStrPrivate::StrCompare2To1(*this,temp,aCount,aIgnoreCase);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares given unistring to this string.
|
||||
* @update gess 01/04/99
|
||||
* @param aString pts to a uni-string
|
||||
* @param aIgnoreCase tells us how to treat case
|
||||
* @param aCount tells us how many chars to test; -1 implies full length
|
||||
* @return -1,0,1
|
||||
*/
|
||||
PRInt32 nsString::CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
|
||||
NS_ASSERTION(0!=aString,kNullPointerError);
|
||||
|
||||
if(aString) {
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aString);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
return nsStrPrivate::StrCompare2To2(*this,temp,aCount,aIgnoreCase);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRBool nsString::EqualsIgnoreCase(const nsString& aString) const {
|
||||
return CompareWithConversion(aString.get(), PR_TRUE) == 0;
|
||||
}
|
||||
|
||||
PRBool nsString::EqualsIgnoreCase(const char* aString,PRInt32 aLength) const {
|
||||
return EqualsWithConversion(aString,PR_TRUE,aLength);
|
||||
}
|
||||
|
@ -1106,7 +1091,7 @@ PRBool nsString::EqualsWithConversion(const char* aString,PRBool aIgnoreCase,PRI
|
|||
return result;
|
||||
}
|
||||
|
||||
PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCount,PRBool aIgnoreCase);
|
||||
PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCount);
|
||||
/**
|
||||
* Compare this to given atom; note that we compare full strings here.
|
||||
* The optional length argument just lets us know how long the given string is.
|
||||
|
@ -1118,7 +1103,7 @@ PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCoun
|
|||
* @param aLength -- length of given string.
|
||||
* @return TRUE if equal
|
||||
*/
|
||||
PRBool nsString::EqualsAtom(/*FIX: const */nsIAtom* aAtom,PRBool aIgnoreCase) const{
|
||||
PRBool nsString::EqualsAtom(nsIAtom* aAtom) const{
|
||||
NS_ASSERTION(0!=aAtom,kNullPointerError);
|
||||
PRBool result=PR_FALSE;
|
||||
if(aAtom){
|
||||
|
@ -1126,7 +1111,7 @@ PRBool nsString::EqualsAtom(/*FIX: const */nsIAtom* aAtom,PRBool aIgnoreCase) co
|
|||
const PRUnichar* unicode;
|
||||
if (aAtom->GetUnicode(&unicode) != NS_OK || unicode == nsnull)
|
||||
return PR_FALSE;
|
||||
cmp=Compare2To2(mUStr,unicode, nsCRT::strlen(mUStr), aIgnoreCase);
|
||||
cmp=Compare2To2(mUStr,unicode, nsCRT::strlen(mUStr));
|
||||
result=PRBool(0==cmp);
|
||||
}
|
||||
|
||||
|
|
|
@ -309,10 +309,12 @@ public:
|
|||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 Find(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
PRInt32 Find(const nsCString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
|
||||
PRInt32 Find(const nsAFlatString& aString, PRInt32 anOffset=0, PRInt32 aCount=-1) const;
|
||||
|
||||
PRInt32 Find(const PRUnichar* aString, PRInt32 anOffset=0, PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the first character
|
||||
|
@ -336,8 +338,9 @@ public:
|
|||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 RFind(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
|
||||
PRInt32 RFind(const nsAFlatString& aString, PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -376,20 +379,11 @@ public:
|
|||
*/
|
||||
|
||||
PRInt32 CompareWithConversion(const char* aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aCount=-1) const;
|
||||
PRInt32 CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
/* a hack to make sure things that used to compile continue to compile
|
||||
even on compilers that don't have proper |explicit| support */
|
||||
inline PRInt32
|
||||
CompareWithConversion(const nsXPIDLString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aCount=-1) const
|
||||
{
|
||||
return CompareWithConversion(aString.get(), aIgnoreCase, aCount);
|
||||
}
|
||||
|
||||
|
||||
PRBool EqualsWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
|
||||
PRBool EqualsAtom(/*FIX: const */nsIAtom* anAtom,PRBool aIgnoreCase) const;
|
||||
PRBool EqualsAtom(nsIAtom* anAtom) const;
|
||||
|
||||
PRBool EqualsIgnoreCase(const nsString& aString) const;
|
||||
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
|
|
|
@ -210,6 +210,26 @@ NS_COM void ToLowerCase( const nsACString& aSource, nsACString& aDest );
|
|||
|
||||
NS_COM PRBool FindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() );
|
||||
NS_COM PRBool FindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() );
|
||||
|
||||
/* sometimes we don't care about where the string was, just that we
|
||||
* found it or not */
|
||||
inline PRBool FindInReadable( const nsAString& aPattern, nsAString& aSource, const nsStringComparator& compare = nsDefaultStringComparator() )
|
||||
{
|
||||
nsAString::const_iterator start, end;
|
||||
aSource.BeginReading(start);
|
||||
aSource.EndReading(end);
|
||||
return FindInReadable(aPattern, start, end, compare);
|
||||
}
|
||||
|
||||
inline PRBool FindInReadable( const nsACString& aPattern, nsACString& aSource, const nsCStringComparator& compare = nsDefaultCStringComparator() )
|
||||
{
|
||||
nsACString::const_iterator start, end;
|
||||
aSource.BeginReading(start);
|
||||
aSource.EndReading(end);
|
||||
return FindInReadable(aPattern, start, end, compare);
|
||||
}
|
||||
|
||||
|
||||
NS_COM PRBool CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator& );
|
||||
|
||||
/**
|
||||
|
@ -220,8 +240,8 @@ NS_COM PRBool CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACStr
|
|||
* Currently, this is equivalent to the O(m*n) implementation previously on |ns[C]String|.
|
||||
* If we need something faster, then we can implement that later.
|
||||
*/
|
||||
NS_COM PRBool RFindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator& );
|
||||
NS_COM PRBool RFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator& );
|
||||
NS_COM PRBool RFindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() );
|
||||
NS_COM PRBool RFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() );
|
||||
|
||||
/**
|
||||
* Finds the leftmost occurance of |aChar|, if any in the range
|
||||
|
|
|
@ -653,7 +653,7 @@ CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACString::const_ite
|
|||
*/
|
||||
NS_COM
|
||||
PRBool
|
||||
RFindInReadable( const nsAString& aPattern, nsAString::const_iterator& aSearchStart, nsAString::const_iterator& aSearchEnd )
|
||||
RFindInReadable( const nsAString& aPattern, nsAString::const_iterator& aSearchStart, nsAString::const_iterator& aSearchEnd, const nsStringComparator& aComparator)
|
||||
{
|
||||
PRBool found_it = PR_FALSE;
|
||||
|
||||
|
@ -662,7 +662,7 @@ RFindInReadable( const nsAString& aPattern, nsAString::const_iterator& aSearchSt
|
|||
|
||||
while ( searchStart != searchEnd )
|
||||
{
|
||||
if ( FindInReadable(aPattern, searchStart, searchEnd) )
|
||||
if ( FindInReadable(aPattern, searchStart, searchEnd, aComparator) )
|
||||
{
|
||||
found_it = PR_TRUE;
|
||||
|
||||
|
@ -686,7 +686,7 @@ RFindInReadable( const nsAString& aPattern, nsAString::const_iterator& aSearchSt
|
|||
|
||||
NS_COM
|
||||
PRBool
|
||||
RFindInReadable( const nsACString& aPattern, nsACString::const_iterator& aSearchStart, nsACString::const_iterator& aSearchEnd )
|
||||
RFindInReadable( const nsACString& aPattern, nsACString::const_iterator& aSearchStart, nsACString::const_iterator& aSearchEnd, const nsCStringComparator& aComparator)
|
||||
{
|
||||
PRBool found_it = PR_FALSE;
|
||||
|
||||
|
@ -695,7 +695,7 @@ RFindInReadable( const nsACString& aPattern, nsACString::const_iterator& aSearch
|
|||
|
||||
while ( searchStart != searchEnd )
|
||||
{
|
||||
if ( FindInReadable(aPattern, searchStart, searchEnd) )
|
||||
if ( FindInReadable(aPattern, searchStart, searchEnd, aComparator) )
|
||||
{
|
||||
found_it = PR_TRUE;
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#ifndef nsFilePicker_h__
|
||||
#define nsFilePicker_h__
|
||||
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
#include "nsICharsetConverterManager.h"
|
||||
|
|
|
@ -693,17 +693,9 @@ PRInt32 Compare1To1(const char* aStr1,const char* aStr2,PRUint32 aCount,PRBool a
|
|||
* @param aIgnorecase tells us whether to use a case-sensitive comparison
|
||||
* @return -1,0,1 depending on <,==,>
|
||||
*/
|
||||
PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCount,PRBool aIgnoreCase);
|
||||
PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCount,PRBool aIgnoreCase){
|
||||
PRInt32 result=0;
|
||||
#ifndef XPCOM_STANDALONE
|
||||
if(aIgnoreCase && NS_SUCCEEDED(NS_InitCaseConversion()))
|
||||
gCaseConv->CaseInsensitiveCompare(aStr1, aStr2, aCount, &result);
|
||||
else result=nsCRT::strncmp(aStr1,aStr2,aCount);
|
||||
#else
|
||||
NS_ERROR("call not supported in XPCOM_STANDALONE");
|
||||
#endif
|
||||
return result;
|
||||
PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCount);
|
||||
PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCount){
|
||||
return nsCRT::strncmp(aStr1, aStr2, aCount * sizeof(PRUnichar));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -647,7 +647,7 @@ PRInt32 nsStrPrivate::FindSubstr1in2(const nsStr& aDest,const nsStr& aTarget, PR
|
|||
return kNotFound;
|
||||
}
|
||||
|
||||
PRInt32 nsStrPrivate::FindSubstr2in2(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) {
|
||||
PRInt32 nsStrPrivate::FindSubstr2in2(const nsStr& aDest,const nsStr& aTarget, PRInt32 anOffset,PRInt32 aCount) {
|
||||
|
||||
NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
NS_ASSERTION(aTarget.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
|
@ -675,7 +675,7 @@ PRInt32 nsStrPrivate::FindSubstr2in2(const nsStr& aDest,const nsStr& aTarget, PR
|
|||
const PRUnichar* right = (last<max) ? last : max;
|
||||
|
||||
while(left<=right){
|
||||
PRInt32 cmp=Compare2To2(left,aTarget.mUStr,aTarget.mLength,aIgnoreCase);
|
||||
PRInt32 cmp=Compare2To2(left,aTarget.mUStr,aTarget.mLength);
|
||||
if(0==cmp) {
|
||||
return (left-root);
|
||||
}
|
||||
|
@ -857,7 +857,7 @@ PRInt32 nsStrPrivate::RFindSubstr1in2(const nsStr& aDest,const nsStr& aTarget,PR
|
|||
return kNotFound;
|
||||
}
|
||||
|
||||
PRInt32 nsStrPrivate::RFindSubstr2in2(const nsStr& aDest,const nsStr& aTarget,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) {
|
||||
PRInt32 nsStrPrivate::RFindSubstr2in2(const nsStr& aDest,const nsStr& aTarget,PRInt32 anOffset,PRInt32 aCount) {
|
||||
|
||||
NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
NS_ASSERTION(aTarget.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
|
@ -885,7 +885,7 @@ PRInt32 nsStrPrivate::RFindSubstr2in2(const nsStr& aDest,const nsStr& aTarget,PR
|
|||
while(leftmost<=rightmost) {
|
||||
//don't forget to divide by delta in next text (bug found by rhp)...
|
||||
if(aTarget.mLength<=PRUint32(destLast-rightmost)) {
|
||||
PRInt32 result = Compare2To2(rightmost,aTarget.mUStr,aTarget.mLength,aIgnoreCase);
|
||||
PRInt32 result = Compare2To2(rightmost,aTarget.mUStr,aTarget.mLength);
|
||||
|
||||
if(0==result) {
|
||||
return (rightmost-root);
|
||||
|
@ -1048,13 +1048,13 @@ PRInt32 nsStrPrivate::StrCompare2To1(const nsStr& aDest,const nsStr& aSource,PRI
|
|||
return 0;
|
||||
}
|
||||
|
||||
PRInt32 nsStrPrivate::StrCompare2To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
|
||||
PRInt32 nsStrPrivate::StrCompare2To2(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount) {
|
||||
NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
NS_ASSERTION(aSource.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
|
||||
if (aCount) {
|
||||
PRInt32 theCount = GetCompareCount(aDest.mLength, aSource.mLength, aCount);
|
||||
PRInt32 result = Compare2To2(aDest.mUStr, aSource.mUStr, theCount, aIgnoreCase);
|
||||
PRInt32 result = Compare2To2(aDest.mUStr, aSource.mUStr, theCount);
|
||||
result = TranslateCompareResult(aDest.mLength, aSource.mLength, result, aCount);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ class nsStrPrivate {
|
|||
static PRInt32 StrCompare2To1(const nsStr& aDest, const nsStr& aSource,
|
||||
PRInt32 aCount, PRBool aIgnoreCase);
|
||||
static PRInt32 StrCompare2To2(const nsStr& aDest, const nsStr& aSource,
|
||||
PRInt32 aCount, PRBool aIgnoreCase);
|
||||
PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* These methods scan the given string for 1 or more chars in a given direction
|
||||
|
@ -224,7 +224,7 @@ class nsStrPrivate {
|
|||
*/
|
||||
static PRInt32 FindSubstr1in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 FindSubstr1in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 FindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 FindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRInt32 anOffset,PRInt32 aCount);
|
||||
|
||||
static PRInt32 FindChar1(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 FindChar2(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount);
|
||||
|
@ -234,7 +234,7 @@ class nsStrPrivate {
|
|||
|
||||
static PRInt32 RFindSubstr1in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindSubstr1in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRInt32 anOffset,PRInt32 aCount);
|
||||
|
||||
static PRInt32 RFindChar1(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindChar2(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount);
|
||||
|
|
|
@ -410,7 +410,7 @@ nsString::ReplaceSubstring(const nsString& aTarget,const nsString& aNewValue){
|
|||
}
|
||||
else {
|
||||
PRInt32 theIndex=0;
|
||||
while(kNotFound!=(theIndex=nsStrPrivate::FindSubstr2in2(*this,aTarget,PR_FALSE,theIndex,mLength))) {
|
||||
while(kNotFound!=(theIndex=nsStrPrivate::FindSubstr2in2(*this,aTarget,theIndex,mLength))) {
|
||||
if(aNewValue.mLength<aTarget.mLength) {
|
||||
//Since target is longer than newValue, we should delete a few chars first, then overwrite.
|
||||
PRInt32 theDelLen=aTarget.mLength-aNewValue.mLength;
|
||||
|
@ -703,7 +703,7 @@ void nsString::AppendWithConversion(const char* aCString,PRInt32 aCount) {
|
|||
if(aCString && aCount){ //if astring is null or count==0 there's nothing to do
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eOneByte);
|
||||
temp.mStr=(char*)aCString;
|
||||
temp.mStr = NS_CONST_CAST(char*, aCString);
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=aCount;
|
||||
|
@ -796,7 +796,7 @@ void nsString::InsertWithConversion(const char* aCString,PRUint32 anOffset,PRInt
|
|||
if(aCString && aCount){
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eOneByte);
|
||||
temp.mStr=(char*)aCString;
|
||||
temp.mStr = NS_CONST_CAST(char*, aCString);
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=aCount;
|
||||
|
@ -852,7 +852,7 @@ PRInt32 nsString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset,
|
|||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eOneByte);
|
||||
temp.mLength=strlen(aCString);
|
||||
temp.mStr=(char*)aCString;
|
||||
temp.mStr = NS_CONST_CAST(char*, aCString);
|
||||
result=nsStrPrivate::FindSubstr1in2(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
|
@ -868,16 +868,16 @@ PRInt32 nsString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset,
|
|||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 nsString::Find(const PRUnichar* aString,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
NS_ASSERTION(0!=aString,kNullPointerError);
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
if(aString) {
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aString);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
result=nsStrPrivate::FindSubstr2in2(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
temp.mLength = nsCRT::strlen(aString);
|
||||
temp.mUStr = NS_CONST_CAST(PRUnichar*, aString);
|
||||
result=nsStrPrivate::FindSubstr2in2(*this,temp,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -892,8 +892,14 @@ PRInt32 nsString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOff
|
|||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::Find(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStrPrivate::FindSubstr2in2(*this,aString,aIgnoreCase,anOffset,aCount);
|
||||
PRInt32 nsString::Find(const nsAFlatString& aString,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp, eTwoByte);
|
||||
temp.mLength = aString.Length();
|
||||
temp.mUStr = NS_CONST_CAST(PRUnichar*, aString.get());
|
||||
|
||||
PRInt32 result=nsStrPrivate::FindSubstr2in2(*this,temp,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -914,7 +920,7 @@ PRInt32 nsString::FindCharInSet(const char* aCStringSet,PRInt32 anOffset) const{
|
|||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eOneByte);
|
||||
temp.mLength=strlen(aCStringSet);
|
||||
temp.mStr=(char*)aCStringSet;
|
||||
temp.mStr = NS_CONST_CAST(char*, aCStringSet);
|
||||
result=nsStrPrivate::FindCharInSet1(*this,temp,PR_FALSE,anOffset);
|
||||
}
|
||||
return result;
|
||||
|
@ -937,7 +943,7 @@ PRInt32 nsString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) co
|
|||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aStringSet);
|
||||
temp.mStr=(char*)aStringSet;
|
||||
temp.mUStr=NS_CONST_CAST(PRUnichar*, aStringSet);
|
||||
result=nsStrPrivate::FindCharInSet2(*this,temp,anOffset);
|
||||
}
|
||||
return result;
|
||||
|
@ -953,12 +959,17 @@ PRInt32 nsString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) co
|
|||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::RFind(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStrPrivate::RFindSubstr2in2(*this,aString,aIgnoreCase,anOffset,aCount);
|
||||
PRInt32 nsString::RFind(const nsAFlatString& aString,PRInt32 anOffset,PRInt32 aCount) const
|
||||
{
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp, eTwoByte);
|
||||
temp.mLength = aString.Length();
|
||||
temp.mUStr = NS_CONST_CAST(PRUnichar*, aString.get());
|
||||
PRInt32 result=nsStrPrivate::RFindSubstr2in2(*this,temp,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
PRInt32 nsString::RFind(const PRUnichar* aString, PRBool aIgnoreCase, PRInt32 anOffset, PRInt32 aCount) const
|
||||
PRInt32 nsString::RFind(const PRUnichar* aString, PRInt32 anOffset, PRInt32 aCount) const
|
||||
{
|
||||
PRInt32 result=kNotFound;
|
||||
if (aString) {
|
||||
|
@ -966,7 +977,7 @@ PRInt32 nsString::RFind(const PRUnichar* aString, PRBool aIgnoreCase, PRInt32 an
|
|||
nsStrPrivate::Initialize(temp, eTwoByte);
|
||||
temp.mLength = nsCRT::strlen(aString);
|
||||
temp.mUStr = NS_CONST_CAST(PRUnichar*, aString);
|
||||
result=nsStrPrivate::RFindSubstr2in2(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
result=nsStrPrivate::RFindSubstr2in2(*this,temp,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -989,7 +1000,7 @@ PRInt32 nsString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset,
|
|||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eOneByte);
|
||||
temp.mLength=strlen(aString);
|
||||
temp.mStr=(char*)aString;
|
||||
temp.mStr = NS_CONST_CAST(char*, aString);
|
||||
result=nsStrPrivate::RFindSubstr1in2(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
|
@ -1026,8 +1037,8 @@ PRInt32 nsString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c
|
|||
if(aStringSet) {
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aStringSet);
|
||||
temp.mUStr=(PRUnichar*)aStringSet;
|
||||
temp.mLength = nsCRT::strlen(aStringSet);
|
||||
temp.mUStr = NS_CONST_CAST(PRUnichar*, aStringSet);
|
||||
result=nsStrPrivate::RFindCharInSet2(*this,temp,anOffset);
|
||||
}
|
||||
return result;
|
||||
|
@ -1055,39 +1066,13 @@ PRInt32 nsString::CompareWithConversion(const char *aCString,PRBool aIgnoreCase,
|
|||
|
||||
temp.mLength= (0<aCount) ? aCount : strlen(aCString);
|
||||
|
||||
temp.mStr=(char*)aCString;
|
||||
temp.mStr = NS_CONST_CAST(char*, aCString);
|
||||
return nsStrPrivate::StrCompare2To1(*this,temp,aCount,aIgnoreCase);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares given unistring to this string.
|
||||
* @update gess 01/04/99
|
||||
* @param aString pts to a uni-string
|
||||
* @param aIgnoreCase tells us how to treat case
|
||||
* @param aCount tells us how many chars to test; -1 implies full length
|
||||
* @return -1,0,1
|
||||
*/
|
||||
PRInt32 nsString::CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
|
||||
NS_ASSERTION(0!=aString,kNullPointerError);
|
||||
|
||||
if(aString) {
|
||||
nsStr temp;
|
||||
nsStrPrivate::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aString);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
return nsStrPrivate::StrCompare2To2(*this,temp,aCount,aIgnoreCase);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRBool nsString::EqualsIgnoreCase(const nsString& aString) const {
|
||||
return CompareWithConversion(aString.get(), PR_TRUE) == 0;
|
||||
}
|
||||
|
||||
PRBool nsString::EqualsIgnoreCase(const char* aString,PRInt32 aLength) const {
|
||||
return EqualsWithConversion(aString,PR_TRUE,aLength);
|
||||
}
|
||||
|
@ -1106,7 +1091,7 @@ PRBool nsString::EqualsWithConversion(const char* aString,PRBool aIgnoreCase,PRI
|
|||
return result;
|
||||
}
|
||||
|
||||
PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCount,PRBool aIgnoreCase);
|
||||
PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCount);
|
||||
/**
|
||||
* Compare this to given atom; note that we compare full strings here.
|
||||
* The optional length argument just lets us know how long the given string is.
|
||||
|
@ -1118,7 +1103,7 @@ PRInt32 Compare2To2(const PRUnichar* aStr1,const PRUnichar* aStr2,PRUint32 aCoun
|
|||
* @param aLength -- length of given string.
|
||||
* @return TRUE if equal
|
||||
*/
|
||||
PRBool nsString::EqualsAtom(/*FIX: const */nsIAtom* aAtom,PRBool aIgnoreCase) const{
|
||||
PRBool nsString::EqualsAtom(nsIAtom* aAtom) const{
|
||||
NS_ASSERTION(0!=aAtom,kNullPointerError);
|
||||
PRBool result=PR_FALSE;
|
||||
if(aAtom){
|
||||
|
@ -1126,7 +1111,7 @@ PRBool nsString::EqualsAtom(/*FIX: const */nsIAtom* aAtom,PRBool aIgnoreCase) co
|
|||
const PRUnichar* unicode;
|
||||
if (aAtom->GetUnicode(&unicode) != NS_OK || unicode == nsnull)
|
||||
return PR_FALSE;
|
||||
cmp=Compare2To2(mUStr,unicode, nsCRT::strlen(mUStr), aIgnoreCase);
|
||||
cmp=Compare2To2(mUStr,unicode, nsCRT::strlen(mUStr));
|
||||
result=PRBool(0==cmp);
|
||||
}
|
||||
|
||||
|
|
|
@ -309,10 +309,12 @@ public:
|
|||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 Find(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
PRInt32 Find(const nsCString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
|
||||
PRInt32 Find(const nsAFlatString& aString, PRInt32 anOffset=0, PRInt32 aCount=-1) const;
|
||||
|
||||
PRInt32 Find(const PRUnichar* aString, PRInt32 anOffset=0, PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the first character
|
||||
|
@ -336,8 +338,9 @@ public:
|
|||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 RFind(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
|
||||
PRInt32 RFind(const nsAFlatString& aString, PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -376,20 +379,11 @@ public:
|
|||
*/
|
||||
|
||||
PRInt32 CompareWithConversion(const char* aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aCount=-1) const;
|
||||
PRInt32 CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
/* a hack to make sure things that used to compile continue to compile
|
||||
even on compilers that don't have proper |explicit| support */
|
||||
inline PRInt32
|
||||
CompareWithConversion(const nsXPIDLString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aCount=-1) const
|
||||
{
|
||||
return CompareWithConversion(aString.get(), aIgnoreCase, aCount);
|
||||
}
|
||||
|
||||
|
||||
PRBool EqualsWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
|
||||
PRBool EqualsAtom(/*FIX: const */nsIAtom* anAtom,PRBool aIgnoreCase) const;
|
||||
PRBool EqualsAtom(nsIAtom* anAtom) const;
|
||||
|
||||
PRBool EqualsIgnoreCase(const nsString& aString) const;
|
||||
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
|
|
|
@ -210,6 +210,26 @@ NS_COM void ToLowerCase( const nsACString& aSource, nsACString& aDest );
|
|||
|
||||
NS_COM PRBool FindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() );
|
||||
NS_COM PRBool FindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() );
|
||||
|
||||
/* sometimes we don't care about where the string was, just that we
|
||||
* found it or not */
|
||||
inline PRBool FindInReadable( const nsAString& aPattern, nsAString& aSource, const nsStringComparator& compare = nsDefaultStringComparator() )
|
||||
{
|
||||
nsAString::const_iterator start, end;
|
||||
aSource.BeginReading(start);
|
||||
aSource.EndReading(end);
|
||||
return FindInReadable(aPattern, start, end, compare);
|
||||
}
|
||||
|
||||
inline PRBool FindInReadable( const nsACString& aPattern, nsACString& aSource, const nsCStringComparator& compare = nsDefaultCStringComparator() )
|
||||
{
|
||||
nsACString::const_iterator start, end;
|
||||
aSource.BeginReading(start);
|
||||
aSource.EndReading(end);
|
||||
return FindInReadable(aPattern, start, end, compare);
|
||||
}
|
||||
|
||||
|
||||
NS_COM PRBool CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator& );
|
||||
|
||||
/**
|
||||
|
@ -220,8 +240,8 @@ NS_COM PRBool CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACStr
|
|||
* Currently, this is equivalent to the O(m*n) implementation previously on |ns[C]String|.
|
||||
* If we need something faster, then we can implement that later.
|
||||
*/
|
||||
NS_COM PRBool RFindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator& );
|
||||
NS_COM PRBool RFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator& );
|
||||
NS_COM PRBool RFindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() );
|
||||
NS_COM PRBool RFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() );
|
||||
|
||||
/**
|
||||
* Finds the leftmost occurance of |aChar|, if any in the range
|
||||
|
|
|
@ -653,7 +653,7 @@ CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACString::const_ite
|
|||
*/
|
||||
NS_COM
|
||||
PRBool
|
||||
RFindInReadable( const nsAString& aPattern, nsAString::const_iterator& aSearchStart, nsAString::const_iterator& aSearchEnd )
|
||||
RFindInReadable( const nsAString& aPattern, nsAString::const_iterator& aSearchStart, nsAString::const_iterator& aSearchEnd, const nsStringComparator& aComparator)
|
||||
{
|
||||
PRBool found_it = PR_FALSE;
|
||||
|
||||
|
@ -662,7 +662,7 @@ RFindInReadable( const nsAString& aPattern, nsAString::const_iterator& aSearchSt
|
|||
|
||||
while ( searchStart != searchEnd )
|
||||
{
|
||||
if ( FindInReadable(aPattern, searchStart, searchEnd) )
|
||||
if ( FindInReadable(aPattern, searchStart, searchEnd, aComparator) )
|
||||
{
|
||||
found_it = PR_TRUE;
|
||||
|
||||
|
@ -686,7 +686,7 @@ RFindInReadable( const nsAString& aPattern, nsAString::const_iterator& aSearchSt
|
|||
|
||||
NS_COM
|
||||
PRBool
|
||||
RFindInReadable( const nsACString& aPattern, nsACString::const_iterator& aSearchStart, nsACString::const_iterator& aSearchEnd )
|
||||
RFindInReadable( const nsACString& aPattern, nsACString::const_iterator& aSearchStart, nsACString::const_iterator& aSearchEnd, const nsCStringComparator& aComparator)
|
||||
{
|
||||
PRBool found_it = PR_FALSE;
|
||||
|
||||
|
@ -695,7 +695,7 @@ RFindInReadable( const nsACString& aPattern, nsACString::const_iterator& aSearch
|
|||
|
||||
while ( searchStart != searchEnd )
|
||||
{
|
||||
if ( FindInReadable(aPattern, searchStart, searchEnd) )
|
||||
if ( FindInReadable(aPattern, searchStart, searchEnd, aComparator) )
|
||||
{
|
||||
found_it = PR_TRUE;
|
||||
|
||||
|
|
|
@ -2386,7 +2386,9 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
|
|||
}
|
||||
|
||||
// update icon?
|
||||
if (schedule.Find(NS_LITERAL_STRING("icon").get(), PR_TRUE, 0) >= 0)
|
||||
if (FindInReadable(NS_LITERAL_STRING("icon"),
|
||||
schedule,
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
nsCOMPtr<nsIRDFLiteral> statusLiteral;
|
||||
if (NS_SUCCEEDED(rv = gRDF->GetLiteral(NS_LITERAL_STRING("new").get(), getter_AddRefs(statusLiteral))))
|
||||
|
@ -2406,7 +2408,9 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
|
|||
}
|
||||
|
||||
// play a sound?
|
||||
if (schedule.Find(NS_LITERAL_STRING("sound").get(), PR_TRUE, 0) >= 0)
|
||||
if (FindInReadable(NS_LITERAL_STRING("sound"),
|
||||
schedule,
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
nsCOMPtr<nsISound> soundInterface;
|
||||
rv = nsComponentManager::CreateInstance(kSoundCID,
|
||||
|
@ -2422,7 +2426,9 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
|
|||
PRBool openURLFlag = PR_FALSE;
|
||||
|
||||
// show an alert?
|
||||
if (schedule.Find(NS_LITERAL_STRING("alert").get(), PR_TRUE, 0) >= 0)
|
||||
if (FindInReadable(NS_LITERAL_STRING("alert"),
|
||||
schedule,
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceRequestor> interfaces;
|
||||
nsCOMPtr<nsIPrompt> prompter;
|
||||
|
@ -2496,10 +2502,12 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// open the URL in a new window?
|
||||
if ((openURLFlag == PR_TRUE) ||
|
||||
(schedule.Find(NS_LITERAL_STRING("open").get(), PR_TRUE, 0) >= 0))
|
||||
FindInReadable(NS_LITERAL_STRING("open"),
|
||||
schedule,
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
|
|
@ -3847,9 +3847,9 @@ nsGlobalHistory::AutoCompleteEnumerator::IsResult(nsIMdbRow* aRow)
|
|||
nsCAutoString url;
|
||||
mHistory->GetRowValue(aRow, mURLColumn, url);
|
||||
|
||||
nsAutoString url2;
|
||||
url2.AssignWithConversion(url.get());
|
||||
PRBool result = mHistory->AutoCompleteCompare(url2, mSelectValue, mExclude);
|
||||
NS_ConvertUTF8toUCS2 utf8Url(url);
|
||||
|
||||
PRBool result = mHistory->AutoCompleteCompare(utf8Url, mSelectValue, mExclude);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -359,7 +359,7 @@ NS_IMPL_ISUPPORTS1(nsCharsetMenuObserver, nsIObserver);
|
|||
NS_IMETHODIMP nsCharsetMenuObserver::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
|
||||
{
|
||||
NS_TIMELINE_START_TIMER("nsCharsetMenu:Observe");
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
//XUL event handler
|
||||
if (!nsCRT::strcmp(aTopic, "charsetmenu-selected")) {
|
||||
|
@ -1755,7 +1755,7 @@ nsresult nsCharsetMenu::GetCollation(nsICollation ** aCollation)
|
|||
NS_IMETHODIMP nsCharsetMenu::SetCurrentCharset(const PRUnichar * aCharset)
|
||||
{
|
||||
NS_TIMELINE_START_TIMER("nsCharsetMenu:SetCurrentCharset");
|
||||
nsresult res;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (mBrowserMenuInitialized) {
|
||||
nsCOMPtr<nsIAtom> atom;
|
||||
|
@ -1785,7 +1785,7 @@ NS_IMETHODIMP nsCharsetMenu::SetCurrentCharset(const PRUnichar * aCharset)
|
|||
NS_IMETHODIMP nsCharsetMenu::SetCurrentMailCharset(const PRUnichar * aCharset)
|
||||
{
|
||||
NS_TIMELINE_START_TIMER("nsCharsetMenu:SetCurrentMailCharset");
|
||||
nsresult res;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (mMailviewMenuInitialized) {
|
||||
nsCOMPtr<nsIAtom> atom;
|
||||
|
@ -1810,7 +1810,7 @@ NS_IMETHODIMP nsCharsetMenu::SetCurrentMailCharset(const PRUnichar * aCharset)
|
|||
NS_IMETHODIMP nsCharsetMenu::SetCurrentComposerCharset(const PRUnichar * aCharset)
|
||||
{
|
||||
NS_TIMELINE_START_TIMER("nsCharsetMenu:SetCurrentComposerCharset");
|
||||
nsresult res;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (mComposerMenuInitialized) {
|
||||
nsCOMPtr<nsIAtom> atom;
|
||||
|
|
|
@ -35,6 +35,7 @@ REQUIRES = xpcom \
|
|||
pref \
|
||||
uconv \
|
||||
intl \
|
||||
unicharutil \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
#include "nsIStringBundle.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
@ -126,7 +127,38 @@ static const char kSearchCommand[] = "http://home.netscape.co
|
|||
|
||||
int PR_CALLBACK searchModePrefCallback(const char *pref, void *aClosure);
|
||||
|
||||
// helper routine because we need to rewrite this to use string
|
||||
// iterators.. this replaces the old nsString::Find
|
||||
|
||||
static PRInt32 nsString_Find(nsAString& aPattern,
|
||||
nsAString& aSource,
|
||||
PRBool aIgnoreCase = PR_FALSE,
|
||||
PRInt32 aOffset = 0, PRInt32 aCount = -1)
|
||||
{
|
||||
nsAString::const_iterator start, end;
|
||||
aSource.BeginReading(start);
|
||||
aSource.EndReading(end);
|
||||
|
||||
// now adjust for the parameters
|
||||
start.advance(aOffset);
|
||||
if (aCount>0) {
|
||||
end = start; // note that start may have been advanced!
|
||||
end.advance(aCount);
|
||||
}
|
||||
PRBool found;
|
||||
if (aIgnoreCase)
|
||||
found = FindInReadable(aPattern, start, end,
|
||||
nsCaseInsensitiveStringComparator());
|
||||
else
|
||||
found = FindInReadable(aPattern, start, end);
|
||||
|
||||
if (!found)
|
||||
return kNotFound;
|
||||
|
||||
nsAString::const_iterator originalStart;
|
||||
aSource.BeginReading(originalStart);
|
||||
return Distance(originalStart, start);
|
||||
}
|
||||
|
||||
class InternetSearchContext : public nsIInternetSearchContext
|
||||
{
|
||||
|
@ -2118,7 +2150,7 @@ InternetSearchDataSource::filterSite(nsIRDFResource *aResource)
|
|||
if (slashOffset2 <= slashOffset1) return(NS_ERROR_UNEXPECTED);
|
||||
site.Truncate(slashOffset2 + 1);
|
||||
|
||||
if (site.EqualsIgnoreCase(host))
|
||||
if (site.Equals(host, nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
mInner->Unassert(aSearchRoot, kNC_Child, aRes);
|
||||
}
|
||||
|
@ -2490,8 +2522,9 @@ InternetSearchDataSource::GetInternetSearchURL(const char *searchEngineURI,
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> dataLit;
|
||||
if (NS_FAILED(rv = FindData(engine, getter_AddRefs(dataLit))) ||
|
||||
(rv == NS_RDF_NO_VALUE)) return(rv);
|
||||
rv = FindData(engine, getter_AddRefs(dataLit));
|
||||
if (NS_FAILED(rv) ||
|
||||
(rv == NS_RDF_NO_VALUE)) return(rv);
|
||||
if (!dataLit) return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
const PRUnichar *dataUni = nsnull;
|
||||
|
@ -2542,9 +2575,12 @@ InternetSearchDataSource::GetInternetSearchURL(const char *searchEngineURI,
|
|||
}
|
||||
|
||||
nsAutoString action, input, method, userVar;
|
||||
if (NS_FAILED(rv = GetData(dataUni, "search", 0, "action", action))) return(rv);
|
||||
if (NS_FAILED(rv = GetData(dataUni, "search", 0, "method", method))) return(rv);
|
||||
if (NS_FAILED(rv = GetInputs(dataUni, userVar, text, input))) return(rv);
|
||||
if (NS_FAILED(rv = GetData(dataUni, "search", 0, "action", action)))
|
||||
return(rv);
|
||||
if (NS_FAILED(rv = GetData(dataUni, "search", 0, "method", method)))
|
||||
return(rv);
|
||||
if (NS_FAILED(rv = GetInputs(dataUni, userVar, text, input)))
|
||||
return(rv);
|
||||
if (input.Length() < 1) return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
// we can only handle HTTP GET
|
||||
|
@ -2653,7 +2689,7 @@ InternetSearchDataSource::FindInternetSearchResults(const char *url, PRBool *sea
|
|||
|
||||
nsAutoString action;
|
||||
if (NS_FAILED(rv = GetData(dataUni, "search", 0, "action", action))) continue;
|
||||
if (shortURL.EqualsIgnoreCase(action))
|
||||
if (shortURL.Equals(action, nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
foundEngine = PR_TRUE;
|
||||
break;
|
||||
|
@ -2661,7 +2697,7 @@ InternetSearchDataSource::FindInternetSearchResults(const char *url, PRBool *sea
|
|||
|
||||
// extension for engines which can have multiple "actions"
|
||||
if (NS_FAILED(rv = GetData(dataUni, "browser", 0, "alsomatch", action))) continue;
|
||||
if (action.Find(shortURL, PR_TRUE) >= 0)
|
||||
if (nsString_Find(shortURL, action, PR_TRUE) >= 0)
|
||||
{
|
||||
foundEngine = PR_TRUE;
|
||||
break;
|
||||
|
@ -2684,12 +2720,12 @@ InternetSearchDataSource::FindInternetSearchResults(const char *url, PRBool *sea
|
|||
NS_LITERAL_STRING("=");
|
||||
|
||||
PRInt32 queryOffset;
|
||||
if ((queryOffset = searchURL.Find(queryStr, PR_TRUE )) < 0)
|
||||
if ((queryOffset = nsString_Find(queryStr, searchURL, PR_TRUE )) < 0)
|
||||
{
|
||||
queryStr = NS_LITERAL_STRING("&") +
|
||||
userVar +
|
||||
NS_LITERAL_STRING("=");
|
||||
queryOffset = searchURL.Find(queryStr, PR_TRUE);
|
||||
queryOffset = nsString_Find(queryStr, searchURL, PR_TRUE);
|
||||
}
|
||||
|
||||
nsAutoString searchText;
|
||||
|
@ -4154,8 +4190,7 @@ InternetSearchDataSource::GetNumInterpretSections(const PRUnichar *dataUni, PRUi
|
|||
|
||||
nsString buffer(dataUni);
|
||||
|
||||
nsAutoString section;
|
||||
section.Assign(NS_LITERAL_STRING("<interpret"));
|
||||
NS_NAMED_LITERAL_STRING(section, "<interpret");
|
||||
PRBool inSection = PR_FALSE;
|
||||
|
||||
while(buffer.Length() > 0)
|
||||
|
@ -4173,7 +4208,7 @@ InternetSearchDataSource::GetNumInterpretSections(const PRUnichar *dataUni, PRUi
|
|||
line.Trim(" \t");
|
||||
if (inSection == PR_FALSE)
|
||||
{
|
||||
PRInt32 sectionOffset = line.Find(section, PR_TRUE);
|
||||
PRInt32 sectionOffset = nsString_Find(section, line, PR_TRUE);
|
||||
if (sectionOffset < 0) continue;
|
||||
line.Cut(0, sectionOffset + section.Length() + 1);
|
||||
inSection = PR_TRUE;
|
||||
|
@ -4222,7 +4257,7 @@ InternetSearchDataSource::GetData(const PRUnichar *dataUni, const char *sectionT
|
|||
line.Trim(" \t");
|
||||
if (inSection == PR_FALSE)
|
||||
{
|
||||
PRInt32 sectionOffset = line.Find(section, PR_TRUE);
|
||||
PRInt32 sectionOffset = nsString_Find(section, line, PR_TRUE);
|
||||
if (sectionOffset < 0) continue;
|
||||
if (sectionNum > 0)
|
||||
{
|
||||
|
@ -4984,12 +5019,12 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
nsCOMPtr<nsIRDFLiteral> bannerLiteral;
|
||||
if ((!bannerStartStr.IsEmpty()) && (!bannerEndStr.IsEmpty()))
|
||||
{
|
||||
PRInt32 bannerStart = htmlResults.Find(bannerStartStr, PR_TRUE);
|
||||
PRInt32 bannerStart = nsString_Find(bannerStartStr, htmlResults, PR_TRUE);
|
||||
if (bannerStart >= 0)
|
||||
{
|
||||
startIndex = bannerStart;
|
||||
|
||||
PRInt32 bannerEnd = htmlResults.Find(bannerEndStr, PR_TRUE, bannerStart + bannerStartStr.Length());
|
||||
PRInt32 bannerEnd = nsString_Find(bannerEndStr,htmlResults, PR_TRUE, bannerStart + bannerStartStr.Length());
|
||||
if (bannerEnd > bannerStart)
|
||||
{
|
||||
stopIndex = bannerEnd - 1;
|
||||
|
@ -5010,7 +5045,7 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
|
||||
if (!resultListStartStr.IsEmpty())
|
||||
{
|
||||
PRInt32 resultListStart = htmlResults.Find(resultListStartStr, PR_TRUE);
|
||||
PRInt32 resultListStart = nsString_Find(resultListStartStr, htmlResults, PR_TRUE);
|
||||
if (resultListStart >= 0)
|
||||
{
|
||||
startIndex = resultListStart + resultListStartStr.Length();
|
||||
|
@ -5024,12 +5059,16 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
}
|
||||
if (!resultListEndStr.IsEmpty())
|
||||
{
|
||||
// rjc note: use RFind to find the LAST occurrence of resultListEndStr
|
||||
PRInt32 resultListEnd = htmlResults.RFind(resultListEndStr, PR_TRUE);
|
||||
if (resultListEnd >= 0)
|
||||
{
|
||||
stopIndex = resultListEnd;
|
||||
}
|
||||
// rjc note: use RFind to find the LAST
|
||||
// occurrence of resultListEndStr
|
||||
|
||||
nsAString::const_iterator originalStart, start, end;
|
||||
htmlResults.BeginReading(start);
|
||||
htmlResults.EndReading(end);
|
||||
originalStart = start;
|
||||
|
||||
if (RFindInReadable(resultListEndStr, start, end))
|
||||
stopIndex = Distance(originalStart, start);
|
||||
}
|
||||
|
||||
PRBool trimItemStart = PR_TRUE;
|
||||
|
@ -5052,18 +5091,18 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
while(startIndex < stopIndex)
|
||||
{
|
||||
PRInt32 resultItemStart;
|
||||
resultItemStart = htmlResults.Find(resultItemStartStr, PR_TRUE, startIndex);
|
||||
resultItemStart = nsString_Find(resultItemStartStr, htmlResults, PR_TRUE, startIndex);
|
||||
if (resultItemStart < 0) break;
|
||||
|
||||
PRInt32 resultItemEnd;
|
||||
if (trimItemStart == PR_TRUE)
|
||||
{
|
||||
resultItemStart += resultItemStartStr.Length();
|
||||
resultItemEnd = htmlResults.Find(resultItemEndStr, PR_TRUE, resultItemStart);
|
||||
resultItemEnd = nsString_Find(resultItemEndStr, htmlResults, PR_TRUE, resultItemStart);
|
||||
}
|
||||
else
|
||||
{
|
||||
resultItemEnd = htmlResults.Find(resultItemEndStr, PR_TRUE, resultItemStart + resultItemStartStr.Length());
|
||||
resultItemEnd = nsString_Find(resultItemEndStr, htmlResults, PR_TRUE, resultItemStart + resultItemStartStr.Length());
|
||||
}
|
||||
|
||||
if (resultItemEnd < 0)
|
||||
|
@ -5112,7 +5151,7 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
{
|
||||
// handle case where HREF isn't quoted
|
||||
quoteStartOffset = hrefOffset + strlen("HREF=");
|
||||
quoteEndOffset = resultItem.FindCharInSet(">", quoteStartOffset);
|
||||
quoteEndOffset = resultItem.FindChar('>', quoteStartOffset);
|
||||
if (quoteEndOffset < quoteStartOffset) continue;
|
||||
}
|
||||
else
|
||||
|
@ -5160,7 +5199,7 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
PRInt32 pathOptionsOffset = absPathStr.FindChar(PRUnichar('?'));
|
||||
if (pathOptionsOffset >= 0)
|
||||
absPathStr.Truncate(pathOptionsOffset);
|
||||
PRBool pathsMatchFlag = serverPathStr.EqualsIgnoreCase(absPathStr);
|
||||
PRBool pathsMatchFlag = serverPathStr.Equals(absPathStr, nsCaseInsensitiveStringComparator());
|
||||
if (pathsMatchFlag == PR_TRUE) continue;
|
||||
}
|
||||
|
||||
|
@ -5240,7 +5279,7 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
mInner->GetTarget(res, kNC_Site, PR_TRUE, getter_AddRefs(oldSiteRes));
|
||||
if (!oldSiteRes)
|
||||
{
|
||||
PRInt32 protocolOffset = site.FindCharInSet(":", 0);
|
||||
PRInt32 protocolOffset = site.FindChar(':', 0);
|
||||
if (protocolOffset >= 0)
|
||||
{
|
||||
site.Cut(0, protocolOffset+1);
|
||||
|
@ -5248,7 +5287,7 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
{
|
||||
site.Cut(0, 1);
|
||||
}
|
||||
PRInt32 slashOffset = site.FindCharInSet("/", 0);
|
||||
PRInt32 slashOffset = site.FindChar('/', 0);
|
||||
if (slashOffset >= 0)
|
||||
{
|
||||
site.Truncate(slashOffset);
|
||||
|
@ -5277,10 +5316,10 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
if ((!nameStartStr.IsEmpty()) && (!nameEndStr.IsEmpty()))
|
||||
{
|
||||
PRInt32 nameStart;
|
||||
if ((nameStart = resultItem.Find(nameStartStr, PR_TRUE)) >= 0)
|
||||
if ((nameStart = nsString_Find(nameStartStr, resultItem, PR_TRUE)) >= 0)
|
||||
{
|
||||
nameStart += nameStartStr.Length();
|
||||
PRInt32 nameEnd = resultItem.Find(nameEndStr, PR_TRUE, nameStart);
|
||||
PRInt32 nameEnd = nsString_Find(nameEndStr, resultItem, PR_TRUE, nameStart);
|
||||
if (nameEnd > nameStart)
|
||||
{
|
||||
resultItem.Mid(nameStr, nameStart, nameEnd - nameStart);
|
||||
|
@ -5290,7 +5329,7 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
|
||||
if (nameStr.IsEmpty())
|
||||
{
|
||||
PRInt32 anchorEnd = resultItem.FindCharInSet(">", quoteEndOffset);
|
||||
PRInt32 anchorEnd = resultItem.FindChar('>', quoteEndOffset);
|
||||
if (anchorEnd < quoteEndOffset)
|
||||
{
|
||||
#ifdef DEBUG_SEARCH_OUTPUT
|
||||
|
@ -5340,10 +5379,10 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
{
|
||||
nsAutoString dateItem;
|
||||
PRInt32 dateStart;
|
||||
if ((dateStart = resultItem.Find(dateStartStr, PR_TRUE)) >= 0)
|
||||
if ((dateStart = nsString_Find(dateStartStr, resultItem, PR_TRUE)) >= 0)
|
||||
{
|
||||
dateStart += dateStartStr.Length();
|
||||
PRInt32 dateEnd = resultItem.Find(dateEndStr, PR_TRUE, dateStart);
|
||||
PRInt32 dateEnd = nsString_Find(dateEndStr, resultItem, PR_TRUE, dateStart);
|
||||
if (dateEnd > dateStart)
|
||||
{
|
||||
resultItem.Mid(dateItem, dateStart, dateEnd - dateStart);
|
||||
|
@ -5382,10 +5421,10 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
{
|
||||
nsAutoString priceItem;
|
||||
PRInt32 priceStart;
|
||||
if ((priceStart = resultItem.Find(priceStartStr, PR_TRUE)) >= 0)
|
||||
if ((priceStart = nsString_Find(priceStartStr, resultItem, PR_TRUE)) >= 0)
|
||||
{
|
||||
priceStart += priceStartStr.Length();
|
||||
PRInt32 priceEnd = resultItem.Find(priceEndStr, PR_TRUE, priceStart);
|
||||
PRInt32 priceEnd = nsString_Find(priceEndStr, resultItem, PR_TRUE, priceStart);
|
||||
if (priceEnd > priceStart)
|
||||
{
|
||||
resultItem.Mid(priceItem, priceStart, priceEnd - priceStart);
|
||||
|
@ -5428,10 +5467,10 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
{
|
||||
nsAutoString availItem;
|
||||
PRInt32 availStart;
|
||||
if ((availStart = resultItem.Find(availStartStr, PR_TRUE)) >= 0)
|
||||
if ((availStart = nsString_Find(availStartStr, resultItem, PR_TRUE)) >= 0)
|
||||
{
|
||||
availStart += availStartStr.Length();
|
||||
PRInt32 availEnd = resultItem.Find(availEndStr, PR_TRUE, availStart);
|
||||
PRInt32 availEnd = nsString_Find(availEndStr, resultItem, PR_TRUE, availStart);
|
||||
if (availEnd > availStart)
|
||||
{
|
||||
resultItem.Mid(availItem, availStart, availEnd - availStart);
|
||||
|
@ -5457,10 +5496,10 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
|||
// look for relevance
|
||||
nsAutoString relItem;
|
||||
PRInt32 relStart;
|
||||
if ((relStart = resultItem.Find(relevanceStartStr, PR_TRUE)) >= 0)
|
||||
if ((relStart = nsString_Find(relevanceStartStr, resultItem, PR_TRUE)) >= 0)
|
||||
{
|
||||
relStart += relevanceStartStr.Length();
|
||||
PRInt32 relEnd = resultItem.Find(relevanceEndStr, PR_TRUE);
|
||||
PRInt32 relEnd = nsString_Find(relevanceEndStr, resultItem, PR_TRUE);
|
||||
if (relEnd > relStart)
|
||||
{
|
||||
resultItem.Mid(relItem, relStart, relEnd - relStart);
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
#include "nsIRDFContainerUtils.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "xp_core.h"
|
||||
#include "plhash.h"
|
||||
#include "plstr.h"
|
||||
|
@ -360,38 +362,53 @@ LocalSearchDataSource::doMatch(nsIRDFLiteral *literal,
|
|||
literal->GetValueConst( &str );
|
||||
if (! str) return(found);
|
||||
nsAutoString value(str);
|
||||
|
||||
|
||||
if (matchMethod.Equals(NS_LITERAL_STRING("contains")))
|
||||
{
|
||||
if (value.Find(matchText, PR_TRUE) >= 0)
|
||||
if (FindInReadable(matchText, value,
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else if (matchMethod.Equals(NS_LITERAL_STRING("startswith")))
|
||||
{
|
||||
if (value.Find(matchText, PR_TRUE) == 0)
|
||||
nsAString::const_iterator start, realstart, end;
|
||||
value.BeginReading(start);
|
||||
value.EndReading(end);
|
||||
realstart = start;
|
||||
|
||||
if (FindInReadable(matchText, start, end,
|
||||
nsCaseInsensitiveStringComparator()) &&
|
||||
start == realstart)
|
||||
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else if (matchMethod.Equals(NS_LITERAL_STRING("endswith")))
|
||||
{
|
||||
PRInt32 pos = value.RFind(matchText, PR_TRUE);
|
||||
if ((pos >= 0) &&
|
||||
(pos == (PRInt32(value.Length()) -
|
||||
PRInt32(matchText.Length()))))
|
||||
nsAString::const_iterator start, end, realend;
|
||||
value.BeginReading(start);
|
||||
value.EndReading(end);
|
||||
realend = end;
|
||||
|
||||
if (RFindInReadable(matchText, start, end,
|
||||
nsCaseInsensitiveStringComparator()) &&
|
||||
end == realend)
|
||||
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else if (matchMethod.Equals(NS_LITERAL_STRING("is")))
|
||||
{
|
||||
if (value.EqualsIgnoreCase(matchText))
|
||||
if (value.Equals(matchText, nsCaseInsensitiveStringComparator()))
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else if (matchMethod.Equals(NS_LITERAL_STRING("isnot")))
|
||||
{
|
||||
if (!value.EqualsIgnoreCase(matchText))
|
||||
if (!value.Equals(matchText, nsCaseInsensitiveStringComparator()))
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else if (matchMethod.Equals(NS_LITERAL_STRING("doesntcontain")))
|
||||
{
|
||||
if (value.Find(matchText, PR_TRUE) < 0)
|
||||
if (!FindInReadable(matchText, value,
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
found = PR_TRUE;
|
||||
}
|
||||
return(found);
|
||||
|
|
|
@ -253,11 +253,13 @@ nsUrlbarHistory::OnStartLookup(const PRUnichar *uSearchString, nsIAutoCompleteRe
|
|||
nsString * match = (nsString *)mIgnoreArray.ElementAt(i);
|
||||
|
||||
if (match) {
|
||||
PRInt32 index = match->Find(uSearchString, PR_TRUE);
|
||||
if (index == 0) {
|
||||
listener->OnAutoComplete(nsnull, nsIAutoCompleteStatus::ignored);
|
||||
return NS_OK;
|
||||
}
|
||||
nsDependentString searchString(uSearchString);
|
||||
if (searchString.Length() <= match->Length() &&
|
||||
searchString.Equals(Substring(*match, 0, searchString.Length()),
|
||||
nsCaseInsensitiveStringComparator())) {
|
||||
listener->OnAutoComplete(nsnull, nsIAutoCompleteStatus::ignored);
|
||||
return NS_OK;
|
||||
}
|
||||
} // match
|
||||
} //for
|
||||
|
||||
|
@ -472,8 +474,10 @@ nsUrlbarHistory::SearchCache(const PRUnichar* searchStr, nsIAutoCompleteResults*
|
|||
// NS_LossyConvertUCS2toASCII(rdfProtocol).get());
|
||||
// We have all the data we need. Let's do the comparison
|
||||
// We compare the path first and compare the protocol next
|
||||
index = rdfPath.Find(searchPath, PR_TRUE);
|
||||
if (index == 0) {
|
||||
|
||||
if (rdfPath.Length() >= searchPath.Length() &&
|
||||
searchPath.Equals(Substring(rdfPath, 0, searchPath.Length()),
|
||||
nsCaseInsensitiveStringComparator())) {
|
||||
// The paths match. Now let's compare protocols
|
||||
if (searchProtocol.Length() && rdfProtocol.Length()) {
|
||||
// Both the strings have a protocol part. Compare them.
|
||||
|
|
Загрузка…
Ссылка в новой задаче