1212 *
1313 *
1414 * IDENTIFICATION
15- * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.157 2008/01/01 19:45:59 momjian Exp $
15+ * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.158 2008/01/11 15: 19:16 meskes Exp $
1616 *
1717 *-------------------------------------------------------------------------
1818*/
@@ -29,7 +29,6 @@ extern YYSTYPE yylval;
2929static int xcdepth =0 ;/* depth of nesting in slash-star comments*/
3030static char *dolqstart;/* current $foo$ quote start string*/
3131static bool escape_string_warning;
32- static bool warn_on_first_escape;
3332static YY_BUFFER_STATE scanbufhandle;
3433static char *scanbuf;
3534
@@ -47,7 +46,6 @@ static intliteralalloc;/* current allocated buffer size */
4746static void addlit (char *ytext,int yleng);
4847static void addlitchar (unsigned char );
4948static void parse_include (void );
50- static void check_escape_warning (void );
5149static bool ecpg_isspace (char ch);
5250static bool isdefine (void );
5351static bool isinformixdefine (void );
@@ -101,6 +99,7 @@ static struct _if_value
10199 *<xd> delimited identifiers (double-quoted identifiers) - thomas 1997-10-27
102100 *<xh> hexadecimal numeric string - thomas 1997-11-16
103101 *<xq> standard quoted strings - thomas 1997-07-30
102+ *<xqc> standard quoted strings in C - michael
104103 *<xe> extended quoted strings (support backslash escape sequences)
105104 *<xn> national character quoted strings
106105 * <xdolq> $foo$ quoted strings
@@ -114,6 +113,7 @@ static struct _if_value
114113%x xe
115114%x xn
116115%x xq
116+ %x xqc
117117%x xdolq
118118%x xcond
119119%x xskip
@@ -145,6 +145,7 @@ xch0[xX][0-9A-Fa-f]*
145145 */
146146xqstart {quote }
147147xqdouble {quote }{quote }
148+ xqcquote [\\ ]{quote }
148149xqinside [^ ' ]+
149150
150151/* $foo$ style quotes ("dollar quoting")
@@ -409,35 +410,31 @@ cppline{space}*#(.*\\{space})*.*{newline}
409410/* National character.
410411 * Transfer it as-is to the backend.
411412 */
412- warn_on_first_escape =true ;
413- token_start = yytext;
413+ token_start = yytext;
414414state_before = YYSTATE;
415415BEGIN (xn);
416416startlit ();
417417}
418418<C >{xqstart }{
419- warn_on_first_escape =false ;
420419token_start = yytext;
421420state_before = YYSTATE;
422- BEGIN (xq );
421+ BEGIN (xqc );
423422startlit ();
424423}
425424<SQL >{xqstart }{
426- warn_on_first_escape =true ;
427425token_start = yytext;
428426state_before = YYSTATE;
429427BEGIN (xq);
430428startlit ();
431429}
432430<SQL >{xestart }{
433- warn_on_first_escape =false ;
434431token_start = yytext;
435432state_before = YYSTATE;
436433BEGIN (xe);
437434startlit ();
438435}
439- <xq >{quotestop } |
440- <xq >{quotefail } {
436+ <xq , xqc >{quotestop } |
437+ <xq , xqc >{quotefail } {
441438yyless (1 );
442439BEGIN (state_before);
443440yylval.str =mm_strdup (literalbuf);
@@ -457,27 +454,22 @@ cppline{space}*#(.*\\{space})*.*{newline}
457454yylval.str =mm_strdup (literalbuf);
458455return NCONST;
459456}
460- <xq ,xe ,xn >{xqdouble }{addlitchar (' \' ' ); }
461- <xq ,xn >{xqinside }{addlit (yytext, yyleng); }
462- <xe >{xeinside }{addlit (yytext, yyleng); }
463- <xe >{xeescape } {
464- check_escape_warning ();
465- addlit (yytext, yyleng);
457+ <xq ,xe ,xn >{xqdouble }{addlitchar (' \' ' ); }
458+ <xqc >{xqcquote }{
459+ addlitchar (' \\ ' );
460+ addlitchar (' \' ' );
466461}
467- <xe >{xeoctesc }{
468- check_escape_warning ();
469- addlit (yytext, yyleng);
470- }
471- <xe >{xehexesc }{
472- check_escape_warning ();
473- addlit (yytext, yyleng);
474- }
475- <xq ,xe ,xn >{quotecontinue }{/* ignore */ }
462+ <xq ,xqc ,xn >{xqinside }{addlit (yytext, yyleng); }
463+ <xe >{xeinside }{addlit (yytext, yyleng); }
464+ <xe >{xeescape } {addlit (yytext, yyleng); }
465+ <xe >{xeoctesc }{addlit (yytext, yyleng); }
466+ <xe >{xehexesc }{addlit (yytext, yyleng); }
467+ <xq ,xqc ,xe ,xn >{quotecontinue }{/* ignore */ }
476468<xe >. {
477469/* This is only needed for \ just before EOF */
478470addlitchar (yytext[0 ]);
479471}
480- <xq ,xe ,xn ><<EOF>> {mmerror (PARSE_ERROR, ET_FATAL," Unterminated quoted string" ); }
472+ <xq ,xqc , xe ,xn ><<EOF>> {mmerror (PARSE_ERROR, ET_FATAL," Unterminated quoted string" ); }
481473<SQL >{dolqfailed }{
482474/* throw back all but the initial "$" */
483475yyless (1 );
@@ -1284,14 +1276,6 @@ parse_include(void)
12841276BEGIN (C);
12851277}
12861278
1287- static void
1288- check_escape_warning (void )
1289- {
1290- if (warn_on_first_escape && escape_string_warning)
1291- mmerror (PARSE_ERROR, ET_WARNING," nonstandard use of escape in a string literal" );
1292- warn_on_first_escape =false ;/* warn only once per string */
1293- }
1294-
12951279/*
12961280 * ecpg_isspace() --- return TRUE if flex scanner considers char whitespace
12971281 */