[Pkg-javascript-commits] [node-expat] 17/371: i can has error handling

Jonas Smedegaard dr at jones.dk
Sun Feb 28 09:59:40 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-expat.

commit 94ef41e5317be51908c0f05798d8f268dabbfbd4
Author: Astro <astro at spaceboyz.net>
Date:   Sun May 23 16:47:30 2010 +0200

    i can has error handling
---
 expat.cc | 12 ++++--------
 test.js  |  6 +++++-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/expat.cc b/expat.cc
index 3c7423d..f2737e9 100644
--- a/expat.cc
+++ b/expat.cc
@@ -89,10 +89,7 @@ protected:
         isFinal = args[1]->IsTrue();
       }
 
-    if (parser->parse(**str, isFinal))
-      return scope.Close(False());
-    else
-      return scope.Close(True());
+    return scope.Close(parser->parse(**str, isFinal) ? True() : False());
   }
 
   bool parse(String &str, int isFinal)
@@ -101,9 +98,8 @@ protected:
     void *buf = XML_GetBuffer(parser, len);
     assert(buf != NULL);
     assert(str.WriteUtf8(static_cast<char *>(buf), len) == len);
-    assert(XML_ParseBuffer(parser, len, isFinal) != XML_STATUS_ERROR);
 
-    return true;
+    return XML_ParseBuffer(parser, len, isFinal) != 0;
   }
 
   static Handle<Value> SetEncoding(const Arguments& args)
@@ -120,7 +116,7 @@ protected:
 
         delete[] encoding;
 
-        return scope.Close(status != 0 ? True() : False());
+        return scope.Close(status ? True() : False());
       }
     else
       return False();
@@ -128,7 +124,7 @@ protected:
 
   int setEncoding(XML_Char *encoding)
   {
-    return XML_SetEncoding(parser, encoding);
+    return XML_SetEncoding(parser, encoding) != 0;
   }
 
 private:
diff --git a/test.js b/test.js
index 82f626c..c5dcf65 100644
--- a/test.js
+++ b/test.js
@@ -43,7 +43,10 @@ function expect(s, evs_expected) {
 	    evs_received.push(['comment', s]);
 	});
 	for(var l = 0; l < s.length; l += step)
-	    p.parse(s.substr(l, step), false);
+	{
+	    if (!p.parse(s.substr(l, step), false))
+		evs_received.push(['error']);
+	}
 
 	var expected = JSON.stringify(evs_expected);
 	var received = JSON.stringify(collapseTexts(evs_received));
@@ -93,5 +96,6 @@ expect("<?i like xml?>",
        [['processingInstruction', 'i', 'like xml']]);
 expect("<!-- no comment -->",
        [['comment', ' no comment ']]);
+expect("<&", [['error']]);
 
 sys.puts("Ran "+tests+" tests with "+iterations+" iterations: "+fails+" failures.");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-expat.git



More information about the Pkg-javascript-commits mailing list