]> git.tdb.fi Git - libs/core.git/commitdiff
Fix Memory::getline
authorMikko Rasa <tdb@tdb.fi>
Wed, 15 Jun 2011 08:20:13 +0000 (11:20 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 18 Jun 2011 18:36:07 +0000 (21:36 +0300)
source/io/memory.cpp

index fa8f9053de029e3965f1fd4c261a43e6c4a69c1c..274f6bae91c1a6a1d53f67be3872319bdae85bc2 100644 (file)
@@ -70,11 +70,16 @@ unsigned Memory::put(char c)
 
 bool Memory::getline(string &line)
 {
 
 bool Memory::getline(string &line)
 {
+       if(pos==end)
+       {
+               set_eof();
+               return false;
+       }
+
        char *nl = find(pos, end, '\n');
        line.assign(pos, nl);
        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()
 }
 
 int Memory::get()