Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf9b2f9b

Browse files
committed
Fix plpgsql lexer to accept Windows-style and Mac-style newlines as
newlines.
1 parent84d0865 commitf9b2f9b

File tree

1 file changed

+44
-27
lines changed

1 file changed

+44
-27
lines changed

‎src/pl/plpgsql/src/scan.l

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.4 2000/06/20 16:40:10 petere Exp $
7+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.5 2000/08/22 14:59:28 tgl Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -40,11 +40,13 @@ static char*plpgsql_source;
4040
staticintplpgsql_bytes_left;
4141
staticintscanner_functype;
4242
staticintscanner_typereported;
43+
4344
intplpgsql_SpaceScanned =0;
4445

4546
externint yylineno;
4647

4748
staticvoidplpgsql_input(char *buf,int *result,int max);
49+
4850
#defineYY_INPUT(buf,res,max)plpgsql_input(buf, &res, max)
4951
#defineYY_NO_UNPUT
5052
%}
@@ -74,37 +76,38 @@ WC[[:alnum:]_"]
7476
* functions type (T_FUNCTION or T_TRIGGER)
7577
* ----------
7678
*/
77-
if (!scanner_typereported) {
78-
scanner_typereported =1;
79-
return scanner_functype;
80-
}
79+
if (!scanner_typereported)
80+
{
81+
scanner_typereported =1;
82+
return scanner_functype;
83+
}
8184

8285
/* ----------
8386
* The keyword rules
8487
* ----------
8588
*/
86-
:={return K_ASSIGN;}
87-
={return K_ASSIGN;}
89+
:={return K_ASSIGN;}
90+
={return K_ASSIGN;}
8891
\.\.{return K_DOTDOT;}
8992
alias{return K_ALIAS;}
9093
begin{return K_BEGIN;}
9194
bpchar{return T_BPCHAR;}
9295
char{return T_CHAR;}
93-
constant{return K_CONSTANT;}
96+
constant{return K_CONSTANT;}
9497
debug{return K_DEBUG;}
9598
declare{return K_DECLARE;}
9699
default{return K_DEFAULT;}
97100
else{return K_ELSE;}
98-
end{return K_END;}
99-
exception{return K_EXCEPTION;}
101+
end{return K_END;}
102+
exception{return K_EXCEPTION;}
100103
exit{return K_EXIT;}
101-
for{return K_FOR;}
104+
for{return K_FOR;}
102105
from{return K_FROM;}
103-
if{return K_IF;}
104-
in{return K_IN;}
106+
if{return K_IF;}
107+
in{return K_IN;}
105108
into{return K_INTO;}
106109
loop{return K_LOOP;}
107-
not{return K_NOT;}
110+
not{return K_NOT;}
108111
notice{return K_NOTICE;}
109112
null{return K_NULL;}
110113
perform{return K_PERFORM;}
@@ -115,7 +118,7 @@ return{ return K_RETURN;}
115118
reverse{return K_REVERSE;}
116119
select{return K_SELECT;}
117120
then{return K_THEN;}
118-
to{return K_TO;}
121+
to{return K_TO;}
119122
type{return K_TYPE;}
120123
varchar{return T_VARCHAR;}
121124
when{return K_WHEN;}
@@ -143,13 +146,13 @@ dump{ return O_DUMP;}
143146
* Ignore whitespaces but remember this happened
144147
* ----------
145148
*/
146-
[\t\n]+{ plpgsql_SpaceScanned =1;}
149+
[\t\r\n]+{ plpgsql_SpaceScanned =1;}
147150

148151
/* ----------
149152
* Eat up comments
150153
* ----------
151154
*/
152-
--[^\n]*;
155+
--[^\r\n]*;
153156
\/\*{ start_lineno = yylineno;
154157
BEGIN IN_COMMENT;
155158
}
@@ -188,22 +191,25 @@ dump{ return O_DUMP;}
188191

189192
%%
190193

191-
intyywrap()
194+
int
195+
yywrap()
192196
{
193197
return1;
194198
}
195199

196200

197-
staticvoidplpgsql_input(char *buf,int *result,int max)
201+
staticvoid
202+
plpgsql_input(char *buf,int *result,int max)
198203
{
199-
int n = max;
200-
if (n > plpgsql_bytes_left) {
204+
intn = max;
205+
206+
if (n > plpgsql_bytes_left)
201207
n = plpgsql_bytes_left;
202-
}
203208

204-
if (n ==0) {
209+
if (n ==0)
210+
{
205211
*result = YY_NULL;
206-
return;
212+
return;
207213
}
208214

209215
*result = n;
@@ -213,18 +219,29 @@ static void plpgsql_input(char *buf, int *result, int max)
213219
}
214220

215221

216-
voidplpgsql_setinput(char *source,int functype)
222+
void
223+
plpgsql_setinput(char *source,int functype)
217224
{
218225
yyrestart(NULL);
219226
yylineno =1;
220227

221228
plpgsql_source = source;
229+
230+
/*----------
231+
* Hack: skip any initial newline, so that in the common coding layout
232+
*CREATE FUNCTION ... AS '
233+
*code body
234+
*' LANGUAGE 'plpgsql';
235+
* we will think "line 1" is what the programmer thinks of as line 1.
236+
*----------
237+
*/
238+
if (*plpgsql_source =='\r')
239+
plpgsql_source++;
222240
if (*plpgsql_source =='\n')
223241
plpgsql_source++;
242+
224243
plpgsql_bytes_left =strlen(plpgsql_source);
225244

226245
scanner_functype = functype;
227246
scanner_typereported =0;
228247
}
229-
230-

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp