1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-18 17:41:14 +03:00

Fixed handling of cyclic defines.

This commit is contained in:
Michael Meskes 2004-07-20 18:22:53 +00:00
parent ab50cb14a4
commit a7d68b42f0
3 changed files with 23 additions and 12 deletions

View File

@ -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;
}

View File

@ -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,6 +954,14 @@ 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);

View File

@ -134,6 +134,7 @@ struct _defines
char *old;
char *new;
int pertinent;
void *used;
struct _defines *next;
};