32 const char **out_bufp,
size_t *out_lenp) {
33 bool transformed =
false;
34 const char *in_ptr = in_buf;
35 const char *in_end = in_buf + in_len;
36 const char *last_xfer = in_buf;
38 while (in_ptr < in_end) {
39 if (*in_ptr ==
'\n' || *in_ptr ==
'\t' || *in_ptr ==
'\0' || *in_ptr ==
'\\') {
40 if (*in_ptr ==
'\t' && m_field_separator !=
'\t') {
46 m_buf.reserve((in_len*2)+1);
49 memcpy(m_buf.ptr, last_xfer, in_ptr-last_xfer);
50 m_buf.ptr += (in_ptr-last_xfer);
55 else if (*in_ptr ==
'\t')
57 else if (*in_ptr ==
'\0')
69 memcpy(m_buf.ptr, last_xfer, in_ptr-last_xfer);
70 m_buf.ptr += (in_ptr-last_xfer);
72 *out_bufp = (
const char *)m_buf.base;
73 *out_lenp = m_buf.fill();
85 const char **out_bufp,
size_t *out_lenp) {
86 bool transformed =
false;
87 const char *in_ptr = in_buf;
88 const char *in_end = in_buf + (in_len - 1);
89 const char *last_xfer = in_buf;
97 while (in_ptr < in_end) {
98 if (*in_ptr ==
'\\' &&
99 (*(in_ptr+1) ==
'n' || *(in_ptr+1) ==
't' || *(in_ptr+1) ==
'0' || *(in_ptr+1) ==
'\\')) {
102 if (*(in_ptr+1) ==
't' && m_field_separator !=
'\t') {
108 m_buf.reserve(in_len+1);
111 memcpy(m_buf.ptr, last_xfer, in_ptr-last_xfer);
112 m_buf.ptr += (in_ptr-last_xfer);
114 if (*(in_ptr+1) ==
'n')
116 else if (*(in_ptr+1) ==
't')
118 else if (*(in_ptr+1) ==
'0')
132 memcpy(m_buf.ptr, last_xfer, in_ptr-last_xfer);
133 m_buf.ptr += (in_ptr-last_xfer);
135 *out_bufp = (
const char *)m_buf.base;
136 *out_lenp = m_buf.fill();
bool escape(const char *in_buf, size_t in_len, const char **out_bufp, size_t *out_lenp)
Compatibility Macros for C/C++.
bool unescape(const char *in_buf, size_t in_len, const char **out_bufp, size_t *out_lenp)