]> www.ginac.de Git - cln.git/blob - src/base/string/input/cl_st_getline1.cc
e3435c6bd6375cfa516dfce52ee1fe4d0e49d323
[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 "cl_string.h"
8
9
10 // Implementation.
11
12 #ifdef CL_IO_IOSTREAM
13
14 #include "cl_io.h"
15 #include "cl_spushstring.h"
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;  // ios::eofbit already set
25                 if (c==delim)
26                         break;
27                 buffer.push(c);
28         }
29         return buffer.contents();
30 }
31
32 #endif