Skip to content

Commit f787663

Browse files
committed
[js] Replace \r\n with \n when reading in files.
1 parent fb74f7c commit f787663

File tree

1 file changed

+3
-3
lines changed
  • src/vm/js/nqp-runtime

1 file changed

+3
-3
lines changed

src/vm/js/nqp-runtime/io.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ function readline(fh, chomp) {
200200
fs.seekSync(fh.fd,
201201
Buffer.byteLength(up_to_newline + sep, fh.encoding) + starting, 0);
202202

203-
return (chomp ? up_to_newline : up_to_newline + sep);
203+
return (chomp ? up_to_newline : up_to_newline + sep).replace(/\r\n/, "\n");
204204
}
205205
}
206206

207207
fs.seekSync(fh.fd, position, 0);
208-
return string;
208+
return string.replace(/\r\n/, "\n");
209209
};
210210

211211

@@ -218,7 +218,7 @@ op.readallfh = function(fh) {
218218
total += bytesRead;
219219
var all = Buffer.concat([all, buf], total);
220220
}
221-
return iconv.decode(all, fh.encoding);
221+
return iconv.decode(all, fh.encoding).replace(/\r\n/, "\n");
222222
};
223223

224224
op.seekfh = function(fh, offset, whence, ctx) {

0 commit comments

Comments
 (0)