Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2bdee07

Browse files
committed
Use "%option prefix" to set API names in ecpg's lexer.
Back-patch commit92fb649 into the pre-9.6 branches.Without this, ecpg fails to build with the latest version of flex.It's not unreasonable that people would want to compile our old brancheswith recent tools. Per report from Дилян Палаузов.Discussion:https://postgr.es/m/d845c1af-e18d-6651-178f-9f08cdf37e10@aegee.org
1 parent73ae395 commit2bdee07

File tree

9 files changed

+136
-141
lines changed

9 files changed

+136
-141
lines changed

‎src/interfaces/ecpg/preproc/descriptor.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ECPGnumeric_lvalue(char *name)
5858
caseECPGt_unsigned_long:
5959
caseECPGt_unsigned_long_long:
6060
caseECPGt_const:
61-
fputs(name,yyout);
61+
fputs(name,base_yyout);
6262
break;
6363
default:
6464
mmerror(PARSE_ERROR,ET_ERROR,"variable \"%s\" must have a numeric type",name);
@@ -152,7 +152,7 @@ output_get_descr_header(char *desc_name)
152152
{
153153
structassignment*results;
154154

155-
fprintf(yyout,"{ ECPGget_desc_header(__LINE__, %s, &(",desc_name);
155+
fprintf(base_yyout,"{ ECPGget_desc_header(__LINE__, %s, &(",desc_name);
156156
for (results=assignments;results!=NULL;results=results->next)
157157
{
158158
if (results->value==ECPGd_count)
@@ -162,7 +162,7 @@ output_get_descr_header(char *desc_name)
162162
}
163163

164164
drop_assignments();
165-
fprintf(yyout,"));\n");
165+
fprintf(base_yyout,"));\n");
166166
whenever_action(3);
167167
}
168168

@@ -171,7 +171,7 @@ output_get_descr(char *desc_name, char *index)
171171
{
172172
structassignment*results;
173173

174-
fprintf(yyout,"{ ECPGget_desc(__LINE__, %s, %s,",desc_name,index);
174+
fprintf(base_yyout,"{ ECPGget_desc(__LINE__, %s, %s,",desc_name,index);
175175
for (results=assignments;results!=NULL;results=results->next)
176176
{
177177
conststructvariable*v=find_variable(results->variable);
@@ -188,12 +188,13 @@ output_get_descr(char *desc_name, char *index)
188188
default:
189189
break;
190190
}
191-
fprintf(yyout,"%s,",get_dtype(results->value));
192-
ECPGdump_a_type(yyout,v->name,v->type,v->brace_level,NULL,NULL,-1,NULL,NULL,str_zero,NULL,NULL);
191+
fprintf(base_yyout,"%s,",get_dtype(results->value));
192+
ECPGdump_a_type(base_yyout,v->name,v->type,v->brace_level,
193+
NULL,NULL,-1,NULL,NULL,str_zero,NULL,NULL);
193194
free(str_zero);
194195
}
195196
drop_assignments();
196-
fputs("ECPGd_EODT);\n",yyout);
197+
fputs("ECPGd_EODT);\n",base_yyout);
197198

198199
whenever_action(2 |1);
199200
}
@@ -203,7 +204,7 @@ output_set_descr_header(char *desc_name)
203204
{
204205
structassignment*results;
205206

206-
fprintf(yyout,"{ ECPGset_desc_header(__LINE__, %s, (int)(",desc_name);
207+
fprintf(base_yyout,"{ ECPGset_desc_header(__LINE__, %s, (int)(",desc_name);
207208
for (results=assignments;results!=NULL;results=results->next)
208209
{
209210
if (results->value==ECPGd_count)
@@ -213,7 +214,7 @@ output_set_descr_header(char *desc_name)
213214
}
214215

215216
drop_assignments();
216-
fprintf(yyout,"));\n");
217+
fprintf(base_yyout,"));\n");
217218
whenever_action(3);
218219
}
219220

@@ -264,7 +265,7 @@ output_set_descr(char *desc_name, char *index)
264265
{
265266
structassignment*results;
266267

267-
fprintf(yyout,"{ ECPGset_desc(__LINE__, %s, %s,",desc_name,index);
268+
fprintf(base_yyout,"{ ECPGset_desc(__LINE__, %s, %s,",desc_name,index);
268269
for (results=assignments;results!=NULL;results=results->next)
269270
{
270271
conststructvariable*v=find_variable(results->variable);
@@ -295,9 +296,11 @@ output_set_descr(char *desc_name, char *index)
295296
caseECPGd_length:
296297
caseECPGd_type:
297298
{
298-
char*str_zero=mm_strdup("0");
299-
fprintf(yyout,"%s,",get_dtype(results->value));
300-
ECPGdump_a_type(yyout,v->name,v->type,v->brace_level,NULL,NULL,-1,NULL,NULL,str_zero,NULL,NULL);
299+
char*str_zero=mm_strdup("0");
300+
301+
fprintf(base_yyout,"%s,",get_dtype(results->value));
302+
ECPGdump_a_type(base_yyout,v->name,v->type,v->brace_level,
303+
NULL,NULL,-1,NULL,NULL,str_zero,NULL,NULL);
301304
free(str_zero);
302305
}
303306
break;
@@ -307,7 +310,7 @@ output_set_descr(char *desc_name, char *index)
307310
}
308311
}
309312
drop_assignments();
310-
fputs("ECPGd_EODT);\n",yyout);
313+
fputs("ECPGd_EODT);\n",base_yyout);
311314

312315
whenever_action(2 |1);
313316
}

‎src/interfaces/ecpg/preproc/ecpg.addons

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ECPG: stmtClosePortalStmt block
88
if (connection)
99
mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CLOSE DATABASE statement");
1010

11-
fprintf(yyout, "{ ECPGdisconnect(__LINE__, \"CURRENT\");");
11+
fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, \"CURRENT\");");
1212
whenever_action(2);
1313
free($1);
1414
break;
@@ -42,14 +42,14 @@ ECPG: stmtPrepareStmt block
4242
}
4343
ECPG: stmtTransactionStmt block
4444
{
45-
fprintf(yyout, "{ ECPGtrans(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
45+
fprintf(base_yyout, "{ ECPGtrans(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
4646
whenever_action(2);
4747
free($1);
4848
}
4949
ECPG: stmtViewStmt rule
5050
| ECPGAllocateDescr
5151
{
52-
fprintf(yyout,"ECPGallocate_desc(__LINE__, %s);",$1);
52+
fprintf(base_yyout,"ECPGallocate_desc(__LINE__, %s);",$1);
5353
whenever_action(0);
5454
free($1);
5555
}
@@ -58,7 +58,7 @@ ECPG: stmtViewStmt rule
5858
if (connection)
5959
mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CONNECT statement");
6060

61-
fprintf(yyout, "{ ECPGconnect(__LINE__, %d, %s, %d); ", compat, $1, autocommit);
61+
fprintf(base_yyout, "{ ECPGconnect(__LINE__, %d, %s, %d); ", compat, $1, autocommit);
6262
reset_variables();
6363
whenever_action(2);
6464
free($1);
@@ -69,7 +69,7 @@ ECPG: stmtViewStmt rule
6969
}
7070
| ECPGDeallocateDescr
7171
{
72-
fprintf(yyout,"ECPGdeallocate_desc(__LINE__, %s);",$1);
72+
fprintf(base_yyout,"ECPGdeallocate_desc(__LINE__, %s);",$1);
7373
whenever_action(0);
7474
free($1);
7575
}
@@ -79,10 +79,10 @@ ECPG: stmtViewStmt rule
7979
}
8080
| ECPGDescribe
8181
{
82-
fprintf(yyout, "{ ECPGdescribe(__LINE__, %d, %s,", compat, $1);
82+
fprintf(base_yyout, "{ ECPGdescribe(__LINE__, %d, %s,", compat, $1);
8383
dump_variables(argsresult, 1);
84-
fputs("ECPGt_EORT);",yyout);
85-
fprintf(yyout, "}");
84+
fputs("ECPGt_EORT);",base_yyout);
85+
fprintf(base_yyout, "}");
8686
output_line_number();
8787

8888
free($1);
@@ -92,7 +92,7 @@ ECPG: stmtViewStmt rule
9292
if (connection)
9393
mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in DISCONNECT statement");
9494

95-
fprintf(yyout, "{ ECPGdisconnect(__LINE__, %s);",
95+
fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, %s);",
9696
$1 ? $1 : "\"CURRENT\"");
9797
whenever_action(2);
9898
free($1);
@@ -103,11 +103,11 @@ ECPG: stmtViewStmt rule
103103
const char *con = connection ? connection : "NULL";
104104

