|
|
|
@ -105,16 +105,14 @@ Parser.prototype._parse = function(data) {
|
|
|
|
|
|
|
|
|
|
this.debug && this.debug('<= ' + inspect(this._buffer));
|
|
|
|
|
|
|
|
|
|
var clearBuffer = false;
|
|
|
|
|
|
|
|
|
|
if (RE_PRECEDING.test(this._buffer)) {
|
|
|
|
|
var firstChar = this._buffer[0];
|
|
|
|
|
if (firstChar === '*')
|
|
|
|
|
clearBuffer = this._resUntagged();
|
|
|
|
|
this._resUntagged();
|
|
|
|
|
else if (firstChar === 'A')
|
|
|
|
|
clearBuffer = this._resTagged();
|
|
|
|
|
this._resTagged();
|
|
|
|
|
else if (firstChar === '+')
|
|
|
|
|
clearBuffer = this._resContinue();
|
|
|
|
|
this._resContinue();
|
|
|
|
|
|
|
|
|
|
if (this._literallen > 0 && i < datalen) {
|
|
|
|
|
// literal data included in this chunk -- put it back onto stream
|
|
|
|
@ -126,12 +124,9 @@ Parser.prototype._parse = function(data) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this._buffer = '';
|
|
|
|
|
this.emit('other', this._buffer);
|
|
|
|
|
clearBuffer = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (clearBuffer)
|
|
|
|
|
this._buffer = '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -140,7 +135,6 @@ Parser.prototype._parse = function(data) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Parser.prototype._resTagged = function() {
|
|
|
|
|
var ret = false;
|
|
|
|
|
if (m = RE_LITERAL.exec(this._buffer)) {
|
|
|
|
|
// non-BODY literal -- buffer it
|
|
|
|
|
this._buffer = this._buffer.replace(RE_LITERAL, LITPLACEHOLDER);
|
|
|
|
@ -152,6 +146,7 @@ Parser.prototype._resTagged = function() {
|
|
|
|
|
type = m[2].toLowerCase(),
|
|
|
|
|
textCode = (m[3] ? parseTextCode(m[3], this._literals) : m[3]),
|
|
|
|
|
text = m[4];
|
|
|
|
|
this._buffer = '';
|
|
|
|
|
|
|
|
|
|
this._literals = [];
|
|
|
|
|
|
|
|
|
@ -161,15 +156,11 @@ Parser.prototype._resTagged = function() {
|
|
|
|
|
textCode: textCode,
|
|
|
|
|
text: text
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ret = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Parser.prototype._resUntagged = function() {
|
|
|
|
|
var ret = false, self = this, m;
|
|
|
|
|
var self = this, m;
|
|
|
|
|
if (m = RE_BODYLITERAL.exec(this._buffer)) {
|
|
|
|
|
// BODY literal -- stream it
|
|
|
|
|
var which = m[1], size = parseInt(m[2], 10);
|
|
|
|
@ -191,6 +182,7 @@ Parser.prototype._resUntagged = function() {
|
|
|
|
|
this._literallen = parseInt(m[1], 10);
|
|
|
|
|
this._tryread(this._literallen);
|
|
|
|
|
} else if (m = RE_UNTAGGED.exec(this._buffer)) {
|
|
|
|
|
this._buffer = '';
|
|
|
|
|
// normal single line response
|
|
|
|
|
|
|
|
|
|
// m[1] or m[3] = response type
|
|
|
|
@ -250,14 +242,15 @@ Parser.prototype._resUntagged = function() {
|
|
|
|
|
textCode: textCode,
|
|
|
|
|
text: val
|
|
|
|
|
});
|
|
|
|
|
ret = true;
|
|
|
|
|
} else
|
|
|
|
|
ret = true;
|
|
|
|
|
return ret;
|
|
|
|
|
this._buffer = '';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Parser.prototype._resContinue = function() {
|
|
|
|
|
var m = RE_CONTINUE.exec(this._buffer), textCode, text = m[2];
|
|
|
|
|
var m = RE_CONTINUE.exec(this._buffer),
|
|
|
|
|
textCode,
|
|
|
|
|
text = m[2];
|
|
|
|
|
this._buffer = '';
|
|
|
|
|
|
|
|
|
|
if (m[1] !== undefined)
|
|
|
|
|
textCode = parseTextCode(m[1], this._literals);
|
|
|
|
@ -266,8 +259,6 @@ Parser.prototype._resContinue = function() {
|
|
|
|
|
textCode: textCode,
|
|
|
|
|
text: text
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function indexOfCh(buffer, len, i, ch) {
|
|
|
|
|