Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions std/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -1846,14 +1846,19 @@ is recommended if you want to process a complete file.
}
else
{
// TODO: optimize this
string s = readln(terminator);
buf.length = 0;
if (!s.length) return 0;
foreach (C c; s)
if (!s.length)
{
buf ~= c;
buf = buf[0 .. 0];
return 0;
}

import std.utf : codeLength;
buf.length = codeLength!C(s);
size_t idx;
foreach (C c; s)
buf[idx++] = c;

return buf.length;
}
}
Expand Down