105105
if (strcmp($1, "all") == 0)
106-
fprintf(yyout, "{ ECPGdeallocate_all(__LINE__, %d, %s);", compat, con);
106+
fprintf(base_yyout, "{ ECPGdeallocate_all(__LINE__, %d, %s);", compat, con);
107107
else if ($1[0] == ':')
108-
fprintf(yyout, "{ ECPGdeallocate(__LINE__, %d, %s, %s);", compat, con, $1+1);
108+
fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, %s);", compat, con, $1+1);
109109
else
110-
fprintf(yyout, "{ ECPGdeallocate(__LINE__, %d, %s, \"%s\");", compat, con, $1);
110+
fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, \"%s\");", compat, con, $1);
111111

112112
whenever_action(2);
113113
free($1);
@@ -138,7 +138,7 @@ ECPG: stmtViewStmt rule
138138
}
139139
| ECPGSetAutocommit
140140
{
141-
fprintf(yyout, "{ ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL");
141+
fprintf(base_yyout, "{ ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL");
142142
whenever_action(2);
143143
free($1);
144144
}
@@ -147,7 +147,7 @@ ECPG: stmtViewStmt rule
147147
if (connection)
148148
mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in SET CONNECTION statement");
149149

150-
fprintf(yyout, "{ ECPGsetconn(__LINE__, %s);", $1);
150+
fprintf(base_yyout, "{ ECPGsetconn(__LINE__, %s);", $1);
151151
whenever_action(2);
152152
free($1);
153153
}
@@ -169,7 +169,7 @@ ECPG: stmtViewStmt rule
169169
if (connection)
170170
mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in TYPE statement");
171171

172-
fprintf(yyout, "%s", $1);
172+
fprintf(base_yyout, "%s", $1);
173173
free($1);
174174
output_line_number();
175175
}

‎src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ main(int argc, char *const argv[])
162162
case'o':
163163
output_filename=strdup(optarg);
164164
if (strcmp(output_filename,"-")==0)
165-
yyout=stdout;
165+
base_yyout=stdout;
166166
else
167-
yyout=fopen(output_filename,PG_BINARY_W);
167+
base_yyout=fopen(output_filename,PG_BINARY_W);
168168

169-
if (yyout==NULL)
169+
if (base_yyout==NULL)
170170
{
171171
fprintf(stderr,_("%s: could not open file \"%s\": %s\n"),
172172
progname,output_filename,strerror(errno));
@@ -229,7 +229,7 @@ main(int argc, char *const argv[])
229229
break;
230230
case'd':
231231
#ifdefYYDEBUG
232-
yydebug=1;
232+
base_yydebug=1;
233233
#else
234234
fprintf(stderr,_("%s: parser debug support (-d) not available\n"),
235235
progname);
@@ -276,7 +276,7 @@ main(int argc, char *const argv[])
276276
{
277277
input_filename=mm_alloc(strlen("stdin")+1);
278278
strcpy(input_filename,"stdin");
279-
yyin=stdin;
279+
base_yyin=stdin;
280280
}
281281
else
282282
{
@@ -300,13 +300,13 @@ main(int argc, char *const argv[])
300300
ptr2ext[4]='\0';
301301
}
302302

303-
yyin=fopen(input_filename,PG_BINARY_R);
303+
base_yyin=fopen(input_filename,PG_BINARY_R);
304304
}
305305

