mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 02:36:16 +02:00
Add eofOk
parameter to the Windows readLine
impl
Now the two implementations are back in sync.
This commit is contained in:
parent
372353722e
commit
a6149eb89d
1 changed files with 7 additions and 3 deletions
|
@ -61,7 +61,7 @@ void writeFull(HANDLE handle, std::string_view s, bool allowInterrupts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string readLine(HANDLE handle)
|
std::string readLine(HANDLE handle, bool eofOk)
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -71,8 +71,12 @@ std::string readLine(HANDLE handle)
|
||||||
DWORD rd;
|
DWORD rd;
|
||||||
if (!ReadFile(handle, &ch, 1, &rd, NULL)) {
|
if (!ReadFile(handle, &ch, 1, &rd, NULL)) {
|
||||||
throw WinError("reading a line");
|
throw WinError("reading a line");
|
||||||
} else if (rd == 0)
|
} else if (rd == 0) {
|
||||||
throw EndOfFile("unexpected EOF reading a line");
|
if (eofOk)
|
||||||
|
return s;
|
||||||
|
else
|
||||||
|
throw EndOfFile("unexpected EOF reading a line");
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (ch == '\n') return s;
|
if (ch == '\n') return s;
|
||||||
s += ch;
|
s += ch;
|
||||||
|
|
Loading…
Reference in a new issue