Skip to content

Commit dfc7f65

Browse files
committed
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 <[email protected]>
1 parent a361dd3 commit dfc7f65

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: quote.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ int sq_dequote_to_strvec(char *arg, struct strvec *array)
210210
*/
211211
#define X8(x) x, x, x, x, x, x, x, x
212212
#define X16(x) X8(x), X8(x)
213-
static signed char const sq_lookup[256] = {
213+
static signed char const cq_lookup[256] = {
214214
/* 0 1 2 3 4 5 6 7 */
215215
/* 0x00 */ 1, 1, 1, 1, 1, 1, 1, 'a',
216216
/* 0x08 */ 'b', 't', 'n', 'v', 'f', 'r', 1, 1,
@@ -223,9 +223,9 @@ static signed char const sq_lookup[256] = {
223223
/* 0x80 */ /* set to 0 */
224224
};
225225

226-
static inline int sq_must_quote(char c)
226+
static inline int cq_must_quote(char c)
227227
{
228-
return sq_lookup[(unsigned char)c] + quote_path_fully > 0;
228+
return cq_lookup[(unsigned char)c] + quote_path_fully > 0;
229229
}
230230

231231
/* 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)
235235
{
236236
size_t len;
237237
if (maxlen < 0) {
238-
for (len = 0; !sq_must_quote(s[len]); len++);
238+
for (len = 0; !cq_must_quote(s[len]); len++);
239239
} 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++);
241241
}
242242
return len;
243243
}
@@ -291,8 +291,8 @@ static size_t quote_c_style_counted(const char *name, ssize_t maxlen,
291291
ch = (unsigned char)*p++;
292292
if (maxlen >= 0)
293293
maxlen -= len + 1;
294-
if (sq_lookup[ch] >= ' ') {
295-
EMIT(sq_lookup[ch]);
294+
if (cq_lookup[ch] >= ' ') {
295+
EMIT(cq_lookup[ch]);
296296
} else {
297297
EMIT(((ch >> 6) & 03) + '0');
298298
EMIT(((ch >> 3) & 07) + '0');

0 commit comments

Comments
 (0)