From 30c0c4bf12cc56a7a6c2b7f874e2cd4c95cd3491 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 22 Dec 2015 22:43:46 -0500 Subject: [PATCH] Remove unnecessary escaping in C character literals '\"' is more commonly written simply as '"'. --- src/backend/nodes/outfuncs.c | 2 +- src/backend/nodes/read.c | 2 +- src/backend/utils/adt/arrayfuncs.c | 4 ++-- src/backend/utils/adt/json.c | 4 ++-- src/backend/utils/adt/rangetypes.c | 4 ++-- src/backend/utils/adt/rowtypes.c | 4 ++-- src/backend/utils/adt/varlena.c | 12 ++++++------ src/bin/pg_dump/dumputils.c | 8 ++++---- src/interfaces/ecpg/preproc/output.c | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index fe2c643c34..7169d46feb 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -124,7 +124,7 @@ _outToken(StringInfo str, const char *s) */ /* These characters only need to be quoted at the start of the string */ if (*s == '<' || - *s == '\"' || + *s == '"' || isdigit((unsigned char) *s) || ((*s == '+' || *s == '-') && (isdigit((unsigned char) s[1]) || s[1] == '.'))) diff --git a/src/backend/nodes/read.c b/src/backend/nodes/read.c index 0dabfa7dc9..71d69ecd25 100644 --- a/src/backend/nodes/read.c +++ b/src/backend/nodes/read.c @@ -245,7 +245,7 @@ nodeTokenType(char *token, int length) retval = RIGHT_PAREN; else if (*token == '{') retval = LEFT_BRACE; - else if (*token == '\"' && length > 1 && token[length - 1] == '\"') + else if (*token == '"' && length > 1 && token[length - 1] == '"') retval = T_String; else if (*token == 'b') retval = T_BitString; diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 359fb1462b..72d308a597 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -515,7 +515,7 @@ ArrayCount(const char *str, int *dim, char typdelim) errmsg("malformed array literal: \"%s\"", str), errdetail("Unexpected end of input."))); break; - case '\"': + case '"': /* * A quote must be after a level start, after a quoted @@ -799,7 +799,7 @@ ReadArrayStr(char *arrayStr, dstendptr = dstptr; hasquoting = true; /* can't be a NULL marker */ break; - case '\"': + case '"': in_quotes = !in_quotes; if (in_quotes) leadingspace = false; diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c index af97fc1eff..a54604ee9d 100644 --- a/src/backend/utils/adt/json.c +++ b/src/backend/utils/adt/json.c @@ -2415,7 +2415,7 @@ escape_json(StringInfo buf, const char *str) { const char *p; - appendStringInfoCharMacro(buf, '\"'); + appendStringInfoCharMacro(buf, '"'); for (p = str; *p; p++) { switch (*p) @@ -2449,7 +2449,7 @@ escape_json(StringInfo buf, const char *str) break; } } - appendStringInfoCharMacro(buf, '\"'); + appendStringInfoCharMacro(buf, '"'); } /* diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c index 88f857b509..21e386c279 100644 --- a/src/backend/utils/adt/rangetypes.c +++ b/src/backend/utils/adt/rangetypes.c @@ -2132,11 +2132,11 @@ range_parse_bound(const char *string, const char *ptr, errdetail("Unexpected end of input."))); appendStringInfoChar(&buf, *ptr++); } - else if (ch == '\"') + else if (ch == '"') { if (!inquote) inquote = true; - else if (*ptr == '\"') + else if (*ptr == '"') { /* doubled quote within quote sequence */ appendStringInfoChar(&buf, *ptr++); diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c index e1c72a1232..567622f759 100644 --- a/src/backend/utils/adt/rowtypes.c +++ b/src/backend/utils/adt/rowtypes.c @@ -216,11 +216,11 @@ record_in(PG_FUNCTION_ARGS) errdetail("Unexpected end of input."))); appendStringInfoChar(&buf, *ptr++); } - else if (ch == '\"') + else if (ch == '"') { if (!inquote) inquote = true; - else if (*ptr == '\"') + else if (*ptr == '"') { /* doubled quote within quote sequence */ appendStringInfoChar(&buf, *ptr++); diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index a89f586aba..85f85d430e 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -3007,16 +3007,16 @@ SplitIdentifierString(char *rawstring, char separator, char *curname; char *endp; - if (*nextp == '\"') + if (*nextp == '"') { /* Quoted name --- collapse quote-quote pairs, no downcasing */ curname = nextp + 1; for (;;) { - endp = strchr(nextp + 1, '\"'); + endp = strchr(nextp + 1, '"'); if (endp == NULL) return false; /* mismatched quotes */ - if (endp[1] != '\"') + if (endp[1] != '"') break; /* found end of quoted name */ /* Collapse adjacent quotes into one quote, and look again */ memmove(endp, endp + 1, strlen(endp)); @@ -3132,16 +3132,16 @@ SplitDirectoriesString(char *rawstring, char separator, char *curname; char *endp; - if (*nextp == '\"') + if (*nextp == '"') { /* Quoted name --- collapse quote-quote pairs */ curname = nextp + 1; for (;;) { - endp = strchr(nextp + 1, '\"'); + endp = strchr(nextp + 1, '"'); if (endp == NULL) return false; /* mismatched quotes */ - if (endp[1] != '\"') + if (endp[1] != '"') break; /* found end of quoted name */ /* Collapse adjacent quotes into one quote, and look again */ memmove(endp, endp + 1, strlen(endp)); diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 52b2b98ed0..da82af25d3 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -130,7 +130,7 @@ fmtId(const char *rawid) } else { - appendPQExpBufferChar(id_return, '\"'); + appendPQExpBufferChar(id_return, '"'); for (cp = rawid; *cp; cp++) { /* @@ -138,11 +138,11 @@ fmtId(const char *rawid) * double double-quote per SQL99. Before, we put in a * backslash/double-quote pair. - thomas 2000-08-05 */ - if (*cp == '\"') - appendPQExpBufferChar(id_return, '\"'); + if (*cp == '"') + appendPQExpBufferChar(id_return, '"'); appendPQExpBufferChar(id_return, *cp); } - appendPQExpBufferChar(id_return, '\"'); + appendPQExpBufferChar(id_return, '"'); } return id_return->data; diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c index 8cac947b5a..cf2ed58d0a 100644 --- a/src/interfaces/ecpg/preproc/output.c +++ b/src/interfaces/ecpg/preproc/output.c @@ -197,7 +197,7 @@ output_escaped_str(char *str, bool quoted) int i = 0; int len = strlen(str); - if (quoted && str[0] == '\"' && str[len - 1] == '\"') /* do not escape quotes + if (quoted && str[0] == '"' && str[len - 1] == '"') /* do not escape quotes * at beginning and end * if quoted string */ { @@ -241,6 +241,6 @@ output_escaped_str(char *str, bool quoted) fputc(str[i], yyout); } - if (quoted && str[0] == '\"' && str[len] == '\"') + if (quoted && str[0] == '"' && str[len] == '"') fputs("\"", yyout); }