Skip to content

Commit 2f7d369

Browse files
committed
Clarify code to double \\ and '.
1 parent f009248 commit 2f7d369

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

src/bin/initdb/initdb.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
* Portions taken from FreeBSD.
4444
*
45-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.88 2005/06/28 15:38:12 tgl Exp $
45+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.89 2005/07/01 17:40:28 momjian Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -1986,10 +1986,8 @@ escape_quotes(const char *src)
19861986

19871987
for (i = 0, j = 0; i < len; i++)
19881988
{
1989-
if (src[i] == '\\')
1990-
result[j++] = '\\';
1991-
if (src[i] == '\'') /* ANSI standard, '' */
1992-
result[j++] = '\'';
1989+
if (src[i] == '\\' || src[i] == '\'')
1990+
result[j++] = src[i]; /* double these */
19931991
result[j++] = src[i];
19941992
}
19951993
result[j] = '\0';

src/bin/psql/describe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.118 2005/06/26 03:03:56 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.119 2005/07/01 17:40:28 momjian Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "describe.h"
@@ -1899,7 +1899,7 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
18991899

19001900
/* Ensure chars special to string literals are passed properly */
19011901
if (*cp == '\'' || *cp == '\\')
1902-
appendPQExpBufferChar(&namebuf, *cp);
1902+
appendPQExpBufferChar(&namebuf, *cp); /* double these */
19031903

19041904
i = PQmblen(cp, pset.encoding);
19051905
while (i--)

src/bin/psql/large_obj.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.37 2005/06/14 02:57:41 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.38 2005/07/01 17:40:28 momjian Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "large_obj.h"
@@ -178,7 +178,7 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
178178
for (i = 0; i < slen; i++)
179179
{
180180
if (comment_arg[i] == '\'' || comment_arg[i] == '\\')
181-
*bufptr++ = '\\';
181+
*bufptr++ = comment_arg[i]; /* double these */
182182
*bufptr++ = comment_arg[i];
183183
}
184184
strcpy(bufptr, "'");

src/pl/plpgsql/src/gram.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.77 2005/06/22 01:35:02 neilc Exp $
7+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.78 2005/07/01 17:40:29 momjian Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -387,7 +387,7 @@ decl_statement : decl_varname decl_const decl_datatype decl_notnull decl_defval
387387
while (*cp1 != '\0')
388388
{
389389
if (*cp1 == '\\' || *cp1 == '\'')
390-
*cp2++ = '\\';
390+
*cp2++ = *cp1; /* double these */
391391
*cp2++ = *cp1++;
392392
}
393393
strcpy(cp2, "'::refcursor");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy