diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-11 15:07:50 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-11 15:07:50 +0000 |
commit | 764b106951b4c47cef929d17ca99e8f4a8165483 (patch) | |
tree | d1606321274760672db3e47d084586a55ce6b983 /protocols/JabberG/src/jabber_xml.cpp | |
parent | fabb5ec61205a9a3dca6f82645f257d00a534572 (diff) |
Jabber not to eat the trailing symbol in chat's topic
git-svn-id: http://svn.miranda-ng.org/main/trunk@7592 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_xml.cpp')
-rw-r--r-- | protocols/JabberG/src/jabber_xml.cpp | 103 |
1 files changed, 36 insertions, 67 deletions
diff --git a/protocols/JabberG/src/jabber_xml.cpp b/protocols/JabberG/src/jabber_xml.cpp index 7d4208a2cc..8596609b47 100644 --- a/protocols/JabberG/src/jabber_xml.cpp +++ b/protocols/JabberG/src/jabber_xml.cpp @@ -283,24 +283,20 @@ void XPath::ProcessPath(LookupInfo &info, bool bCreate) TCHAR *nodeName = (TCHAR *)alloca(sizeof(TCHAR) * (info.nodeName.length+1));
lstrcpyn(nodeName, info.nodeName.p, info.nodeName.length+1);
- if (info.attrName && info.attrValue)
- {
- TCHAR *attrName = (TCHAR *)alloca(sizeof(TCHAR) * (info.attrName.length+1));
- lstrcpyn(attrName, info.attrName.p, info.attrName.length+1);
- TCHAR *attrValue = (TCHAR *)alloca(sizeof(TCHAR) * (info.attrValue.length+1));
- lstrcpyn(attrValue, info.attrValue.p, info.attrValue.length+1);
+ if (info.attrName && info.attrValue) {
+ TCHAR *attrName = (TCHAR *)alloca(sizeof(TCHAR)* (info.attrName.length + 1));
+ lstrcpyn(attrName, info.attrName.p, info.attrName.length + 1);
+ TCHAR *attrValue = (TCHAR *)alloca(sizeof(TCHAR)* (info.attrValue.length + 1));
+ lstrcpyn(attrValue, info.attrValue.p, info.attrValue.length + 1);
HXML hXml = xmlGetChildByTag(m_hXml, nodeName, attrName, attrValue);
m_hXml = (hXml || !bCreate) ? hXml : (m_hXml << XCHILD(nodeName) << XATTR(attrName, attrValue));
- } else
- if (info.nodeIndex)
- {
+ }
+ else if (info.nodeIndex) {
int idx = _ttoi(info.nodeIndex.p);
- m_hXml = lstrcmp(nodeName, _T("*")) ? xmlGetNthChild(m_hXml, nodeName, idx) : xmlGetChild(m_hXml, idx-1);
-
- // no support for such creation mode
- } else
- {
+ m_hXml = lstrcmp(nodeName, _T("*")) ? xmlGetNthChild(m_hXml, nodeName, idx) : xmlGetChild(m_hXml, idx - 1);
+ }
+ else {
HXML hXml = xmlGetChild(m_hXml, nodeName);
m_hXml = (hXml || !bCreate) ? hXml : (m_hXml << XCHILD(nodeName));
}
@@ -313,26 +309,21 @@ XPath::PathType XPath::LookupImpl(bool bCreate) LookupState state = S_START;
LookupInfo info = {0};
- for (LPCTSTR p = m_szPath; state < S_FINAL; ++p)
- {
- switch (state)
- {
+ for (LPCTSTR p = m_szPath; state < S_FINAL; ++p) {
+ switch (state) {
case S_START:
- {
ProcessPath(info, bCreate);
- if (!m_hXml)
- {
+ if (!m_hXml) {
state = S_FINAL_ERROR;
break;
}
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
case _T('@'):
- info.attrName.Begin(p+1);
+ info.attrName.Begin(p + 1);
state = S_ATTR_STEP;
break;
case _T('/'):
@@ -343,11 +334,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_ATTR_STEP:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
info.attrName.End(p);
state = S_FINAL_ATTR;
@@ -356,11 +345,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_NAME:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
info.nodeName.End(p);
state = S_FINAL_NODESET;
@@ -377,16 +364,14 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_OPENBRACKET:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
case _T('@'):
- info.attrName.Begin(p+1);
+ info.attrName.Begin(p + 1);
state = S_NODE_ATTRNAME;
break;
case _T('0'): case _T('1'): case _T('2'): case _T('3'): case _T('4'):
@@ -399,11 +384,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_INDEX:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
@@ -419,11 +402,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_ATTRNAME:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
@@ -435,16 +416,14 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_ATTREQUALS:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
case _T('\''):
- info.attrValue.Begin(p+1);
+ info.attrValue.Begin(p + 1);
state = S_NODE_ATTRVALUE;
break;
default:
@@ -452,11 +431,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_ATTRVALUE:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
@@ -468,11 +445,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_ATTRCLOSEVALUE:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
@@ -484,11 +459,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_CLOSEBRACKET:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_NODE;
break;
@@ -501,16 +474,12 @@ XPath::PathType XPath::LookupImpl(bool bCreate) };
break;
}
- }
if (!*p && (state < S_FINAL))
- {
state = S_FINAL_ERROR;
- }
}
- switch (state)
- {
+ switch (state) {
case S_FINAL_ATTR:
m_szParam = info.attrName.p;
return T_ATTRIBUTE;
|