|
|
@ -9,6 +9,9 @@ |
|
|
|
@license LGPL, see file <a href="license.html">COPYING</a> |
|
|
|
@license LGPL, see file <a href="license.html">COPYING</a> |
|
|
|
|
|
|
|
|
|
|
|
$Log$ |
|
|
|
$Log$ |
|
|
|
|
|
|
|
Revision 1.2 2004/12/14 20:21:21 marc |
|
|
|
|
|
|
|
bugfix, now it works for empty lines |
|
|
|
|
|
|
|
|
|
|
|
Revision 1.1 2004/10/13 11:18:33 marc |
|
|
|
Revision 1.1 2004/10/13 11:18:33 marc |
|
|
|
getline reads a whole line from a stream |
|
|
|
getline reads a whole line from a stream |
|
|
|
|
|
|
|
|
|
|
@ -18,15 +21,8 @@ |
|
|
|
#include <stdext.hpp> |
|
|
|
#include <stdext.hpp> |
|
|
|
|
|
|
|
|
|
|
|
std::string mrw::getline(std::istream& is, char d) { |
|
|
|
std::string mrw::getline(std::istream& is, char d) { |
|
|
|
char buf[255]; |
|
|
|
|
|
|
|
char c; |
|
|
|
|
|
|
|
std::string s; |
|
|
|
std::string s; |
|
|
|
do { |
|
|
|
mrw::getline(is, s, d); |
|
|
|
if (is && is.get(buf, 255, d)) { |
|
|
|
|
|
|
|
s += buf; |
|
|
|
|
|
|
|
if (is.get(c) && c!=d) s+=c; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} while (is.good() && !is.eof() && c!=d); |
|
|
|
|
|
|
|
return s; |
|
|
|
return s; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -35,8 +31,9 @@ std::istream& mrw::getline(std::istream& is, std::string& s, char d) { |
|
|
|
char c; |
|
|
|
char c; |
|
|
|
s.clear(); |
|
|
|
s.clear(); |
|
|
|
do { |
|
|
|
do { |
|
|
|
if (is && is.get(buf, 255, d)) { |
|
|
|
if (is) { |
|
|
|
s += buf; |
|
|
|
if (is.get(buf, 255, d)) s += buf; |
|
|
|
|
|
|
|
is.clear(); // is.get fails if line is empty
|
|
|
|
if (is.get(c) && c!=d) s+=c; |
|
|
|
if (is.get(c) && c!=d) s+=c; |
|
|
|
} |
|
|
|
} |
|
|
|
} while (is.good() && !is.eof() && c!=d); |
|
|
|
} while (is.good() && !is.eof() && c!=d); |
|
|
|