53 const char *whitespace,
63 static char *
string = NULL;
89 offset = strspn(
string, whitespace);
90 start = &
string[offset];
103 if (delim && strchr(delim, *
start))
115 if (!strchr(whitespace, *p))
116 memmove(p + 1, p, strlen(p) + 1);
132 (*p ==
'E' || *p ==
'e') &&
141 if (quote && strchr(quote, *p))
144 char thisquote = *p++;
148 if (*p == escape && p[1] !=
'\0')
150 else if (*p == thisquote && p[1] == thisquote)
152 else if (*p == thisquote)
165 if (!strchr(whitespace, *p))
166 memmove(p + 1, p, strlen(p) + 1);
188 offset = strcspn(
start, whitespace);
192 unsigned int offset2 = strcspn(
start, delim);
194 if (offset > offset2)
200 unsigned int offset2 = strcspn(
start, quote);
202 if (offset > offset2)
214 if (!strchr(whitespace, *p))
215 memmove(p + 1, p, strlen(p) + 1);
250 if (*src && *src == quote)
258 if (
c == quote && src[1] ==
'\0')
260 else if (
c == quote && src[1] == quote)
262 else if (
c == escape && src[1] !=
'\0')
293 char quote,
char escape,
bool force_quote,
299 bool need_quotes = force_quote;
305 dst = ret =
pg_malloc(2 * strlen(src) + 3);
319 else if (
c == escape)
324 else if (strchr(entails_quote,
c))
#define Assert(condition)
int PQmblenBounded(const char *s, int encoding)
void * pg_malloc(size_t size)
static rewind_source * source
char * quote_if_needed(const char *source, const char *entails_quote, char quote, char escape, bool force_quote, int encoding)
char * strtokx(const char *s, const char *whitespace, const char *delim, const char *quote, char escape, bool e_strings, bool del_quotes, int encoding)
void strip_quotes(char *source, char quote, char escape, int encoding)