summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2019-05-31 16:38:53 +0000
committerTom Lane2019-05-31 16:38:53 +0000
commit4f67858d3f210658d42f44fc674d2850581e572e (patch)
tree7423fd34d7797154bd7d3207a8ea7d36aabe6c9f
parent3f61b3205f1a8bd27909be97341f002db8842093 (diff)
Fix C++ incompatibilities in ecpg/preproc/ header files.
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/[email protected]
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.c16
-rw-r--r--src/interfaces/ecpg/preproc/pgc.l26
-rw-r--r--src/interfaces/ecpg/preproc/type.h4
3 files changed, 24 insertions, 22 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index 861a2d98d5..e60d2be9a3 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -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);
}
}
diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l
index 3dc2453a2f..488c89b7f4 100644
--- a/src/interfaces/ecpg/preproc/pgc.l
+++ b/src/interfaces/ecpg/preproc/pgc.l
@@ -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;
}
}
diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h
index ceb6270973..9c1df73241 100644
--- a/src/interfaces/ecpg/preproc/type.h
+++ b/src/interfaces/ecpg/preproc/type.h
@@ -160,8 +160,8 @@ struct typedefs
struct _defines
{
- char *old;
- char *new;
+ char *olddef;
+ char *newdef;
int pertinent;
void *used;
struct _defines *next;