]> granicus.if.org Git - postgresql/commitdiff
Fixed handling of cyclic defines.
authorMichael Meskes <meskes@postgresql.org>
Tue, 20 Jul 2004 18:22:53 +0000 (18:22 +0000)
committerMichael Meskes <meskes@postgresql.org>
Tue, 20 Jul 2004 18:22:53 +0000 (18:22 +0000)
src/interfaces/ecpg/preproc/ecpg.c
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/preproc/type.h

index 967dce8f155899aa19ff2e8749fd2c703298da07..e3a1023d7c5a591fe65726255baf95a8fe22e54d 100644 (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;
 }
 
index babb2ac07098c2544a1baed4e7399aa768dfe279..c7ec6d69fc9e89ab3fc9be3e34bddb2b7498a50c 100644 (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,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);
 
index 4091a562ab42ffb06bdab96dbc8a93f1c4125cc7..1d34a7c9ec533f42fe5cfbef3009b8b553a789e3 100644 (file)
@@ -134,6 +134,7 @@ struct _defines
        char            *old;
        char            *new;
        int             pertinent;
+       void            *used;
        struct _defines *next;
 };