Changed statement escaping to not escape continuation line markers.
authorMichael Meskes <meskes@postgresql.org>
Thu, 20 Mar 2008 15:56:59 +0000 (15:56 +0000)
committerMichael Meskes <meskes@postgresql.org>
Thu, 20 Mar 2008 15:56:59 +0000 (15:56 +0000)
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/preproc/output.c

index 613a3096886d947511174925ab6bc66635025a38..2147d28efcb083e91053c2106ed8507ac6bce371 100644 (file)
@@ -2327,3 +2327,8 @@ Sun, 02 Mar 2008 11:50:48 +0100
 
        - Fixed bug that caused arrays of varchar to be output with incomplete
          name.
+
+Thu, 20 Mar 2008 16:54:27 +0100
+
+       - Changed statement escaping to not escape continuation line markers.
+
index d503c996025da4fb59fb4a05158eb4d2e6895f11..c1d74426eb72b44f1b9fc320b361c6476a1439f5 100644 (file)
@@ -193,7 +193,18 @@ output_escaped_str(char *str, bool quoted)
                else if (str[i] == '\n')
                        fputs("\\\n", yyout);
                else if (str[i] == '\\')
-                       fputs("\\\\", yyout);
+               {
+                       int j = i;
+                       
+                       /* check whether this is a continuation line 
+                        * if it is, do not output anything because newlines are escaped anyway */
+
+                       /* accept blanks after the '\' as some other compilers do too */
+                       do { j++; } while (str[j] == ' ' || str[j] == '\t');
+
+                       if ((str[j] != '\n') && (str[j] != '\r' || str[j + 1] != '\n')) /* not followed by a newline */
+                               fputs("\\\\", yyout);
+               }
                else if (str[i] == '\r' && str[i + 1] == '\n')
                {
                        fputs("\\\r\n", yyout);