From b6853cfe4fd1ee089dfdd0cb09bbc4063532ef82 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 25 Apr 2016 11:23:43 -0700 Subject: Pass CFX_*StringCs to FX_HashCode_GETA and _GETW hash functions. Too many calls were of the form fn(x.c_str(), x.GetLength()) which is an anti-pattern given the StringC classes which tie these together. There are a few places where explicit CFX_*StringCs are constructed, but this can be avoided by changing the args to these functions in the same manner. Removed String_ from name of functions since it added little value. Also removed default argument. Review URL: https://codereview.chromium.org/1919563002 --- xfa/fxfa/parser/cxfa_widgetdata.cpp | 3 +- xfa/fxfa/parser/xfa_basic_imp.cpp | 71 ++++++++++++------------- xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 70 ++++++++++++------------ xfa/fxfa/parser/xfa_document_imp.cpp | 10 ++-- xfa/fxfa/parser/xfa_object_imp.cpp | 53 +++++++----------- xfa/fxfa/parser/xfa_script_imp.cpp | 3 +- xfa/fxfa/parser/xfa_script_nodehelper.cpp | 2 +- xfa/fxfa/parser/xfa_script_resolveprocessor.cpp | 12 ++--- xfa/fxfa/parser/xfa_utils_imp.cpp | 3 +- 9 files changed, 99 insertions(+), 128 deletions(-) (limited to 'xfa/fxfa/parser') diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index a702527347..0c3d065a39 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -466,8 +466,7 @@ CXFA_Node* CXFA_WidgetData::GetSelectedMember() { CXFA_Node* CXFA_WidgetData::SetSelectedMember(const CFX_WideStringC& wsName, FX_BOOL bNotify) { CXFA_Node* pSelectedMember = NULL; - uint32_t nameHash = - FX_HashCode_String_GetW(wsName.c_str(), wsName.GetLength()); + uint32_t nameHash = FX_HashCode_GetW(wsName, false); for (CXFA_Node* pNode = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)); pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { if (pNode->GetNameHash() == nameHash) { diff --git a/xfa/fxfa/parser/xfa_basic_imp.cpp b/xfa/fxfa/parser/xfa_basic_imp.cpp index 631b7c10ca..728ecfc319 100644 --- a/xfa/fxfa/parser/xfa_basic_imp.cpp +++ b/xfa/fxfa/parser/xfa_basic_imp.cpp @@ -21,12 +21,12 @@ #include "xfa/fxfa/parser/xfa_utils.h" const XFA_PACKETINFO* XFA_GetPacketByName(const CFX_WideStringC& wsName) { - int32_t iLength = wsName.GetLength(); - if (iLength == 0) { - return NULL; - } - uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength); - int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1; + if (wsName.IsEmpty()) + return nullptr; + + uint32_t uHash = FX_HashCode_GetW(wsName, false); + int32_t iStart = 0; + int32_t iEnd = g_iXFAPacketCount - 1; do { int32_t iMid = (iStart + iEnd) / 2; const XFA_PACKETINFO* pInfo = g_XFAPacketData + iMid; @@ -63,12 +63,12 @@ const XFA_PACKETINFO* XFA_GetPacketByIndex(XFA_PACKET ePacket) { const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByName( const CFX_WideStringC& wsName) { - int32_t iLength = wsName.GetLength(); - if (iLength == 0) { - return NULL; - } - uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength); - int32_t iStart = 0, iEnd = g_iXFAEnumCount - 1; + if (wsName.IsEmpty()) + return nullptr; + + uint32_t uHash = FX_HashCode_GetW(wsName, false); + int32_t iStart = 0; + int32_t iEnd = g_iXFAEnumCount - 1; do { int32_t iMid = (iStart + iEnd) / 2; const XFA_ATTRIBUTEENUMINFO* pInfo = g_XFAEnumData + iMid; @@ -87,12 +87,12 @@ const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName) { } const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName) { - int32_t iLength = wsName.GetLength(); - if (iLength == 0) { - return NULL; - } - uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength); - int32_t iStart = 0, iEnd = g_iXFAAttributeCount - 1; + if (wsName.IsEmpty()) + return nullptr; + + uint32_t uHash = FX_HashCode_GetW(wsName, false); + int32_t iStart = 0; + int32_t iEnd = g_iXFAAttributeCount - 1; do { int32_t iMid = (iStart + iEnd) / 2; const XFA_ATTRIBUTEINFO* pInfo = g_XFAAttributeData + iMid; @@ -104,7 +104,7 @@ const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName) { iStart = iMid + 1; } } while (iStart <= iEnd); - return NULL; + return nullptr; } const XFA_ATTRIBUTEINFO* XFA_GetAttributeByID(XFA_ATTRIBUTE eName) { return (eName < g_iXFAAttributeCount) ? (g_XFAAttributeData + eName) : NULL; @@ -177,12 +177,12 @@ CXFA_Measurement XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT eElement, } const XFA_ELEMENTINFO* XFA_GetElementByName(const CFX_WideStringC& wsName) { - int32_t iLength = wsName.GetLength(); - if (iLength == 0) { - return NULL; - } - uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength); - int32_t iStart = 0, iEnd = g_iXFAElementCount - 1; + if (wsName.IsEmpty()) + return nullptr; + + uint32_t uHash = FX_HashCode_GetW(wsName, false); + int32_t iStart = 0; + int32_t iEnd = g_iXFAElementCount - 1; do { int32_t iMid = (iStart + iEnd) / 2; const XFA_ELEMENTINFO* pInfo = g_XFAElementData + iMid; @@ -334,10 +334,9 @@ const XFA_NOTSUREATTRIBUTE* XFA_GetNotsureAttribute(XFA_ELEMENT eElement, const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement, const CFX_WideStringC& wsMethodName) { - int32_t iLength = wsMethodName.GetLength(); - if (iLength == 0) { - return NULL; - } + if (wsMethodName.IsEmpty()) + return nullptr; + int32_t iElementIndex = eElement; while (iElementIndex != -1) { const XFA_SCRIPTHIERARCHY* scriptIndex = g_XFAScriptIndex + iElementIndex; @@ -346,8 +345,9 @@ const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement, iElementIndex = scriptIndex->wParentIndex; continue; } - uint32_t uHash = FX_HashCode_String_GetW(wsMethodName.c_str(), iLength); - int32_t iStart = scriptIndex->wMethodStart, iEnd = iStart + icount - 1; + uint32_t uHash = FX_HashCode_GetW(wsMethodName, false); + int32_t iStart = scriptIndex->wMethodStart; + int32_t iEnd = iStart + icount - 1; do { int32_t iMid = (iStart + iEnd) / 2; const XFA_METHODINFO* pInfo = g_SomMethodData + iMid; @@ -366,10 +366,9 @@ const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement, const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName( XFA_ELEMENT eElement, const CFX_WideStringC& wsAttributeName) { - int32_t iLength = wsAttributeName.GetLength(); - if (iLength == 0) { - return NULL; - } + if (wsAttributeName.IsEmpty()) + return nullptr; + int32_t iElementIndex = eElement; while (iElementIndex != -1) { const XFA_SCRIPTHIERARCHY* scriptIndex = g_XFAScriptIndex + iElementIndex; @@ -378,7 +377,7 @@ const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName( iElementIndex = scriptIndex->wParentIndex; continue; } - uint32_t uHash = FX_HashCode_String_GetW(wsAttributeName.c_str(), iLength); + uint32_t uHash = FX_HashCode_GetW(wsAttributeName, false); int32_t iStart = scriptIndex->wAttributeStart, iEnd = iStart + icount - 1; do { int32_t iMid = (iStart + iEnd) / 2; diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 22d3c625c9..59e663eec1 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -397,52 +397,48 @@ static CXFA_Node* XFA_DataMerge_FindGlobalDataNode(CXFA_Document* pDocument, CFX_WideStringC wsName, CXFA_Node* pDataScope, XFA_ELEMENT eMatchNodeType) { - uint32_t dwNameHash = - wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.c_str(), - wsName.GetLength()); - if (dwNameHash != 0) { - CXFA_Node* pBounded = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); - if (!pBounded) { - pBounded = XFA_DataMerge_ScopeMatchGlobalBinding(pDataScope, dwNameHash, - eMatchNodeType); - if (pBounded) { - XFA_DataMerge_RegisterGlobalBinding(pDocument, dwNameHash, pBounded); - } + if (wsName.IsEmpty()) + return nullptr; + + uint32_t dwNameHash = FX_HashCode_GetW(wsName, false); + CXFA_Node* pBounded = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); + if (!pBounded) { + pBounded = XFA_DataMerge_ScopeMatchGlobalBinding(pDataScope, dwNameHash, + eMatchNodeType); + if (pBounded) { + XFA_DataMerge_RegisterGlobalBinding(pDocument, dwNameHash, pBounded); } - return pBounded; } - return NULL; + return pBounded; } + static CXFA_Node* XFA_DataMerge_FindOnceDataNode(CXFA_Document* pDocument, CFX_WideStringC wsName, CXFA_Node* pDataScope, XFA_ELEMENT eMatchNodeType) { - uint32_t dwNameHash = - wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.c_str(), - wsName.GetLength()); - if (dwNameHash != 0) { - for (CXFA_Node *pCurDataScope = pDataScope, *pLastDataScope = NULL; - pCurDataScope && - pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets; - pLastDataScope = pCurDataScope, - pCurDataScope = - pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) { - for (CXFA_Node* pDataChild = - pCurDataScope->GetFirstChildByName(dwNameHash); - pDataChild; - pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) { - if (pDataChild == pLastDataScope || - (eMatchNodeType != XFA_ELEMENT_DataModel && - pDataChild->GetClassID() != eMatchNodeType) || - pDataChild->HasBindItem()) { - continue; - } - return pDataChild; + if (wsName.IsEmpty()) + return nullptr; + + uint32_t dwNameHash = FX_HashCode_GetW(wsName, false); + CXFA_Node* pLastDataScope = nullptr; + for (CXFA_Node* pCurDataScope = pDataScope; + pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets; + pCurDataScope = pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) { + for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash); + pDataChild; + pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) { + if (pDataChild == pLastDataScope || pDataChild->HasBindItem() || + (eMatchNodeType != XFA_ELEMENT_DataModel && + pDataChild->GetClassID() != eMatchNodeType)) { + continue; } + return pDataChild; } + pLastDataScope = pCurDataScope; } - return NULL; + return nullptr; } + static CXFA_Node* XFA_DataMerge_FindDataRefDataNode(CXFA_Document* pDocument, CFX_WideStringC wsRef, CXFA_Node* pDataScope, @@ -561,8 +557,8 @@ static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager( CXFA_NodeArray& subforms) { CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName; - uint32_t dwInstNameHash = FX_HashCode_String_GetW( - wsInstMgrNodeName.c_str(), wsInstMgrNodeName.GetLength()); + uint32_t dwInstNameHash = + FX_HashCode_GetW(wsInstMgrNodeName.AsStringC(), false); CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( pDocument, XFA_ELEMENT_InstanceManager, dwInstNameHash, pFormParent); if (pExistingNode) { diff --git a/xfa/fxfa/parser/xfa_document_imp.cpp b/xfa/fxfa/parser/xfa_document_imp.cpp index 39bdf2503c..ad3fd70e0d 100644 --- a/xfa/fxfa/parser/xfa_document_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_imp.cpp @@ -94,8 +94,7 @@ CXFA_FFNotify* CXFA_Document::GetNotify() const { return m_pParser->GetNotify(); } CXFA_Object* CXFA_Document::GetXFAObject(const CFX_WideStringC& wsNodeName) { - return GetXFAObject( - FX_HashCode_String_GetW(wsNodeName.c_str(), wsNodeName.GetLength())); + return GetXFAObject(FX_HashCode_GetW(wsNodeName, false)); } CXFA_Object* CXFA_Document::GetXFAObject(uint32_t dwNodeNameHash) { switch (dwNodeNameHash) { @@ -367,8 +366,7 @@ void CXFA_Document::DoProtoMerge() { pNode = sIterator.MoveToNext()) { CFX_WideStringC wsIDVal; if (pNode->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) && !wsIDVal.IsEmpty()) { - mIDMap[FX_HashCode_String_GetW(wsIDVal.c_str(), wsIDVal.GetLength())] = - pNode; + mIDMap[FX_HashCode_GetW(wsIDVal, false)] = pNode; } CFX_WideStringC wsUseVal; if (pNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) && !wsUseVal.IsEmpty()) { @@ -426,9 +424,7 @@ void CXFA_Document::DoProtoMerge() { pProtoNode = resoveNodeRS.nodes[0]->AsNode(); } } else if (!wsID.IsEmpty()) { - if (!mIDMap.Lookup( - FX_HashCode_String_GetW(wsID.c_str(), wsID.GetLength()), - pProtoNode)) { + if (!mIDMap.Lookup(FX_HashCode_GetW(wsID, false), pProtoNode)) { continue; } } diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp index 93b596ae99..fd54b1509b 100644 --- a/xfa/fxfa/parser/xfa_object_imp.cpp +++ b/xfa/fxfa/parser/xfa_object_imp.cpp @@ -1769,24 +1769,22 @@ static const XFA_ExecEventParaInfo gs_eventParaInfos[] = { }; const XFA_ExecEventParaInfo* GetEventParaInfoByName( const CFX_WideStringC& wsEventName) { - int32_t iLength = wsEventName.GetLength(); - uint32_t uHash = FX_HashCode_String_GetW(wsEventName.c_str(), iLength); - const XFA_ExecEventParaInfo* eventParaInfo = NULL; - int32_t iStart = 0, - iEnd = (sizeof(gs_eventParaInfos) / sizeof(gs_eventParaInfos[0])) - 1; - int32_t iMid = (iStart + iEnd) / 2; + uint32_t uHash = FX_HashCode_GetW(wsEventName, false); + int32_t iStart = 0; + int32_t iEnd = (sizeof(gs_eventParaInfos) / sizeof(gs_eventParaInfos[0])) - 1; do { - iMid = (iStart + iEnd) / 2; - eventParaInfo = &gs_eventParaInfos[iMid]; + int32_t iMid = (iStart + iEnd) / 2; + const XFA_ExecEventParaInfo* eventParaInfo = &gs_eventParaInfos[iMid]; if (uHash == eventParaInfo->m_uHash) { return eventParaInfo; - } else if (uHash < eventParaInfo->m_uHash) { + } + if (uHash < eventParaInfo->m_uHash) { iEnd = iMid - 1; } else { iStart = iMid + 1; } } while (iStart <= iEnd); - return NULL; + return nullptr; } void XFA_STRING_TO_RGB(CFX_WideString& strRGB, int32_t& r, @@ -3287,9 +3285,7 @@ int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) { ? wsInstManagerName : wsInstManagerName.Mid(1); uint32_t dInstanceNameHash = - wsInstanceName.IsEmpty() ? 0 : FX_HashCode_String_GetW( - wsInstanceName.c_str(), - wsInstanceName.GetLength()); + FX_HashCode_GetW(wsInstanceName.AsStringC(), false); CXFA_Node* pPrevSibling = (iDesired == 0) ? this : XFA_ScriptInstanceManager_GetItem(this, iDesired - 1); @@ -3726,7 +3722,7 @@ enum XFA_KEYTYPE { XFA_KEYTYPE_Element, }; void* XFA_GetMapKey_Custom(const CFX_WideStringC& wsKey) { - uint32_t dwKey = FX_HashCode_String_GetW(wsKey.c_str(), wsKey.GetLength()); + uint32_t dwKey = FX_HashCode_GetW(wsKey, false); return (void*)(uintptr_t)((dwKey << 1) | XFA_KEYTYPE_Custom); } void* XFA_GetMapKey_Element(XFA_ELEMENT eElement, XFA_ATTRIBUTE eAttribute) { @@ -4732,9 +4728,7 @@ FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { return TRUE; } CXFA_Node* CXFA_Node::GetFirstChildByName(const CFX_WideStringC& wsName) const { - return GetFirstChildByName( - wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.c_str(), - wsName.GetLength())); + return GetFirstChildByName(FX_HashCode_GetW(wsName, false)); } CXFA_Node* CXFA_Node::GetFirstChildByName(uint32_t dwNameHash) const { for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; @@ -4765,10 +4759,7 @@ CXFA_Node* CXFA_Node::GetNextSameNameSibling(uint32_t dwNameHash) const { } CXFA_Node* CXFA_Node::GetNextSameNameSibling( const CFX_WideStringC& wsNodeName) const { - return GetNextSameNameSibling( - wsNodeName.IsEmpty() ? 0 - : FX_HashCode_String_GetW(wsNodeName.c_str(), - wsNodeName.GetLength())); + return GetNextSameNameSibling(FX_HashCode_GetW(wsNodeName, false)); } CXFA_Node* CXFA_Node::GetNextSameClassSibling(XFA_ELEMENT eElement) const { for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; @@ -4951,17 +4942,13 @@ int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, void CXFA_Node::UpdateNameHash() { const XFA_NOTSUREATTRIBUTE* pNotsure = XFA_GetNotsureAttribute(GetClassID(), XFA_ATTRIBUTE_Name); + CFX_WideStringC wsName; if (!pNotsure || pNotsure->eType == XFA_ATTRIBUTETYPE_Cdata) { - CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); - m_dwNameHash = - wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.c_str(), - wsName.GetLength()); + wsName = GetCData(XFA_ATTRIBUTE_Name); + m_dwNameHash = FX_HashCode_GetW(wsName, false); } else if (pNotsure->eType == XFA_ATTRIBUTETYPE_Enum) { - CFX_WideStringC wsName = - XFA_GetAttributeEnumByID(GetEnum(XFA_ATTRIBUTE_Name))->pName; - m_dwNameHash = - wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.c_str(), - wsName.GetLength()); + wsName = XFA_GetAttributeEnumByID(GetEnum(XFA_ATTRIBUTE_Name))->pName; + m_dwNameHash = FX_HashCode_GetW(wsName, false); } } CFDE_XMLNode* CXFA_Node::CreateXMLMappingNode() { @@ -5233,14 +5220,12 @@ CXFA_NodeList::CXFA_NodeList(CXFA_Document* pDocument) m_pDocument->GetScriptContext()->CacheList(this); } CXFA_Node* CXFA_NodeList::NamedItem(const CFX_WideStringC& wsName) { + uint32_t dwHashCode = FX_HashCode_GetW(wsName, false); int32_t iCount = GetLength(); - uint32_t dwHashCode = - FX_HashCode_String_GetW(wsName.c_str(), wsName.GetLength()); for (int32_t i = 0; i < iCount; i++) { CXFA_Node* ret = Item(i); - if (dwHashCode == ret->GetNameHash()) { + if (dwHashCode == ret->GetNameHash()) return ret; - } } return NULL; } diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp index ee95865dc6..0c8aa1a838 100644 --- a/xfa/fxfa/parser/xfa_script_imp.cpp +++ b/xfa/fxfa/parser/xfa_script_imp.cpp @@ -179,8 +179,7 @@ void CXFA_ScriptContext::GlobalPropertyGetter(FXJSE_HOBJECT hObject, XFA_FM2JS_GlobalPropertyGetter(lpScriptContext->m_hFM2JSContext, hValue); return; } - uint32_t uHashCode = - FX_HashCode_String_GetW(wsPropName.c_str(), wsPropName.GetLength()); + uint32_t uHashCode = FX_HashCode_GetW(wsPropName.AsStringC(), false); if (uHashCode != XFA_HASHCODE_Layout) { CXFA_Object* pObject = lpScriptContext->GetDocument()->GetXFAObject(uHashCode); diff --git a/xfa/fxfa/parser/xfa_script_nodehelper.cpp b/xfa/fxfa/parser/xfa_script_nodehelper.cpp index 96ae98aeaf..96ecc5a125 100644 --- a/xfa/fxfa/parser/xfa_script_nodehelper.cpp +++ b/xfa/fxfa/parser/xfa_script_nodehelper.cpp @@ -33,7 +33,7 @@ CXFA_Node* CXFA_NodeHelper::XFA_ResolveNodes_GetOneChild( return NULL; } CXFA_NodeArray siblings; - uint32_t uNameHash = FX_HashCode_String_GetW(pwsName, FXSYS_wcslen(pwsName)); + uint32_t uNameHash = FX_HashCode_GetW(CFX_WideStringC(pwsName), false); XFA_NodeAcc_TraverseAnySiblings(parent, uNameHash, &siblings, bIsClassName); if (siblings.GetSize() == 0) { return NULL; diff --git a/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp b/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp index ecf384b51c..fcd24bf949 100644 --- a/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp +++ b/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp @@ -122,8 +122,8 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Dollar( if (rnd.m_nLevel > 0) { return -1; } - uint32_t dwNameHash = - FX_HashCode_String_GetW(wsName.c_str() + 1, iNameLen - 1); + uint32_t dwNameHash = FX_HashCode_GetW( + CFX_WideStringC(wsName.c_str() + 1, iNameLen - 1), false); if (dwNameHash == XFA_HASHCODE_Xfa) { nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); } else { @@ -151,8 +151,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Excalmatory( rndFind.m_pSC = rnd.m_pSC; rndFind.m_CurNode = datasets; rndFind.m_wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); - rndFind.m_uHashName = FX_HashCode_String_GetW(rndFind.m_wsName.c_str(), - rndFind.m_wsName.GetLength()); + rndFind.m_uHashName = FX_HashCode_GetW(rndFind.m_wsName.AsStringC(), false); rndFind.m_nLevel = rnd.m_nLevel + 1; rndFind.m_dwStyles = XFA_RESOLVENODE_Children; rndFind.m_wsCondition = rnd.m_wsCondition; @@ -178,8 +177,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_NumberSign( rndFind.m_dwStyles |= XFA_RESOLVENODE_TagName; rndFind.m_dwStyles &= ~XFA_RESOLVENODE_Attributes; rndFind.m_wsName = wsName; - rndFind.m_uHashName = FX_HashCode_String_GetW(rndFind.m_wsName.c_str(), - rndFind.m_wsName.GetLength()); + rndFind.m_uHashName = FX_HashCode_GetW(rndFind.m_wsName.AsStringC(), false); rndFind.m_wsCondition = wsCondition; rndFind.m_CurNode = curNode; XFA_ResolveNodes_Normal(rndFind); @@ -617,7 +615,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_GetFilter( wsCondition.ReleaseBuffer(nConditionCount); wsCondition.TrimLeft(); wsCondition.TrimRight(); - rnd.m_uHashName = FX_HashCode_String_GetW(wsName.c_str(), wsName.GetLength()); + rnd.m_uHashName = FX_HashCode_GetW(wsName.AsStringC(), false); return nStart; } void CXFA_ResolveProcessor::XFA_ResolveNode_ConditionArray( diff --git a/xfa/fxfa/parser/xfa_utils_imp.cpp b/xfa/fxfa/parser/xfa_utils_imp.cpp index 4fec7c071b..77cac00b89 100644 --- a/xfa/fxfa/parser/xfa_utils_imp.cpp +++ b/xfa/fxfa/parser/xfa_utils_imp.cpp @@ -196,8 +196,7 @@ void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); CFX_WideString wsTag; pXMLElement->GetLocalTagName(wsTag); - uint32_t uTag = - FX_HashCode_String_GetW(wsTag.c_str(), wsTag.GetLength(), TRUE); + uint32_t uTag = FX_HashCode_GetW(wsTag.AsStringC(), true); if (uTag == 0x0001f714) { wsPlainText += L"\n"; } else if (uTag == 0x00000070) { -- cgit v1.2.3