From 8c4b91906faa3181ca944148079d85c002a1f1bf Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Sun, 12 Mar 2000 09:23:40 +0000 Subject: [PATCH] removed nsStr references --- htmlparser/src/nsHTMLEntities.cpp | 26 ++++++++++++++++++++++++ htmlparser/src/nsHTMLEntities.h | 1 + parser/htmlparser/src/nsHTMLEntities.cpp | 26 ++++++++++++++++++++++++ parser/htmlparser/src/nsHTMLEntities.h | 1 + 4 files changed, 54 insertions(+) diff --git a/htmlparser/src/nsHTMLEntities.cpp b/htmlparser/src/nsHTMLEntities.cpp index 4aeffeb40635..6c178ae6e12f 100644 --- a/htmlparser/src/nsHTMLEntities.cpp +++ b/htmlparser/src/nsHTMLEntities.cpp @@ -173,6 +173,32 @@ nsHTMLEntities::EntityToUnicode(const nsString& aEntity) return -1; } +PRInt32 +nsHTMLEntities::EntityToUnicode(const nsCString& aEntity) +{ + NS_ASSERTION(gEntityToCodeTree, "no lookup table, needs addref"); + if (gEntityToCodeTree) { + + //this little piece of code exists because entities may or may not have the terminating ';'. + //if we see it, strip if off for this test... + + PRUnichar theLastChar=GetCharAt(aEntity,aEntity.mLength-1); + if(';'==theLastChar) { + nsCAutoString temp(aEntity); + temp.Truncate(aEntity.mLength-1); + return EntityToUnicode(temp); + } + + + EntityNode node(aEntity); + EntityNode* found = (EntityNode*)gEntityToCodeTree->FindItem(&node); + if (found) { + NS_ASSERTION(found->mStr.Equals(aEntity.mUStr,PR_FALSE,aEntity.mLength), "bad tree"); + return found->mUnicode; + } + } + return -1; +} const nsCString& nsHTMLEntities::UnicodeToEntity(PRInt32 aUnicode) diff --git a/htmlparser/src/nsHTMLEntities.h b/htmlparser/src/nsHTMLEntities.h index 033535728c26..6c1da7a49cb2 100644 --- a/htmlparser/src/nsHTMLEntities.h +++ b/htmlparser/src/nsHTMLEntities.h @@ -38,6 +38,7 @@ public: * in it. */ static PRInt32 EntityToUnicode(const nsString& aEntity); + static PRInt32 EntityToUnicode(const nsCString& aEntity); /** * Translate an entity string into it's unicode value. This call diff --git a/parser/htmlparser/src/nsHTMLEntities.cpp b/parser/htmlparser/src/nsHTMLEntities.cpp index 4aeffeb40635..6c178ae6e12f 100644 --- a/parser/htmlparser/src/nsHTMLEntities.cpp +++ b/parser/htmlparser/src/nsHTMLEntities.cpp @@ -173,6 +173,32 @@ nsHTMLEntities::EntityToUnicode(const nsString& aEntity) return -1; } +PRInt32 +nsHTMLEntities::EntityToUnicode(const nsCString& aEntity) +{ + NS_ASSERTION(gEntityToCodeTree, "no lookup table, needs addref"); + if (gEntityToCodeTree) { + + //this little piece of code exists because entities may or may not have the terminating ';'. + //if we see it, strip if off for this test... + + PRUnichar theLastChar=GetCharAt(aEntity,aEntity.mLength-1); + if(';'==theLastChar) { + nsCAutoString temp(aEntity); + temp.Truncate(aEntity.mLength-1); + return EntityToUnicode(temp); + } + + + EntityNode node(aEntity); + EntityNode* found = (EntityNode*)gEntityToCodeTree->FindItem(&node); + if (found) { + NS_ASSERTION(found->mStr.Equals(aEntity.mUStr,PR_FALSE,aEntity.mLength), "bad tree"); + return found->mUnicode; + } + } + return -1; +} const nsCString& nsHTMLEntities::UnicodeToEntity(PRInt32 aUnicode) diff --git a/parser/htmlparser/src/nsHTMLEntities.h b/parser/htmlparser/src/nsHTMLEntities.h index 033535728c26..6c1da7a49cb2 100644 --- a/parser/htmlparser/src/nsHTMLEntities.h +++ b/parser/htmlparser/src/nsHTMLEntities.h @@ -38,6 +38,7 @@ public: * in it. */ static PRInt32 EntityToUnicode(const nsString& aEntity); + static PRInt32 EntityToUnicode(const nsCString& aEntity); /** * Translate an entity string into it's unicode value. This call