Index: src/interfaces/ecpg/preproc/output.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/ecpg/preproc/output.c,v retrieving revision 1.12 diff -c -c -r1.12 output.c *** src/interfaces/ecpg/preproc/output.c 13 Oct 2004 01:25:13 -0000 1.12 --- src/interfaces/ecpg/preproc/output.c 3 Feb 2006 05:33:38 -0000 *************** *** 2,7 **** --- 2,9 ---- #include "extern.h" + static void ouput_escaped_str(char *cmd); + void output_line_number(void) { *************** *** 10,30 **** } void ! output_simple_statement(char *cmd) { ! int i, ! j = strlen(cmd);; ! ! /* output this char by char as we have to filter '\"' */ ! for (i = 0; i < j; i++) ! { ! if (cmd[i] != '"') ! fputc(cmd[i], yyout); ! else ! fputs("\\\"", yyout); ! } output_line_number(); ! free(cmd); } /* --- 12,22 ---- } void ! output_simple_statement(char *stmt) { ! ouput_escaped_str(stmt); output_line_number(); ! free(stmt); } /* *************** *** 106,125 **** void output_statement(char *stmt, int mode, char *con) { - int i, - j = strlen(stmt); - fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, \"", compat, force_indicator, con ? con : "NULL"); ! ! /* output this char by char as we have to filter '\"' */ ! for (i = 0; i < j; i++) ! { ! if (stmt[i] != '"') ! fputc(stmt[i], yyout); ! else ! fputs("\\\"", yyout); ! } ! fputs("\", ", yyout); /* dump variables to C file */ --- 98,105 ---- void output_statement(char *stmt, int mode, char *con) { fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, \"", compat, force_indicator, con ? con : "NULL"); ! ouput_escaped_str(stmt); fputs("\", ", yyout); /* dump variables to C file */ *************** *** 135,137 **** --- 115,135 ---- if (connection != NULL) free(connection); } + + + static void + ouput_escaped_str(char *str) + { + int i, len = strlen(str); + + /* output this char by char as we have to filter " and \n */ + for (i = 0; i < len; i++) + { + if (str[i] == '"') + fputs("\\\"", yyout); + else if (str[i] == '\n') + fputs("\\n\\\n", yyout); + else + fputc(str[i], yyout); + } + } Index: src/interfaces/ecpg/preproc/pgc.l =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v retrieving revision 1.140 diff -c -c -r1.140 pgc.l *** src/interfaces/ecpg/preproc/pgc.l 2 Feb 2006 03:51:41 -0000 1.140 --- src/interfaces/ecpg/preproc/pgc.l 3 Feb 2006 05:33:38 -0000 *************** *** 152,158 **** dolq_cont [A-Za-z\200-\377_0-9] dolqdelim \$({dolq_start}{dolq_cont}*)?\$ dolqfailed \${dolq_start}{dolq_cont}* ! dolqinside [^$]+ /* Double quote * Allows embedded spaces and other special characters into identifiers. --- 152,158 ---- dolq_cont [A-Za-z\200-\377_0-9] dolqdelim \$({dolq_start}{dolq_cont}*)?\$ dolqfailed \${dolq_start}{dolq_cont}* ! dolqinside [^$']+ /* Double quote * Allows embedded spaces and other special characters into identifiers. *************** *** 476,482 **** {dolqinside} { addlit(yytext, yyleng); } {dolqfailed} { addlit(yytext, yyleng); } . { ! /* This is only needed for $ inside the quoted text */ addlitchar(yytext[0]); } <> { yyerror("unterminated dollar-quoted string"); } --- 476,485 ---- {dolqinside} { addlit(yytext, yyleng); } {dolqfailed} { addlit(yytext, yyleng); } . { ! /* $$ is implemented as a single-quoted string, so double it? */ ! if (yytext[0] == '\'') ! addlitchar(yytext[0]); ! /* single quote or dollar sign */ addlitchar(yytext[0]); } <> { yyerror("unterminated dollar-quoted string"); }