From: Mikko Rasa Date: Wed, 15 Jun 2011 08:20:13 +0000 (+0300) Subject: Fix Memory::getline X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=bff25a255af05f1ddd6c956a97fa6b8c50c9b22d;p=libs%2Fcore.git Fix Memory::getline --- diff --git a/source/io/memory.cpp b/source/io/memory.cpp index fa8f905..274f6ba 100644 --- a/source/io/memory.cpp +++ b/source/io/memory.cpp @@ -70,11 +70,16 @@ 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()