Skip to content

Commit

Permalink
[fix dist] 0.6.0
Browse files Browse the repository at this point in the history
fixes #3
minor jshint adjustments
  • Loading branch information
dscape committed Jun 8, 2012
1 parent c5570c1 commit 58b4294
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
29 changes: 18 additions & 11 deletions clarinet.js
Expand Up @@ -123,7 +123,7 @@ if(typeof FastList === 'function') {
}
}

var stringTokenPattern = /[\\"\n]/g
var stringTokenPattern = /[\\"\n]/g;

function CParser (opt) {
if (!(this instanceof CParser)) return new CParser (opt);
Expand Down Expand Up @@ -226,13 +226,15 @@ if(typeof FastList === 'function') {
}

function emitNode(parser, event, data) {
if (parser.textNode) closeValue(parser);
closeValue(parser);
emit(parser, event, data);
}

function closeValue(parser, event) {
parser.textNode = textopts(parser.opt, parser.textNode);
if (parser.textNode) emit(parser, (event ? event : "onvalue"), parser.textNode);
if (parser.textNode) {
emit(parser, (event ? event : "onvalue"), parser.textNode);
}
parser.textNode = "";
}

Expand Down Expand Up @@ -413,6 +415,9 @@ if(typeof FastList === 'function') {
if (c === '"' && !slashed) {
parser.state = parser.stack.pop() || S.VALUE;
parser.textNode += chunk.substring(starti, i-1);
if(!parser.textNode) {
emit(parser, "onvalue", "");
}
break;
}
if (c === '\\' && !slashed) {
Expand All @@ -423,25 +428,27 @@ if(typeof FastList === 'function') {
}
if (slashed) {
slashed = false;
if (c === 'n') parser.textNode += '\n'
else if (c === 'r') parser.textNode += '\r'
else if (c === 't') parser.textNode += '\t'
else if (c === 'f') parser.textNode += '\f'
else if (c === 'b') parser.textNode += '\b'
if (c === 'n') { parser.textNode += '\n'; }
else if (c === 'r') { parser.textNode += '\r'; }
else if (c === 't') { parser.textNode += '\t'; }
else if (c === 'f') { parser.textNode += '\f'; }
else if (c === 'b') { parser.textNode += '\b'; }
else if (c === 'u') {
// \uxxxx. meh!
unicodeI = 1;
parser.unicodeS = '';
} else parser.textNode += c
} else {
parser.textNode += c;
}
c = chunk.charAt(i++);
starti = i-1;
if (!c) break;
else continue;
}

stringTokenPattern.lastIndex = i
stringTokenPattern.lastIndex = i;
var reResult = stringTokenPattern.exec(chunk);
if (reResult == null) {
if (reResult === null) {
i = chunk.length+1;
parser.textNode += chunk.substring(starti, i-1);
break;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -6,7 +6,7 @@
[ "Jann Horn (https://github.com/thejh)"
, "Justin Makeig <jmpublic+github@makeig.com> (http://www.audiblepop.com)"
]
, "version" : "0.5.8"
, "version" : "0.6.0"
, "main" : "./clarinet.js"
, "homepage" : "https://github.com/dscape/clarinet"
, "repository" :
Expand Down
10 changes: 10 additions & 0 deletions test/clarinet.js
Expand Up @@ -42,6 +42,16 @@ var seps = [undefined, /\t|\n|\r/, '']
, ['ready' , undefined]
]
}
, empty_value :
{ text : '{"foo": ""}'
, events :
[ ["openobject" , "foo"]
, ["value" , ""]
, ["closeobject" , undefined]
, ['end' , undefined]
, ['ready' , undefined]
]
}
, three_byte_utf8 :
{ text : '{"matzue": "松江", "asakusa": "浅草"}'
, events :
Expand Down

0 comments on commit 58b4294

Please sign in to comment.