Nikolay Sivov : msxml3: Add a helper to check that lexical handler is set.

Alexandre Julliard julliard at winehq.org
Tue May 8 14:16:55 CDT 2012


Module: wine
Branch: master
Commit: fc4dab4c3ba8007f1ab6e1e2e986a8d95c633e90
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=fc4dab4c3ba8007f1ab6e1e2e986a8d95c633e90

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue May  8 15:56:20 2012 +0400

msxml3: Add a helper to check that lexical handler is set.

---

 dlls/msxml3/saxreader.c |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/dlls/msxml3/saxreader.c b/dlls/msxml3/saxreader.c
index 0d46c4f..b3b6fc4 100644
--- a/dlls/msxml3/saxreader.c
+++ b/dlls/msxml3/saxreader.c
@@ -319,7 +319,13 @@ static inline int has_content_handler(const saxlocator *locator)
            (!locator->vbInterface && locator->saxreader->contentHandler);
 }
 
-static inline BOOL has_error_handler(const saxlocator *locator)
+static inline int has_lexical_handler(const saxlocator *locator)
+{
+    return  (locator->vbInterface && locator->saxreader->vblexicalHandler) ||
+           (!locator->vbInterface && locator->saxreader->lexicalHandler);
+}
+
+static inline int has_error_handler(const saxlocator *locator)
 {
     return (locator->vbInterface && locator->saxreader->vberrorHandler) ||
           (!locator->vbInterface && locator->saxreader->errorHandler);
@@ -1587,8 +1593,7 @@ static void libxmlComment(void *ctx, const xmlChar *value)
     for(; p>=This->pParserCtxt->input->base && *p!='\n' && *p!='\r'; p--)
         This->column++;
 
-    if(!This->vbInterface && !This->saxreader->lexicalHandler) return;
-    if(This->vbInterface && !This->saxreader->vblexicalHandler) return;
+    if (!has_lexical_handler(This)) return;
 
     bValue = pooled_bstr_from_xmlChar(&This->saxreader->pool, value);
 
@@ -1678,10 +1683,13 @@ static void libxmlCDataBlock(void *ctx, const xmlChar *value, int len)
     for(; beg>=This->pParserCtxt->input->base && *beg!='\n' && *beg!='\r'; beg--)
         This->column++;
 
-    if(This->vbInterface && This->saxreader->vblexicalHandler)
-        hr = IVBSAXLexicalHandler_startCDATA(This->saxreader->vblexicalHandler);
-    if(!This->vbInterface && This->saxreader->lexicalHandler)
-        hr = ISAXLexicalHandler_startCDATA(This->saxreader->lexicalHandler);
+    if (has_lexical_handler(This))
+    {
+       if (This->vbInterface)
+           hr = IVBSAXLexicalHandler_startCDATA(This->saxreader->vblexicalHandler);
+       else
+           hr = ISAXLexicalHandler_startCDATA(This->saxreader->lexicalHandler);
+    }
 
     if(FAILED(hr))
     {
@@ -1731,10 +1739,13 @@ static void libxmlCDataBlock(void *ctx, const xmlChar *value, int len)
         cur = end;
     }
 
-    if(This->vbInterface && This->saxreader->vblexicalHandler)
-        hr = IVBSAXLexicalHandler_endCDATA(This->saxreader->vblexicalHandler);
-    if(!This->vbInterface && This->saxreader->lexicalHandler)
-        hr = ISAXLexicalHandler_endCDATA(This->saxreader->lexicalHandler);
+    if (has_lexical_handler(This))
+    {
+        if (This->vbInterface)
+            hr = IVBSAXLexicalHandler_endCDATA(This->saxreader->vblexicalHandler);
+        else
+            hr = ISAXLexicalHandler_endCDATA(This->saxreader->lexicalHandler);
+    }
 
     if(FAILED(hr))
         format_error_message_from_id(This, hr);




More information about the wine-cvs mailing list