mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
fix a bug of reading CRLF file on win32
This commit is contained in:
parent
e9b4734004
commit
bd351b055f
@ -1,3 +1,6 @@
|
|||||||
|
if (Test-Path build) {
|
||||||
|
Remove-Item -Recurse -Force build
|
||||||
|
}
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
|
@ -58,6 +58,9 @@ Bytes _default_import_handler(const Str& name){
|
|||||||
std::vector<char> buffer(ftell(io.fp));
|
std::vector<char> buffer(ftell(io.fp));
|
||||||
fseek(io.fp, 0, SEEK_SET);
|
fseek(io.fp, 0, SEEK_SET);
|
||||||
size_t sz = io_fread(buffer.data(), 1, buffer.size(), io.fp);
|
size_t sz = io_fread(buffer.data(), 1, buffer.size(), io.fp);
|
||||||
|
PK_ASSERT(sz <= buffer.size());
|
||||||
|
// in text mode, CR may be dropped, which may cause `sz < buffer.size()`
|
||||||
|
if(sz < buffer.size()) buffer.resize(sz);
|
||||||
PK_UNUSED(sz);
|
PK_UNUSED(sz);
|
||||||
Bytes b(std::move(buffer));
|
Bytes b(std::move(buffer));
|
||||||
if(io.is_text()) return VAR(b.str());
|
if(io.is_text()) return VAR(b.str());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user