diff options
author | Michael Meskes <meskes@postgresql.org> | 2004-07-20 18:22:53 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2004-07-20 18:22:53 +0000 |
commit | a7d68b42f02b0a422004d8abcb743fa104162868 (patch) | |
tree | f14ca28cd523b05078ac7da2b4ff585bb5b8e027 /src | |
parent | ab50cb14a44657aceed82bf691f3d90874370662 (diff) | |
download | postgresql-a7d68b42f02b0a422004d8abcb743fa104162868.tar.gz postgresql-a7d68b42f02b0a422004d8abcb743fa104162868.zip |
Fixed handling of cyclic defines.
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/ecpg/preproc/ecpg.c | 5 | ||||
-rw-r--r-- | src/interfaces/ecpg/preproc/pgc.l | 31 | ||||
-rw-r--r-- | src/interfaces/ecpg/preproc/type.h | 1 |
3 files changed, 24 insertions, 13 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c index 967dce8f155..e3a1023d7c5 100644 --- a/src/interfaces/ecpg/preproc/ecpg.c +++ b/src/interfaces/ecpg/preproc/ecpg.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.81.2.1 2003/12/18 18:55:06 petere Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.81.2.2 2004/07/20 18:22:53 meskes Exp $ */ /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */ /* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */ @@ -103,9 +103,10 @@ add_preprocessor_define(char *define) else { defines->old = define_copy; - defines->new = mm_strdup(""); + defines->new = mm_strdup("1"); } defines->pertinent = true; + defines->used = NULL; defines->next = pd; } diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index babb2ac0709..c7ec6d69fc9 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.122.2.2 2004/02/15 13:50:02 meskes Exp $ + * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.122.2.3 2004/07/20 18:22:53 meskes Exp $ * *------------------------------------------------------------------------- */ @@ -550,7 +550,7 @@ cppline {space}*#(.*\\{space})+.* /* How about a DEFINE? */ for (ptr = defines; ptr; ptr = ptr->next) { - if (strcmp(yytext, ptr->old) == 0) + if (strcmp(yytext, ptr->old) == 0 && ptr->used == NULL) { struct _yy_buffer *yb; @@ -559,7 +559,7 @@ cppline {space}*#(.*\\{space})+.* yb->buffer = YY_CURRENT_BUFFER; yb->lineno = yylineno; yb->filename = mm_strdup(input_filename); - yb->next = yy_buffer; + ptr->used = yb->next = yy_buffer; yy_buffer = yb; @@ -648,7 +648,7 @@ cppline {space}*#(.*\\{space})+.* /* is it a define? */ for (ptr = defines; ptr; ptr = ptr->next) { - if (strcmp(yytext, ptr->old) == 0) + if (strcmp(yytext, ptr->old) == 0 && ptr->used == NULL) { struct _yy_buffer *yb; @@ -657,7 +657,7 @@ cppline {space}*#(.*\\{space})+.* yb->buffer = YY_CURRENT_BUFFER; yb->lineno = yylineno; yb->filename = mm_strdup(input_filename); - yb->next = yy_buffer; + ptr->used = yb->next = yy_buffer; yy_buffer = yb; @@ -687,7 +687,7 @@ cppline {space}*#(.*\\{space})+.* <C>"-" { return('-'); } <C>"(" { return('('); } <C>")" { return(')'); } -<C>{space} { ECHO; } +<C,xskip>{space} { ECHO; } <C>\{ { return('{'); } <C>\} { return('}'); } <C>\[ { return('['); } @@ -923,12 +923,13 @@ cppline {space}*#(.*\\{space})+.* } if (ptr == NULL) { - this = (struct _defines *) mm_alloc(sizeof(struct _defines)); + this = (struct _defines *) mm_alloc(sizeof(struct _defines)); - /* initial definition */ - this->old = old; - this->new = mm_strdup(literalbuf); + /* initial definition */ + this->old = old; + this->new = mm_strdup(literalbuf); this->next = defines; + this->used = NULL; defines = this; } @@ -953,7 +954,15 @@ cppline {space}*#(.*\\{space})+.* { struct _yy_buffer *yb = yy_buffer; int i; - + struct _defines *ptr; + + for (ptr = defines; ptr; ptr = ptr->next) + if (ptr->used == yy_buffer) + { + ptr->used = NULL; + break; + } + if (yyin != NULL) fclose(yyin); diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h index 4091a562ab4..1d34a7c9ec5 100644 --- a/src/interfaces/ecpg/preproc/type.h +++ b/src/interfaces/ecpg/preproc/type.h @@ -134,6 +134,7 @@ struct _defines char *old; char *new; int pertinent; + void *used; struct _defines *next; }; |