diff options
| author | ruki <[email protected]> | 2019-07-06 00:03:00 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-07-05 22:11:19 +0800 |
| commit | 124f03f327db5246a0ae19f67784aaf26a0be6b5 (patch) | |
| tree | 3916906ba3dde0d61c9a1f01a0437700ee23d2cf | |
| parent | 48f852eefe1f781756e86a2b3fb2bab5e16deda9 (diff) | |
fix pushline
| -rw-r--r-- | core/src/xmake/io/file_read.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/src/xmake/io/file_read.c b/core/src/xmake/io/file_read.c index 5ae7b91b3..1bf722cc4 100644 --- a/core/src/xmake/io/file_read.c +++ b/core/src/xmake/io/file_read.c @@ -81,7 +81,14 @@ static tb_int_t xm_io_file_buffer_pushline(luaL_Buffer* buf, xm_io_file* file, t { // check tb_assert(file && continuation && xm_io_file_is_file(file) && !xm_io_file_is_closed(file)); - tb_assert(file->encoding != XM_IO_FILE_ENCODING_BINARY); + + // is binary? + tb_bool_t is_binary = file->encoding == XM_IO_FILE_ENCODING_BINARY; + if (is_binary) + { + continuation = ""; + keep_crlf = tb_true; + } // init line buffer tb_buffer_t line; @@ -116,7 +123,7 @@ static tb_int_t xm_io_file_buffer_pushline(luaL_Buffer* buf, xm_io_file* file, t else if (size > 1) { // crlf? => lf - if (data[size - 2] == '\r') + if (!is_binary && data[size - 2] == '\r') { data[size - 2] = '\n'; size--; |
