12
12
*
13
13
*
14
14
* 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 $
16
16
*
17
17
*-------------------------------------------------------------------------
18
18
*/
@@ -29,7 +29,6 @@ extern YYSTYPE yylval;
29
29
static int xcdepth =0 ;/* depth of nesting in slash-star comments*/
30
30
static char *dolqstart;/* current $foo$ quote start string*/
31
31
static bool escape_string_warning;
32
- static bool warn_on_first_escape;
33
32
static YY_BUFFER_STATE scanbufhandle;
34
33
static char *scanbuf;
35
34
@@ -47,7 +46,6 @@ static intliteralalloc;/* current allocated buffer size */
47
46
static void addlit (char *ytext,int yleng);
48
47
static void addlitchar (unsigned char );
49
48
static void parse_include (void );
50
- static void check_escape_warning (void );
51
49
static bool ecpg_isspace (char ch);
52
50
static bool isdefine (void );
53
51
static bool isinformixdefine (void );
@@ -101,6 +99,7 @@ static struct _if_value
101
99
*<xd> delimited identifiers (double-quoted identifiers) - thomas 1997-10-27
102
100
*<xh> hexadecimal numeric string - thomas 1997-11-16
103
101
*<xq> standard quoted strings - thomas 1997-07-30
102
+ *<xqc> standard quoted strings in C - michael
104
103
*<xe> extended quoted strings (support backslash escape sequences)
105
104
*<xn> national character quoted strings
106
105
* <xdolq> $foo$ quoted strings
@@ -114,6 +113,7 @@ static struct _if_value
114
113
%x xe
115
114
%x xn
116
115
%x xq
116
+ %x xqc
117
117
%x xdolq
118
118
%x xcond
119
119
%x xskip
@@ -145,6 +145,7 @@ xch0[xX][0-9A-Fa-f]*
145
145
*/
146
146
xqstart {quote }
147
147
xqdouble {quote }{quote }
148
+ xqcquote [\\ ]{quote }
148
149
xqinside [^ ' ]+
149
150
150
151
/* $foo$ style quotes ("dollar quoting")
@@ -409,35 +410,31 @@ cppline{space}*#(.*\\{space})*.*{newline}
409
410
/* National character.
410
411
* Transfer it as-is to the backend.
411
412
*/
412
- warn_on_first_escape =true ;
413
- token_start = yytext;
413
+ token_start = yytext;
414
414
state_before = YYSTATE;
415
415
BEGIN (xn);
416
416
startlit ();
417
417
}
418
418
<C >{xqstart }{
419
- warn_on_first_escape =false ;
420
419
token_start = yytext;
421
420
state_before = YYSTATE;
422
- BEGIN (xq );
421
+ BEGIN (xqc );
423
422
startlit ();
424
423
}
425
424
<SQL >{xqstart }{
426
- warn_on_first_escape =true ;
427
425
token_start = yytext;
428
426
state_before = YYSTATE;
429
427
BEGIN (xq);
430
428
startlit ();
431
429
}
432
430
<SQL >{xestart }{
433
- warn_on_first_escape =false ;
434
431
token_start = yytext;
435
432
state_before = YYSTATE;
436
433
BEGIN (xe);
437
434
startlit ();
438
435
}
439
- <xq >{quotestop } |
440
- <xq >{quotefail } {
436
+ <xq , xqc >{quotestop } |
437
+ <xq , xqc >{quotefail } {
441
438
yyless (1 );
442
439
BEGIN (state_before);
443
440
yylval.str =mm_strdup (literalbuf);
@@ -457,27 +454,22 @@ cppline{space}*#(.*\\{space})*.*{newline}
457
454
yylval.str =mm_strdup (literalbuf);
458
455
return NCONST;
459
456
}
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 (' \' ' );
466
461
}
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 */ }
476
468
<xe >. {
477
469
/* This is only needed for \ just before EOF */
478
470
addlitchar (yytext[0 ]);
479
471
}
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" ); }
481
473
<SQL >{dolqfailed }{
482
474
/* throw back all but the initial "$" */
483
475
yyless (1 );
@@ -1284,14 +1276,6 @@ parse_include(void)
1284
1276
BEGIN (C);
1285
1277
}
1286
1278
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
-
1295
1279
/*
1296
1280
* ecpg_isspace() --- return TRUE if flex scanner considers char whitespace
1297
1281
*/