Merge pull request #19 from perfectworks/master

LineReader.hasNextLine go to a endless loop when LineReader.buffer is empty
This commit is contained in:
Ryan McGrath 2012-02-20 17:05:17 -08:00
commit 6caa8c9aba

View file

@ -175,7 +175,7 @@ exports.copyDirSyncRecursive = function(sourceDir, newDirLocation, opts) {
var checkDir = fs.statSync(sourceDir); var checkDir = fs.statSync(sourceDir);
try { try {
fs.mkdirSync(newDirLocation, checkDir.mode); fs.mkdirSync(newDirLocation, checkDir.mode);
} catch (e) { } catch (e) {
//if the directory already exists, that's okay //if the directory already exists, that's okay
if (e.code !== 'EEXIST') throw e; if (e.code !== 'EEXIST') throw e;
} }
@ -378,6 +378,7 @@ exports.LineReader.prototype = {
while(this.buffer.indexOf('\n') === -1) { while(this.buffer.indexOf('\n') === -1) {
this.getBufferAndSetCurrentPosition(this.currentPosition); this.getBufferAndSetCurrentPosition(this.currentPosition);
if(this.currentPosition === -1) return false; if(this.currentPosition === -1) return false;
if(this.buffer.length === 0) return false;
} }
if(this.buffer.indexOf("\n") > -1) return true; if(this.buffer.indexOf("\n") > -1) return true;