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

Function strip_quotes

src/backend/utils/misc/string_utils.c:24–56  ·  view source on GitHub ↗

* strip_quotes * * (copied from bin/psql/stringutils.c - TODO: place to share FE and BE code?). * * 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 str

Source from the content-addressed store, hash-verified

22 * Note that the source string is overwritten in-place.
23 */
24extern void
25strip_quotes(char *source, char quote, char escape, int encoding)
26{
27 char *src;
28 char *dst;
29
30 Assert(source);
31 Assert(quote);
32
33 src = dst = source;
34
35 if (*src && *src == quote)
36 src++; /* skip leading quote */
37
38 while (*src)
39 {
40 char c = *src;
41 int i;
42
43 if (c == quote && src[1] == '\0')
44 break; /* skip trailing quote */
45 else if (c == quote && src[1] == quote)
46 src++; /* process doubled quote */
47 else if (c == escape && src[1] != '\0')
48 src++; /* process escaped character */
49
50 i = pg_encoding_mblen(encoding, src);
51 while (i--)
52 *dst++ = *src++;
53 }
54
55 *dst = '\0';
56}
57
58/*
59 * strtokx2

Callers 1

strtokx2Function · 0.70

Calls 1

pg_encoding_mblenFunction · 0.85

Tested by

no test coverage detected