MCPcopy Create free account
hub / github.com/apache/cloudberry / strip_quotes

Function strip_quotes

src/bin/psql/stringutils.c:239–271  ·  view source on GitHub ↗

* strip_quotes * * Remove quotes from the string at *source. Leading and trailing occurrences * of 'quote' are removed; embedded double occurrences of 'quote' are reduced * to single occurrences; if 'escape' is not 0 then 'escape' removes special * significance of next character. * * Note that the source string is overwritten in-place. */

Source from the content-addressed store, hash-verified

237 * Note that the source string is overwritten in-place.
238 */
239void
240strip_quotes(char *source, char quote, char escape, int encoding)
241{
242 char *src;
243 char *dst;
244
245 Assert(source != NULL);
246 Assert(quote != '\0');
247
248 src = dst = source;
249
250 if (*src && *src == quote)
251 src++; /* skip leading quote */
252
253 while (*src)
254 {
255 char c = *src;
256 int i;
257
258 if (c == quote && src[1] == '\0')
259 break; /* skip trailing quote */
260 else if (c == quote && src[1] == quote)
261 src++; /* process doubled quote */
262 else if (c == escape && src[1] != '\0')
263 src++; /* process escaped character */
264
265 i = PQmblenBounded(src, encoding);
266 while (i--)
267 *dst++ = *src++;
268 }
269
270 *dst = '\0';
271}
272
273
274/*

Callers 2

parse_slash_copyFunction · 0.70
strtokxFunction · 0.70

Calls 1

PQmblenBoundedFunction · 0.85

Tested by

no test coverage detected