Clarify code to double \\ and '.
authorBruce Momjian <bruce@momjian.us>
Fri, 1 Jul 2005 17:40:29 +0000 (17:40 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 1 Jul 2005 17:40:29 +0000 (17:40 +0000)
src/bin/initdb/initdb.c
src/bin/psql/describe.c
src/bin/psql/large_obj.c
src/pl/plpgsql/src/gram.y

index daafc96476759d54871add361f4f4f7b3d73ad60..250b2563a7e00fe5a84b6ee0378aee49964f572b 100644 (file)
@@ -42,7 +42,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  * Portions taken from FreeBSD.
  *
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.88 2005/06/28 15:38:12 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.89 2005/07/01 17:40:28 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1986,10 +1986,8 @@ escape_quotes(const char *src)
        
        for (i = 0, j = 0; i < len; i++)
        {
-               if (src[i] == '\\')
-                       result[j++] = '\\';
-               if (src[i] == '\'')             /* ANSI standard, '' */
-                       result[j++] = '\'';
+               if (src[i] == '\\' || src[i] == '\'')
+                       result[j++] = src[i];   /* double these */
                result[j++] = src[i];
        }
        result[j] = '\0';
index b7397515b73ba6ced40169bd53d7e427e5e31b13..49553268c639a1b36fae9ef9622121e89dcc64ec 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2005, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.118 2005/06/26 03:03:56 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.119 2005/07/01 17:40:28 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "describe.h"
@@ -1899,7 +1899,7 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
 
                        /* Ensure chars special to string literals are passed properly */
                        if (*cp == '\'' || *cp == '\\')
-                               appendPQExpBufferChar(&namebuf, *cp);
+                               appendPQExpBufferChar(&namebuf, *cp);   /* double these */
 
                        i = PQmblen(cp, pset.encoding);
                        while (i--)
index 6606e99849522f5b0c53ad533d581093f8979f20..f7f9b2fd25c1757429e2af8b187a9d4ad8fc5054 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2005, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.37 2005/06/14 02:57:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.38 2005/07/01 17:40:28 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "large_obj.h"
@@ -178,7 +178,7 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
                for (i = 0; i < slen; i++)
                {
                        if (comment_arg[i] == '\'' || comment_arg[i] == '\\')
-                               *bufptr++ = '\\';
+                               *bufptr++ = comment_arg[i];     /* double these */
                        *bufptr++ = comment_arg[i];
                }
                strcpy(bufptr, "'");
index f33d373883e6aa7fd7164df1022fbf5b5be7e60b..5d3fd8259b5a83256bdee4ec9612b92ebffcdc9c 100644 (file)
@@ -4,7 +4,7 @@
  *                                               procedural language
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.77 2005/06/22 01:35:02 neilc Exp $
+ *       $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.78 2005/07/01 17:40:29 momjian Exp $
  *
  *       This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -387,7 +387,7 @@ decl_statement      : decl_varname decl_const decl_datatype decl_notnull decl_defval
                                                while (*cp1 != '\0')
                                                {
                                                        if (*cp1 == '\\' || *cp1 == '\'')
-                                                               *cp2++ = '\\';
+                                                               *cp2++ = *cp1;  /* double these */
                                                        *cp2++ = *cp1++;
                                                }
                                                strcpy(cp2, "'::refcursor");