diff options
author | Tom Lane | 2006-05-11 19:15:36 +0000 |
---|---|---|
committer | Tom Lane | 2006-05-11 19:15:36 +0000 |
commit | 637028afe17b9616d279d13d9fc5d6df1ecf369b (patch) | |
tree | 1e95735e0563109cd859edf95e268a5287a97aae /src/interfaces | |
parent | 3fdeb189e977ebe29ee658592d07930e016dd031 (diff) |
Code review for standard_conforming_strings patch. Fix it so it does not
throw warnings for 100%-SQL-standard constructs, clean up some minor
infelicities, try to un-break ecpg to the best of my ability. (It's not clear
how ecpg is going to find out the setting of standard_conforming_strings,
though.) I think pg_dump still needs work, too.
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/ecpg/preproc/pgc.l | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index 67f2517d21f..a835a1da696 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.145 2006/03/06 19:49:20 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.146 2006/05/11 19:15:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -29,8 +29,8 @@ extern YYSTYPE yylval; static int xcdepth = 0; /* depth of nesting in slash-star comments */ static char *dolqstart; /* current $foo$ quote start string */ -bool escape_string_warning; -bool standard_conforming_strings; +static bool escape_string_warning; +static bool standard_conforming_strings; static bool warn_on_first_escape; /* @@ -128,10 +128,10 @@ xnstart [nN]{quote} /* Quoted string that allows backslash escapes */ xestart [eE]{quote} -xeinside [^\\']+ -xeescape [\\][^0-7] -xeoctesc [\\][0-7]{1,3} -xehexesc [\\]x[0-9A-Fa-f]{1,2} +xeinside [^\\']+ +xeescape [\\][^0-7] +xeoctesc [\\][0-7]{1,3} +xehexesc [\\]x[0-9A-Fa-f]{1,2} /* C version of hex number */ xch 0[xX][0-9A-Fa-f]* @@ -141,8 +141,7 @@ xch 0[xX][0-9A-Fa-f]* */ xqstart {quote} xqdouble {quote}{quote} -xqinside [^\\']+ -xqbackslash [\\] +xqinside [^']+ /* $foo$ style quotes ("dollar quoting") * The quoted string starts with $foo$ where "foo" is an optional string @@ -402,11 +401,23 @@ cppline {space}*#(.*\\{space})*.*{newline} /* National character. * Transfer it as-is to the backend. */ + warn_on_first_escape = true; token_start = yytext; - BEGIN(xq); + state_before = YYSTATE; + if (standard_conforming_strings) + BEGIN(xq); + else + BEGIN(xe); + startlit(); + } +<C>{xqstart} { + warn_on_first_escape = false; + token_start = yytext; + state_before = YYSTATE; + BEGIN(xe); startlit(); } -<C,SQL>{xqstart} { +<SQL>{xqstart} { warn_on_first_escape = true; token_start = yytext; state_before = YYSTATE; @@ -416,7 +427,7 @@ cppline {space}*#(.*\\{space})*.*{newline} BEGIN(xe); startlit(); } -<C,SQL>{xestart} { +<SQL>{xestart} { warn_on_first_escape = false; token_start = yytext; state_before = YYSTATE; @@ -433,10 +444,6 @@ cppline {space}*#(.*\\{space})*.*{newline} <xq,xe>{xqdouble} { addlitchar('\''); } <xq>{xqinside} { addlit(yytext, yyleng); } <xe>{xeinside} { addlit(yytext, yyleng); } -<xq>{xqbackslash} { - check_escape_warning(); - addlitchar('\\'); - } <xe>{xeescape} { check_escape_warning(); addlit(yytext, yyleng); |