@matheusbsbs / matheus-bagliano / commits / dfc7f65c26
Fork 0

quote: rename misnamed sq_lookup[] to cq_lookup[]

This table is used to see if each byte needs quoting when responding to a request to C-quote the string, not quoting with single-quote in the shell style. Similarly, sq_must_quote() is fed each byte from the string being C-quoted. No behaviour change intended. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Sep 10, 2020 at 10:01 UTC dfc7f65c261e923a41c910a11390d487e66eb6fe
1 file changed +7 -7
quote.c
+7 -7
@@ -210,7 +210,7 @@ int sq_dequote_to_strvec(char *arg, struct strvec *array)
210 */
211 #define X8(x) x, x, x, x, x, x, x, x
212 #define X16(x) X8(x), X8(x)
213 -static signed char const sq_lookup[256] = {
213 +static signed char const cq_lookup[256] = {
214 /* 0 1 2 3 4 5 6 7 */
215 /* 0x00 */ 1, 1, 1, 1, 1, 1, 1, 'a',
216 /* 0x08 */ 'b', 't', 'n', 'v', 'f', 'r', 1, 1,
@@ -223,9 +223,9 @@ static signed char const sq_lookup[256] = {
223 /* 0x80 */ /* set to 0 */
224 };
225
226 -static inline int sq_must_quote(char c)
226 +static inline int cq_must_quote(char c)
227 {
228 - return sq_lookup[(unsigned char)c] + quote_path_fully > 0;
228 + return cq_lookup[(unsigned char)c] + quote_path_fully > 0;
229 }
230
231 /* returns the longest prefix not needing a quote up to maxlen if positive.
@@ -235,9 +235,9 @@ static size_t next_quote_pos(const char *s, ssize_t maxlen)
235 {
236 size_t len;
237 if (maxlen < 0) {
238 - for (len = 0; !sq_must_quote(s[len]); len++);
238 + for (len = 0; !cq_must_quote(s[len]); len++);
239 } else {
240 - for (len = 0; len < maxlen && !sq_must_quote(s[len]); len++);
240 + for (len = 0; len < maxlen && !cq_must_quote(s[len]); len++);
241 }
242 return len;
243 }
@@ -291,8 +291,8 @@ static size_t quote_c_style_counted(const char *name, ssize_t maxlen,
291 ch = (unsigned char)*p++;
292 if (maxlen >= 0)
293 maxlen -= len + 1;
294 - if (sq_lookup[ch] >= ' ') {
295 - EMIT(sq_lookup[ch]);
294 + if (cq_lookup[ch] >= ' ') {
295 + EMIT(cq_lookup[ch]);
296 } else {
297 EMIT(((ch >> 6) & 03) + '0');
298 EMIT(((ch >> 3) & 07) + '0');