MCPcopy Create free account
hub / github.com/git/git / sq_dequote_step

Function sq_dequote_step

quote.c:123–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123char *sq_dequote_step(char *arg, char **next)
124{
125 char *dst = arg;
126 char *src = arg;
127 char c;
128
129 if (*src != '\'')
130 return NULL;
131 for (;;) {
132 c = *++src;
133 if (!c)
134 return NULL;
135 if (c != '\'') {
136 *dst++ = c;
137 continue;
138 }
139 /* We stepped out of sq */
140 switch (*++src) {
141 case '\0':
142 *dst = 0;
143 if (next)
144 *next = NULL;
145 return arg;
146 case '\\':
147 /*
148 * Allow backslashed characters outside of
149 * single-quotes only if they need escaping,
150 * and only if we resume the single-quoted part
151 * afterward.
152 */
153 if (need_bs_quote(src[1]) && src[2] == '\'') {
154 *dst++ = src[1];
155 src += 2;
156 continue;
157 }
158 /* Fallthrough */
159 default:
160 if (!next)
161 return NULL;
162 *dst = 0;
163 *next = src;
164 return arg;
165 }
166 }
167}
168
169char *sq_dequote(char *arg)
170{

Callers 3

parse_config_env_listFunction · 0.85
sq_dequoteFunction · 0.85
sq_dequote_to_strvecFunction · 0.85

Calls 1

need_bs_quoteFunction · 0.85

Tested by

no test coverage detected