306306
if (out_option==0)/* calculate the output name */
307307
{
308308
if (strcmp(input_filename,"stdin")==0)
309-
yyout=stdout;
309+
base_yyout=stdout;
310310
else
311311
{
312312
output_filename=strdup(input_filename);
@@ -316,8 +316,8 @@ main(int argc, char *const argv[])
316316
ptr2ext[1]= (header_mode== true) ?'h' :'c';
317317
ptr2ext[2]='\0';
318318

319-
yyout=fopen(output_filename,PG_BINARY_W);
320-
if (yyout==NULL)
319+
base_yyout=fopen(output_filename,PG_BINARY_W);
320+
if (base_yyout==NULL)
321321
{
322322
fprintf(stderr,_("%s: could not open file \"%s\": %s\n"),
323323
progname,output_filename,strerror(errno));
@@ -328,7 +328,7 @@ main(int argc, char *const argv[])
328328
}
329329
}
330330

331-
if (yyin==NULL)
331+
if (base_yyin==NULL)
332332
fprintf(stderr,_("%s: could not open file \"%s\": %s\n"),
333333
progname,argv[fnr],strerror(errno));
334334
else
@@ -423,23 +423,23 @@ main(int argc, char *const argv[])
423423
/* we need several includes */
424424
/* but not if we are in header mode */
425425
if (regression_mode)
426-
fprintf(yyout,"/* Processed by ecpg (regression mode) */\n");
426+
fprintf(base_yyout,"/* Processed by ecpg (regression mode) */\n");
427427
else
428-
fprintf(yyout,"/* Processed by ecpg (%d.%d.%d) */\n",MAJOR_VERSION,MINOR_VERSION,PATCHLEVEL);
428+
fprintf(base_yyout,"/* Processed by ecpg (%d.%d.%d) */\n",MAJOR_VERSION,MINOR_VERSION,PATCHLEVEL);
429429

430430
if (header_mode== false)
431431
{
432-
fprintf(yyout,"/* These include files are added by the preprocessor */\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n");
432+
fprintf(base_yyout,"/* These include files are added by the preprocessor */\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n");
433433

434434
/* add some compatibility headers */
435435
if (INFORMIX_MODE)
436-
fprintf(yyout,"/* Needed for informix compatibility */\n#include <ecpg_informix.h>\n");
436+
fprintf(base_yyout,"/* Needed for informix compatibility */\n#include <ecpg_informix.h>\n");
437437

438-
fprintf(yyout,"/* End of automatic include section */\n");
438+
fprintf(base_yyout,"/* End of automatic include section */\n");
439439
}
440440

441441
if (regression_mode)
442-
fprintf(yyout,"#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))\n");
442+
fprintf(base_yyout,"#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))\n");
443443

444444
output_line_number();
445445

@@ -454,10 +454,10 @@ main(int argc, char *const argv[])
454454
if (!(ptr->opened))
455455
mmerror(PARSE_ERROR,ET_WARNING,"cursor \"%s\" has been declared but not opened",ptr->name);
456456

457-
if (yyin!=NULL&&yyin!=stdin)
458-
fclose(yyin);
459-
if (out_option==0&&yyout!=stdout)
460-
fclose(yyout);
457+
if (base_yyin!=NULL&&base_yyin!=stdin)
458+
fclose(base_yyin);
459+
if (out_option==0&&base_yyout!=stdout)
460+
fclose(base_yyout);
461461

462462
/*
463463
* If there was an error, delete the output file.

‎src/interfaces/ecpg/preproc/ecpg.header

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ mmerror(int error_code, enum errortype type, const char *error, ...)
7272
/* internationalize the error message string */
7373
error = _(error);
7474

75-
fprintf(stderr, "%s:%d: ", input_filename,yylineno);
75+
fprintf(stderr, "%s:%d: ", input_filename,base_yylineno);
7676

7777
switch(type)
7878
{
@@ -99,10 +99,10 @@ mmerror(int error_code, enum errortype type, const char *error, ...)
9999
ret_value = error_code;
100100
break;
101101
case ET_FATAL:
102-
if (yyin)
103-
fclose(yyin);
104-
if (yyout)
105-
fclose(yyout);
102+
if (base_yyin)
103+
fclose(base_yyin);
104+
if (base_yyout)
105+
fclose(base_yyout);
106106

107107
if (strcmp(output_filename, "-") != 0 && unlink(output_filename) != 0)
108108
fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename);
@@ -178,7 +178,7 @@ make3_str(char *str1, char *str2, char *str3)
178178
static char *
179179
make_name(void)
180180
{
181-
return mm_strdup(yytext);
181+
return mm_strdup(base_yytext);
182182
}
183183

184184
static char *

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp