blob: 1e805825af36c3bec32400e268ae91194b23ba39 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// license:GPL-2.0+
// copyright-holders:Couriersud
/*
* pstream.c
*
*/
#include "pstream.h"
#include "palloc.h"
#include <algorithm>
#include <cstdio>
//#include <cstdlib>
// VS2015 prefers _dup
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
namespace plib {
bool putf8_reader::readline(pstring &line)
{
putf8string::code_t c = 0;
m_linebuf = "";
if (!this->readcode(c))
{
line = "";
return false;
}
while (true)
{
if (c == 10)
break;
else if (c != 13) /* ignore CR */
m_linebuf += putf8string(1, c);
if (!this->readcode(c))
break;
}
line = m_linebuf.c_str();
return true;
}
void putf8_fmt_writer::vdowrite(const pstring &ls) const
{
write(ls);
}
} // namespace plib
|