Fix C++ incompatibilities in ecpg/preproc/ header files.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 31 May 2019 16:38:53 +0000 (12:38 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 31 May 2019 16:38:53 +0000 (12:38 -0400)
There's probably no need to back-patch this, since it seems unlikely
that anybody would be inserting C++ code into ecpg's preprocessor.

Discussion: https://postgr.es/m/b517ec3918d645eb950505eac8dd434e@gaz-is.ru

src/interfaces/ecpg/preproc/ecpg.c
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/preproc/type.h

index 861a2d98d5eff6d0e03a1b358eabb2d7876bf6a3..e60d2be9a36cf715a362369a2da481173349fad8 100644 (file)
@@ -99,13 +99,13 @@ add_preprocessor_define(char *define)
                /* symbol has a value */
                for (tmp = ptr - 1; *tmp == ' '; tmp--);
                tmp[1] = '\0';
-               defines->old = define_copy;
-               defines->new = ptr + 1;
+               defines->olddef = define_copy;
+               defines->newdef = ptr + 1;
        }
        else
        {
-               defines->old = define_copy;
-               defines->new = mm_strdup("1");
+               defines->olddef = define_copy;
+               defines->newdef = mm_strdup("1");
        }
        defines->pertinent = true;
        defines->used = NULL;
@@ -410,8 +410,8 @@ main(int argc, char *const argv[])
                                        defptr = defines;
                                        defines = defines->next;
 
-                                       free(defptr->new);
-                                       free(defptr->old);
+                                       free(defptr->newdef);
+                                       free(defptr->olddef);
                                        free(defptr);
                                }
 
@@ -423,8 +423,8 @@ main(int argc, char *const argv[])
                                        {
                                                defptr->next = this->next;
 
-                                               free(this->new);
-                                               free(this->old);
+                                               free(this->newdef);
+                                               free(this->olddef);
                                                free(this);
                                        }
                                }
index 3dc2453a2fc83fd358d2d3c8b4ad601ff354b65d..488c89b7f42ec01f3d489db8fa4be401b223543a 100644 (file)
@@ -1114,14 +1114,14 @@ cppline                 {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
 
                                        for (ptr = defines; ptr != NULL; ptr2 = ptr, ptr = ptr->next)
                                        {
-                                               if (strcmp(yytext, ptr->old) == 0)
+                                               if (strcmp(yytext, ptr->olddef) == 0)
                                                {
                                                        if (ptr2 == NULL)
                                                                defines = ptr->next;
                                                        else
                                                                ptr2->next = ptr->next;
-                                                       free(ptr->new);
-                                                       free(ptr->old);
+                                                       free(ptr->newdef);
+                                                       free(ptr->olddef);
                                                        free(ptr);
                                                        break;
                                                }
@@ -1300,8 +1300,10 @@ cppline                  {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
                                                yytext[i+1] = '\0';
 
                                                for (defptr = defines;
-                                                        defptr != NULL && strcmp(yytext, defptr->old) != 0;
-                                                        defptr = defptr->next);
+                                                        defptr != NULL &&
+                                                        strcmp(yytext, defptr->olddef) != 0;
+                                                        defptr = defptr->next)
+                                                       /* skip */ ;
 
                                                preproc_tos++;
                                                stacked_if_value[preproc_tos].else_branch = false;
@@ -1333,10 +1335,10 @@ cppline                 {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
 
                                                for (ptr = defines; ptr != NULL; ptr = ptr->next)
                                                {
-                                                        if (strcmp(old, ptr->old) == 0)
+                                                        if (strcmp(old, ptr->olddef) == 0)
                                                         {
-                                                               free(ptr->new);
-                                                               ptr->new = mm_strdup(literalbuf);
+                                                               free(ptr->newdef);
+                                                               ptr->newdef = mm_strdup(literalbuf);
                                                         }
                                                }
                                                if (ptr == NULL)
@@ -1344,8 +1346,8 @@ cppline                   {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
                                                        this = (struct _defines *) mm_alloc(sizeof(struct _defines));
 
                                                        /* initial definition */
-                                                       this->old = old;
-                                                       this->new = mm_strdup(literalbuf);
+                                                       this->olddef = old;
+                                                       this->newdef = mm_strdup(literalbuf);
                                                        this->next = defines;
                                                        this->used = NULL;
                                                        defines = this;
@@ -1613,7 +1615,7 @@ static bool isdefine(void)
        /* is it a define? */
        for (ptr = defines; ptr; ptr = ptr->next)
        {
-               if (strcmp(yytext, ptr->old) == 0 && ptr->used == NULL)
+               if (strcmp(yytext, ptr->olddef) == 0 && ptr->used == NULL)
                {
                        struct _yy_buffer *yb;
 
@@ -1626,7 +1628,7 @@ static bool isdefine(void)
 
                        ptr->used = yy_buffer = yb;
 
-                       yy_scan_string(ptr->new);
+                       yy_scan_string(ptr->newdef);
                        return true;
                }
        }
index ceb6270973d1553604006287306a473fe76c624a..9c1df73241c15e83883ffc42dad875c853312ada 100644 (file)
@@ -160,8 +160,8 @@ struct typedefs
 
 struct _defines
 {
-       char       *old;
-       char       *new;
+       char       *olddef;
+       char       *newdef;
        int                     pertinent;
        void       *used;
        struct _defines *next;