X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fmemory.cpp;h=274f6bae91c1a6a1d53f67be3872319bdae85bc2;hp=6ccf84654764cbe8086a3ac841330580d302dcd1;hb=bff25a255af05f1ddd6c956a97fa6b8c50c9b22d;hpb=df5ab3d867c51d72344e443e3adb05bfa29a2b53 diff --git a/source/io/memory.cpp b/source/io/memory.cpp index 6ccf846..274f6ba 100644 --- a/source/io/memory.cpp +++ b/source/io/memory.cpp @@ -51,7 +51,7 @@ unsigned Memory::do_read(char *buf, unsigned size) { if(pos==end) { - eof_flag = true; + set_eof(); return 0; } @@ -70,18 +70,23 @@ unsigned Memory::put(char c) bool Memory::getline(string &line) { + if(pos==end) + { + set_eof(); + return false; + } + char *nl = find(pos, end, '\n'); line.assign(pos, nl); - bool result = (nl!=pos); - pos = nl; - return result; + pos = (nl==end ? end : nl+1); + return true; } int Memory::get() { if(pos==end) { - eof_flag = true; + set_eof(); return -1; }