summaryrefslogtreecommitdiff
path: root/quote.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-09-10 17:01:58 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-09-10 20:07:24 (GMT)
commitdfc7f65c261e923a41c910a11390d487e66eb6fe (patch)
tree7ad6fd17c85a6c8341f3d7cb1026aabafac0c2c0 /quote.c
parenta361dd3f798968b3be4bd10d0f4133dc1f48e50b (diff)
downloadgit-dfc7f65c261e923a41c910a11390d487e66eb6fe.zip
git-dfc7f65c261e923a41c910a11390d487e66eb6fe.tar.gz
git-dfc7f65c261e923a41c910a11390d487e66eb6fe.tar.bz2
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>
Diffstat (limited to 'quote.c')
-rw-r--r--quote.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/quote.c b/quote.c
index 0b01121..192e2ee 100644
--- a/quote.c
+++ b/quote.c
@@ -210,7 +210,7 @@ int sq_dequote_to_strvec(char *arg, struct strvec *array)
*/
#define X8(x) x, x, x, x, x, x, x, x
#define X16(x) X8(x), X8(x)
-static signed char const sq_lookup[256] = {
+static signed char const cq_lookup[256] = {
/* 0 1 2 3 4 5 6 7 */
/* 0x00 */ 1, 1, 1, 1, 1, 1, 1, 'a',
/* 0x08 */ 'b', 't', 'n', 'v', 'f', 'r', 1, 1,
@@ -223,9 +223,9 @@ static signed char const sq_lookup[256] = {
/* 0x80 */ /* set to 0 */
};
-static inline int sq_must_quote(char c)
+static inline int cq_must_quote(char c)
{
- return sq_lookup[(unsigned char)c] + quote_path_fully > 0;
+ return cq_lookup[(unsigned char)c] + quote_path_fully > 0;
}
/* 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)
{
size_t len;
if (maxlen < 0) {
- for (len = 0; !sq_must_quote(s[len]); len++);
+ for (len = 0; !cq_must_quote(s[len]); len++);
} else {
- for (len = 0; len < maxlen && !sq_must_quote(s[len]); len++);
+ for (len = 0; len < maxlen && !cq_must_quote(s[len]); len++);
}
return len;
}
@@ -291,8 +291,8 @@ static size_t quote_c_style_counted(const char *name, ssize_t maxlen,
ch = (unsigned char)*p++;
if (maxlen >= 0)
maxlen -= len + 1;
- if (sq_lookup[ch] >= ' ') {
- EMIT(sq_lookup[ch]);
+ if (cq_lookup[ch] >= ' ') {
+ EMIT(cq_lookup[ch]);
} else {
EMIT(((ch >> 6) & 03) + '0');
EMIT(((ch >> 3) & 07) + '0');