diff options
author | Michael Meskes <meskes@postgresql.org> | 2008-03-20 15:56:59 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2008-03-20 15:56:59 +0000 |
commit | 15364ea09dc7005202d11d41ac56e69665a12a98 (patch) | |
tree | 797dde1b469eaa48c09caba773480d224e0ba215 /src | |
parent | f4b7624eb07a0bf1f95df2927562c76c5dfdc5f7 (diff) | |
download | postgresql-15364ea09dc7005202d11d41ac56e69665a12a98.tar.gz postgresql-15364ea09dc7005202d11d41ac56e69665a12a98.zip |
Changed statement escaping to not escape continuation line markers.
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/ecpg/ChangeLog | 5 | ||||
-rw-r--r-- | src/interfaces/ecpg/preproc/output.c | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog index 613a3096886..2147d28efcb 100644 --- a/src/interfaces/ecpg/ChangeLog +++ b/src/interfaces/ecpg/ChangeLog @@ -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. + diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c index 74da49a0d20..e12308d666f 100644 --- a/src/interfaces/ecpg/preproc/output.c +++ b/src/interfaces/ecpg/preproc/output.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/output.c,v 1.23 2007/11/15 21:14:45 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/output.c,v 1.24 2008/03/20 15:56:59 meskes Exp $ */ #include "postgres_fe.h" @@ -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); |