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

Commit811f7df

Browse files
committed
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 thatis that if you are i n a ifdef block, you get a wrong error telling youthat a endif is missing.This patch corrects pgc.l and also adds a test of this problem totest1.pgc. To convince you apply the patch to test1.pgc first then tryto 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 ofthe file b eeing parsed, including all includes files, ... .Nicolas Bazin
1 parent3cbe6b2 commit811f7df

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

‎src/interfaces/ecpg/preproc/pgc.l

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.89 2002/03/24 18:22:21 tgl Exp $
15+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.90 2002/04/05 11:39:45 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -837,14 +837,14 @@ cppline{space}*#(.*\\{space})*.*
837837
}
838838

839839
<<EOF>>{
840+
if (yy_buffer ==NULL) {
840841
if ( preproc_tos >0 )
841842
{
842843
preproc_tos =0;
843844
mmerror(PARSE_ERROR, ET_FATAL,"Missing 'EXEC SQL ENDIF;'");
844845
}
845-
846-
if (yy_buffer ==NULL)
847846
yyterminate();
847+
}
848848
else
849849
{
850850
struct_yy_buffer *yb = yy_buffer;

‎src/interfaces/ecpg/test/test1.pgc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,29 @@ static void warn(void)
1717

1818
/* comment */
1919
exec sql define AMOUNT 6;
20+
exec sql define NAMELEN 8;
2021

2122
exec sql type intarray is int[AMOUNT];
22-
exec sql type string is char(8);
2323

2424
typedef int intarray[AMOUNT];
2525

2626
int
2727
main ()
2828
{
2929
exec sql begin declare section;
30+
exec sql ifdef NAMELEN;
31+
typedef char string[NAMELEN];
3032
intarray amount;
3133
int increment=100;
32-
char name[AMOUNT][8];
34+
char name[AMOUNT][NAMELEN];
3335
char letter[AMOUNT][1];
3436
struct name_letter_struct
3537
{
36-
char name[8];
38+
char name[NAMELEN];
3739
int amount;
3840
char letter;
3941
} name_letter[AMOUNT];
42+
exec sql endif;
4043
struct ind_struct
4144
{
4245
short a;
@@ -62,8 +65,8 @@ exec sql end declare section;
6265
exec sql connect to pm;
6366

6467
strcpy(msg, "create");
65-
exec sql at main create table "Test" (name char(8), amount int, letter char(1));
66-
exec sql create table "Test" (name char(8), amount int, letter char(1));
68+
exec sql at main create table "Test" (name char(NAMELEN), amount int, letter char(1));
69+
exec sql create table "Test" (name char(NAMELEN), amount int, letter char(1));
6770

6871
strcpy(msg, "commit");
6972
exec sql at main commit;
@@ -115,7 +118,7 @@ exec sql end declare section;
115118
int a = amount[i];
116119
exec sql end declare section;
117120

118-
strncpy(n, name[i],8);
121+
strncpy(n, name[i],NAMELEN);
119122
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
120123
amount[i]+=1000;
121124

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp