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
This commit is contained in:
parent
3cbe6b2478
commit
811f7df274
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user