mirror of
https://github.com/postgres/postgres.git
synced 2025-05-22 00:02:02 -04:00
Fix plpgsql lexer to accept Windows-style and Mac-style newlines as
newlines.
This commit is contained in:
parent
84d0865d03
commit
f9b2f9bb76
@ -4,7 +4,7 @@
|
|||||||
* procedural language
|
* procedural language
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.4 2000/06/20 16:40:10 petere Exp $
|
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.5 2000/08/22 14:59:28 tgl Exp $
|
||||||
*
|
*
|
||||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||||
*
|
*
|
||||||
@ -40,11 +40,13 @@ static char *plpgsql_source;
|
|||||||
static int plpgsql_bytes_left;
|
static int plpgsql_bytes_left;
|
||||||
static int scanner_functype;
|
static int scanner_functype;
|
||||||
static int scanner_typereported;
|
static int scanner_typereported;
|
||||||
|
|
||||||
int plpgsql_SpaceScanned = 0;
|
int plpgsql_SpaceScanned = 0;
|
||||||
|
|
||||||
extern int yylineno;
|
extern int yylineno;
|
||||||
|
|
||||||
static void plpgsql_input(char *buf, int *result, int max);
|
static void plpgsql_input(char *buf, int *result, int max);
|
||||||
|
|
||||||
#define YY_INPUT(buf,res,max) plpgsql_input(buf, &res, max)
|
#define YY_INPUT(buf,res,max) plpgsql_input(buf, &res, max)
|
||||||
#define YY_NO_UNPUT
|
#define YY_NO_UNPUT
|
||||||
%}
|
%}
|
||||||
@ -74,7 +76,8 @@ WC [[:alnum:]_"]
|
|||||||
* functions type (T_FUNCTION or T_TRIGGER)
|
* functions type (T_FUNCTION or T_TRIGGER)
|
||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
if (!scanner_typereported) {
|
if (!scanner_typereported)
|
||||||
|
{
|
||||||
scanner_typereported = 1;
|
scanner_typereported = 1;
|
||||||
return scanner_functype;
|
return scanner_functype;
|
||||||
}
|
}
|
||||||
@ -143,13 +146,13 @@ dump { return O_DUMP; }
|
|||||||
* Ignore whitespaces but remember this happened
|
* Ignore whitespaces but remember this happened
|
||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
[ \t\n]+ { plpgsql_SpaceScanned = 1; }
|
[ \t\r\n]+ { plpgsql_SpaceScanned = 1; }
|
||||||
|
|
||||||
/* ----------
|
/* ----------
|
||||||
* Eat up comments
|
* Eat up comments
|
||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
--[^\n]* ;
|
--[^\r\n]* ;
|
||||||
\/\* { start_lineno = yylineno;
|
\/\* { start_lineno = yylineno;
|
||||||
BEGIN IN_COMMENT;
|
BEGIN IN_COMMENT;
|
||||||
}
|
}
|
||||||
@ -188,20 +191,23 @@ dump { return O_DUMP; }
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
int yywrap()
|
int
|
||||||
|
yywrap()
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void plpgsql_input(char *buf, int *result, int max)
|
static void
|
||||||
|
plpgsql_input(char *buf, int *result, int max)
|
||||||
{
|
{
|
||||||
int n = max;
|
int n = max;
|
||||||
if (n > plpgsql_bytes_left) {
|
|
||||||
n = plpgsql_bytes_left;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n == 0) {
|
if (n > plpgsql_bytes_left)
|
||||||
|
n = plpgsql_bytes_left;
|
||||||
|
|
||||||
|
if (n == 0)
|
||||||
|
{
|
||||||
*result = YY_NULL;
|
*result = YY_NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -213,18 +219,29 @@ static void plpgsql_input(char *buf, int *result, int max)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void plpgsql_setinput(char *source, int functype)
|
void
|
||||||
|
plpgsql_setinput(char *source, int functype)
|
||||||
{
|
{
|
||||||
yyrestart(NULL);
|
yyrestart(NULL);
|
||||||
yylineno = 1;
|
yylineno = 1;
|
||||||
|
|
||||||
plpgsql_source = source;
|
plpgsql_source = source;
|
||||||
|
|
||||||
|
/*----------
|
||||||
|
* Hack: skip any initial newline, so that in the common coding layout
|
||||||
|
* CREATE FUNCTION ... AS '
|
||||||
|
* code body
|
||||||
|
* ' LANGUAGE 'plpgsql';
|
||||||
|
* we will think "line 1" is what the programmer thinks of as line 1.
|
||||||
|
*----------
|
||||||
|
*/
|
||||||
|
if (*plpgsql_source == '\r')
|
||||||
|
plpgsql_source++;
|
||||||
if (*plpgsql_source == '\n')
|
if (*plpgsql_source == '\n')
|
||||||
plpgsql_source++;
|
plpgsql_source++;
|
||||||
|
|
||||||
plpgsql_bytes_left = strlen(plpgsql_source);
|
plpgsql_bytes_left = strlen(plpgsql_source);
|
||||||
|
|
||||||
scanner_functype = functype;
|
scanner_functype = functype;
|
||||||
scanner_typereported = 0;
|
scanner_typereported = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user