[Pkg-javascript-commits] [ltx] 228/469: sax_ltx: peek at charCode

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:03:06 UTC 2016


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

js pushed a commit to branch master
in repository ltx.

commit 8e693a8a379c5cc7df47f3cd883cda69d7e20030
Author: Astro <astro at spaceboyz.net>
Date:   Tue Mar 20 04:16:14 2012 +0100

    sax_ltx: peek at charCode
---
 lib/sax_ltx.js | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/lib/sax_ltx.js b/lib/sax_ltx.js
index 4c9a60c..1445aa7 100644
--- a/lib/sax_ltx.js
+++ b/lib/sax_ltx.js
@@ -19,11 +19,11 @@ var SaxLtx = module.exports = function SaxLtx() {
     this.state = STATE_TEXT;
 
 
-    var origEmit = this.emit;
+    /*var origEmit = this.emit;
     this.emit = function() {
-	//console.log('ltx', arguments);
+	console.log('ltx', arguments);
 	origEmit.apply(this, arguments);
-    };
+    };*/
 };
 util.inherits(SaxLtx, events.EventEmitter);
 
@@ -49,11 +49,11 @@ SaxLtx.prototype.write = function(data) {
     }
 
     for(; pos < data.length; pos++) {
-	var c = data[pos];
-	//console.log("state", this.state, "c", c);
+	var c = data.charCodeAt(pos);
+	//console.log("state", this.state, "c", c, data[pos]);
 	switch(this.state) {
 	case STATE_TEXT:
-	    if (c === "<") {
+	    if (c === 60 /* < */) {
 		var text = endRecording();
 		if (text)
 		    this.emit('text', unescapeXml(text));
@@ -63,17 +63,17 @@ SaxLtx.prototype.write = function(data) {
 	    }
 	    break;
 	case STATE_TAG_NAME:
-	    if (c === "/" && this.recordStart === pos) {
+	    if (c === 47 /* / */ && this.recordStart === pos) {
 		this.recordStart = pos + 1;
 		this.endTag = true;
-	    } else if (!RE_TAG_NAME.test(c)) {
+	    } else if (c <= 32 || c === 47 /* / */ || c === 62 /* > */) {
 		this.tagName = endRecording();
 		pos--;
 		this.state = STATE_TAG;
 	    }
 	    break;
 	case STATE_TAG:
-	    if (c === ">") {
+	    if (c === 62 /* > */) {
 		if (!this.endTag) {
 		    this.emit('startElement', this.tagName, this.attrs);
 		    if (this.selfClosing)
@@ -86,27 +86,27 @@ SaxLtx.prototype.write = function(data) {
 		delete this.selfClosing;
 		this.state = STATE_TEXT;
 		this.recordStart = pos + 1;
-	    } else if (c === "/") {
+	    } else if (c === 47 /* / */) {
 		this.selfClosing = true;
-	    } else if (RE_ATTR_NAME.test(c)) {
+	    } else if (c > 32) {
 		this.recordStart = pos;
 		this.state = STATE_ATTR_NAME;
 	    }
 	    break;
 	case STATE_ATTR_NAME:
-	    if (!RE_ATTR_NAME.test(c)) {
+	    if (c <= 32 || c === 61 /* = */) {
 		this.attrName = endRecording();
 		pos--;
 		this.state = STATE_ATTR_EQ;
 	    }
 	    break;
 	case STATE_ATTR_EQ:
-	    if (c === "=") {
+	    if (c === 61 /* = */) {
 		this.state = STATE_ATTR_QUOT;
 	    }
 	    break;
 	case STATE_ATTR_QUOT:
-	    if (c === '"' || c === "'") {
+	    if (c === 34 /* " */ || c === 39 /* ' */) {
 		this.attrQuote = c;
 		this.state = STATE_ATTR_VALUE;
 		this.recordStart = pos + 1;

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



More information about the Pkg-javascript-commits mailing list