Skip to content

Commit 4f67858

Browse files
committed
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/b517ec3918d645eb950505eac8dd434e@gaz-is.ru
1 parent 3f61b32 commit 4f67858

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ add_preprocessor_define(char *define)
9999
/* symbol has a value */
100100
for (tmp = ptr - 1; *tmp == ' '; tmp--);
101101
tmp[1] = '\0';
102-
defines->old = define_copy;
103-
defines->new = ptr + 1;
102+
defines->olddef = define_copy;
103+
defines->newdef = ptr + 1;
104104
}
105105
else
106106
{
107-
defines->old = define_copy;
108-
defines->new = mm_strdup("1");
107+
defines->olddef = define_copy;
108+
defines->newdef = mm_strdup("1");
109109
}
110110
defines->pertinent = true;
111111
defines->used = NULL;
@@ -410,8 +410,8 @@ main(int argc, char *const argv[])
410410
defptr = defines;
411411
defines = defines->next;
412412

413-
free(defptr->new);
414-
free(defptr->old);
413+
free(defptr->newdef);
414+
free(defptr->olddef);
415415
free(defptr);
416416
}
417417

@@ -423,8 +423,8 @@ main(int argc, char *const argv[])
423423
{
424424
defptr->next = this->next;
425425

426-
free(this->new);
427-
free(this->old);
426+
free(this->newdef);
427+
free(this->olddef);
428428
free(this);
429429
}
430430
}

src/interfaces/ecpg/preproc/pgc.l

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,14 +1114,14 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
11141114

11151115
for (ptr = defines; ptr != NULL; ptr2 = ptr, ptr = ptr->next)
11161116
{
1117-
if (strcmp(yytext, ptr->old) == 0)
1117+
if (strcmp(yytext, ptr->olddef) == 0)
11181118
{
11191119
if (ptr2 == NULL)
11201120
defines = ptr->next;
11211121
else
11221122
ptr2->next = ptr->next;
1123-
free(ptr->new);
1124-
free(ptr->old);
1123+
free(ptr->newdef);
1124+
free(ptr->olddef);
11251125
free(ptr);
11261126
break;
11271127
}
@@ -1300,8 +1300,10 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
13001300
yytext[i+1] = '\0';
13011301

13021302
for (defptr = defines;
1303-
defptr != NULL && strcmp(yytext, defptr->old) != 0;
1304-
defptr = defptr->next);
1303+
defptr != NULL &&
1304+
strcmp(yytext, defptr->olddef) != 0;
1305+
defptr = defptr->next)
1306+
/* skip */ ;
13051307

13061308
preproc_tos++;
13071309
stacked_if_value[preproc_tos].else_branch = false;
@@ -1333,19 +1335,19 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
13331335

13341336
for (ptr = defines; ptr != NULL; ptr = ptr->next)
13351337
{
1336-
if (strcmp(old, ptr->old) == 0)
1338+
if (strcmp(old, ptr->olddef) == 0)
13371339
{
1338-
free(ptr->new);
1339-
ptr->new = mm_strdup(literalbuf);
1340+
free(ptr->newdef);
1341+
ptr->newdef = mm_strdup(literalbuf);
13401342
}
13411343
}
13421344
if (ptr == NULL)
13431345
{
13441346
this = (struct _defines *) mm_alloc(sizeof(struct _defines));
13451347

13461348
/* initial definition */
1347-
this->old = old;
1348-
this->new = mm_strdup(literalbuf);
1349+
this->olddef = old;
1350+
this->newdef = mm_strdup(literalbuf);
13491351
this->next = defines;
13501352
this->used = NULL;
13511353
defines = this;
@@ -1613,7 +1615,7 @@ static bool isdefine(void)
16131615
/* is it a define? */
16141616
for (ptr = defines; ptr; ptr = ptr->next)
16151617
{
1616-
if (strcmp(yytext, ptr->old) == 0 && ptr->used == NULL)
1618+
if (strcmp(yytext, ptr->olddef) == 0 && ptr->used == NULL)
16171619
{
16181620
struct _yy_buffer *yb;
16191621

@@ -1626,7 +1628,7 @@ static bool isdefine(void)
16261628

16271629
ptr->used = yy_buffer = yb;
16281630

1629-
yy_scan_string(ptr->new);
1631+
yy_scan_string(ptr->newdef);
16301632
return true;
16311633
}
16321634
}

src/interfaces/ecpg/preproc/type.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ struct typedefs
160160

161161
struct _defines
162162
{
163-
char *old;
164-
char *new;
163+
char *olddef;
164+
char *newdef;
165165
int pertinent;
166166
void *used;
167167
struct _defines *next;

0 commit comments

Comments
 (0)