aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-04-05 11:39:47 +0000
committerBruce Momjian <bruce@momjian.us>2002-04-05 11:39:47 +0000
commit811f7df27454577d723e7f59dd840b09c5286913 (patch)
tree8e9efaa58e40263ff5087ad12812eb0bb154325d /src
parent3cbe6b2478d7a321e203857f255bcaf69bcc5c8d (diff)
downloadpostgresql-811f7df27454577d723e7f59dd840b09c5286913.tar.gz
postgresql-811f7df27454577d723e7f59dd840b09c5286913.zip
When a macro is replaced by the preprocessor, pgc.l reaches a end of
file, which is not the actual end of the file. One side effect of that is that if you are i n a ifdef block, you get a wrong error telling you that a endif is missing. This patch corrects pgc.l and also adds a test of this problem to test1.pgc. To convince you apply the patch to test1.pgc first then try to compile the test the n apply the patch to pgc.l. The patch moves the test of the scope of an ifdef block to the end of the file b eeing parsed, including all includes files, ... . Nicolas Bazin
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/ecpg/preproc/pgc.l6
-rw-r--r--src/interfaces/ecpg/test/test1.pgc15
2 files changed, 12 insertions, 9 deletions
diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l
index 5341d093018..27ba1c9375a 100644
--- a/src/interfaces/ecpg/preproc/pgc.l
+++ b/src/interfaces/ecpg/preproc/pgc.l
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.89 2002/03/24 18:22:21 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.90 2002/04/05 11:39:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -837,14 +837,14 @@ cppline {space}*#(.*\\{space})*.*
}
<<EOF>> {
+ if (yy_buffer == NULL) {
if ( preproc_tos > 0 )
{
preproc_tos = 0;
mmerror(PARSE_ERROR, ET_FATAL, "Missing 'EXEC SQL ENDIF;'");
}
-
- if (yy_buffer == NULL)
yyterminate();
+ }
else
{
struct _yy_buffer *yb = yy_buffer;
diff --git a/src/interfaces/ecpg/test/test1.pgc b/src/interfaces/ecpg/test/test1.pgc
index 0c23f240f60..8eb27c3a278 100644
--- a/src/interfaces/ecpg/test/test1.pgc
+++ b/src/interfaces/ecpg/test/test1.pgc
@@ -17,9 +17,9 @@ static void warn(void)
/* comment */
exec sql define AMOUNT 6;
+exec sql define NAMELEN 8;
exec sql type intarray is int[AMOUNT];
-exec sql type string is char(8);
typedef int intarray[AMOUNT];
@@ -27,16 +27,19 @@ int
main ()
{
exec sql begin declare section;
+exec sql ifdef NAMELEN;
+ typedef char string[NAMELEN];
intarray amount;
int increment=100;
- char name[AMOUNT][8];
+ char name[AMOUNT][NAMELEN];
char letter[AMOUNT][1];
struct name_letter_struct
{
- char name[8];
+ char name[NAMELEN];
int amount;
char letter;
} name_letter[AMOUNT];
+exec sql endif;
struct ind_struct
{
short a;
@@ -62,8 +65,8 @@ exec sql end declare section;
exec sql connect to pm;
strcpy(msg, "create");
- exec sql at main create table "Test" (name char(8), amount int, letter char(1));
- exec sql create table "Test" (name char(8), amount int, letter char(1));
+ exec sql at main create table "Test" (name char(NAMELEN), amount int, letter char(1));
+ exec sql create table "Test" (name char(NAMELEN), amount int, letter char(1));
strcpy(msg, "commit");
exec sql at main commit;
@@ -115,7 +118,7 @@ exec sql end declare section;
int a = amount[i];
exec sql end declare section;
- strncpy(n, name[i], 8);
+ strncpy(n, name[i], NAMELEN);
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
amount[i]+=1000;