]> www.ginac.de Git - cln.git/blob - src/base/string/input/cl_st_get1.cc
Cater to the fact that g++ 4.3 will use a different naming for
[cln.git] / src / base / string / input / cl_st_get1.cc
1 // cl_fget().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/string.h"
8
9
10 // Implementation.
11
12 #include "cln/io.h"
13 #include "cl_spushstring.h"
14
15 namespace cln {
16
17 const cl_string cl_fget (std::istream& stream, char delim)
18 {
19         var cl_spushstring buffer;
20         // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.get()==EOF).
21         while (stream.good()) {
22                 var int c = stream.get();
23                 if (c==EOF)
24                         break;  // std::ios::eofbit already set
25                 if (c==delim) {
26                         stream.unget();
27                         break;
28                 }
29                 buffer.push(c);
30         }
31         return buffer.contents();
32 }
33
34 }  // namespace cln