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

Commit 74a09d9

Browse files
committed
Fix bugs in the isolation tester flex rules.
Tom Lane pointed out that it was giving a warning: "-s option given but default rule can be matched". That was because there was no rule to handle newline in a quoted string. I made that throw an error. Also, line number tracking was broken, giving incorrect line number on error. Fixed that too.
1 parent 2d8de0a commit 74a09d9

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/test/isolation/specscanner.l

+17-9
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ static void addlitchar(const char c);
3232
%x qstr
3333

3434
non_newline [^\n\r]
35-
space [ \t\n\r\f]
35+
space [ \t\r\f]
3636

3737
comment ("#"{non_newline}*)
38-
whitespace ({space}+|{comment})
3938

4039
%%
4140

@@ -46,10 +45,10 @@ step { return(STEP); }
4645
teardown { return(TEARDOWN); }
4746

4847
[\n] { yyline++; }
49-
{whitespace} {
50-
/* ignore */
51-
}
48+
{comment} { /* ignore */ }
49+
{space} { /* ignore */ }
5250

51+
/* Quoted strings: "foo" */
5352
\" {
5453
litbufpos = 0;
5554
BEGIN(qstr);
@@ -61,27 +60,36 @@ teardown { return(TEARDOWN); }
6160
return(string);
6261
}
6362
<qstr>. { addlitchar(yytext[0]); }
63+
<qstr>\n { yyerror("unexpected newline in quoted string"); }
64+
<qstr><<EOF>> { yyerror("unterminated quoted string"); }
6465

66+
/* SQL blocks: { UPDATE ... } */
6567
"{" {
6668

6769
litbufpos = 0;
6870
BEGIN(sql);
6971
}
70-
7172
<sql>"}" {
7273
litbuf[litbufpos] = '\0';
7374
yylval.str = strdup(litbuf);
7475
BEGIN(INITIAL);
7576
return(sqlblock);
7677
}
77-
<sql>[^}] { addlitchar(yytext[0]);}
78-
78+
<sql>. {
79+
addlitchar(yytext[0]);
80+
}
81+
<sql>\n {
82+
yyline++;
83+
addlitchar(yytext[0]);
84+
}
85+
<sql><<EOF>> {
86+
yyerror("unterminated sql block");
87+
}
7988

8089
. {
8190
fprintf(stderr, "syntax error at line %d: unexpected character \"%s\"\n", yyline, yytext);
8291
exit(1);
8392
}
84-
8593
%%
8694

8795
static void

0 commit comments

Comments
 (0)