]> www.ginac.de Git - cln.git/blob - src/base/string/input/cl_st_getline1.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / base / string / input / cl_st_getline1.cc
1 // cl_fgetline().
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_fgetline (cl_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                         break;
27                 buffer.push(c);
28         }
29         return buffer.contents();
30 }
31
32 }  // namespace cln