Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fa96a5e

Browse files
committed
Add %option nodefault to all our flex lexers. Fix a couple of rule gaps
exposed thereby. AFAICT these would not lead to any worse problems than junk emitted on the backend's stdout, but we should have the option to catch possible worse errors in future.
1 parent 58e7053 commit fa96a5e

File tree

8 files changed

+16
-7
lines changed

8 files changed

+16
-7
lines changed

contrib/cube/cubescan.l

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void cube_scanner_finish(void);
2626

2727
%option 8bit
2828
%option never-interactive
29+
%option nodefault
2930
%option nounput
3031
%option noyywrap
3132
%option prefix="cube_yy"
@@ -44,7 +45,7 @@ float ({integer}|{real})([eE]{integer})?
4445
\( yylval = "("; return O_PAREN;
4546
\) yylval = ")"; return C_PAREN;
4647
\, yylval = ")"; return COMMA;
47-
[ ]+ /* discard spaces */
48+
[ \t\n\r\f]+ /* discard spaces */
4849
. return yytext[0]; /* alert parser of the garbage */
4950

5051
%%

contrib/seg/segscan.l

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ void seg_scanner_finish(void);
2525

2626
%option 8bit
2727
%option never-interactive
28+
%option nodefault
2829
%option nounput
2930
%option noyywrap
3031
%option prefix="seg_yy"
@@ -44,7 +45,7 @@ float ({integer}|{real})([eE]{integer})?
4445
\< yylval.text = "<"; return EXTENSION;
4546
\> yylval.text = ">"; return EXTENSION;
4647
\~ yylval.text = "~"; return EXTENSION;
47-
[ ]+ /* discard spaces */
48+
[ \t\n\r\f]+ /* discard spaces */
4849
. return yytext[0]; /* alert parser of the garbage */
4950

5051
%%

contrib/tsearch/parser.l

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ YY_BUFFER_STATE buf = NULL; /* buffer to parse; it need for parse from string */
1616

1717
%option 8bit
1818
%option never-interactive
19+
%option nodefault
1920
%option nounput
2021
%option noyywrap
2122

contrib/tsearch2/wordparser/parser.l

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ YY_BUFFER_STATE buf = NULL; /* buffer to parse; it need for parse from string */
1818

1919
%option 8bit
2020
%option never-interactive
21+
%option nodefault
2122
%option nounput
2223
%option noyywrap
2324

src/backend/bootstrap/bootscanner.l

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.32 2003/11/29 19:51:41 pgsql Exp $
12+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.33 2004/02/24 22:06:32 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -53,6 +53,7 @@ static int yyline; /* keep track of the line number for error reporting */
5353

5454
%option 8bit
5555
%option never-interactive
56+
%option nodefault
5657
%option nounput
5758
%option noyywrap
5859

src/backend/utils/misc/guc-file.l

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.20 2003/11/29 19:52:03 pgsql Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.21 2004/02/24 22:06:32 tgl Exp $
88
*/
99

1010
%{
@@ -47,6 +47,7 @@ char *GUC_scanstr(char *);
4747

4848
%option 8bit
4949
%option never-interactive
50+
%option nodefault
5051
%option nounput
5152
%option noyywrap
5253

src/interfaces/ecpg/preproc/pgc.l

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.125 2004/02/15 13:48:54 meskes Exp $
15+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.126 2004/02/24 22:06:32 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -70,6 +70,7 @@ static struct _if_value
7070

7171
%option 8bit
7272
%option never-interactive
73+
%option nodefault
7374
%option noyywrap
7475

7576
%option yylineno

src/pl/plpgsql/src/scan.l

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.30 2003/11/29 19:52:12 pgsql Exp $
7+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.31 2004/02/24 22:06:32 tgl Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -63,6 +63,7 @@ int plpgsql_SpaceScanned = 0;
6363

6464
%option 8bit
6565
%option never-interactive
66+
%option nodefault
6667
%option nounput
6768
%option noyywrap
6869

@@ -272,20 +273,21 @@ dump { return O_DUMP; }
272273
BEGIN IN_STRING;
273274
}
274275
<IN_STRING>\\. { }
276+
<IN_STRING>\\ { /* can only happen with \ at EOF */ }
275277
<IN_STRING>'' { }
276278
<IN_STRING>' {
277279
yyleng -= (yytext - start_charpos);
278280
yytext = start_charpos;
279281
BEGIN INITIAL;
280282
return T_STRING;
281283
}
284+
<IN_STRING>[^'\\]+ { }
282285
<IN_STRING><<EOF>> {
283286
plpgsql_error_lineno = start_lineno;
284287
ereport(ERROR,
285288
(errcode(ERRCODE_DATATYPE_MISMATCH),
286289
errmsg("unterminated string")));
287290
}
288-
<IN_STRING>[^'\\]* { }
289291

290292
/* ----------
291293
* Any unmatched character is returned as is

0 commit comments

Comments
 (0)