diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-12-11 14:54:25 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-12-11 14:54:25 -0500 |
commit | 92fb649837e36944bd0e9eed6c90b4b01b7deb18 (patch) | |
tree | 2a9886db5aee7e0722d4582d5154a99e2c8e6c8f /src/interfaces/ecpg/preproc/ecpg.c | |
parent | 0eaaaf00e296c2048b868b7c1d3c12c0eae6dd12 (diff) | |
download | postgresql-92fb649837e36944bd0e9eed6c90b4b01b7deb18.tar.gz postgresql-92fb649837e36944bd0e9eed6c90b4b01b7deb18.zip |
Use "%option prefix" to set API names in ecpg's lexer.
Clean up some technical debt left behind by commit 72b1e3a21: instead of
quickly hacking the name of base_yylex() with a #define, set it properly
with "%option prefix". This causes the names of pgc.l's other exported
symbols to change as well, so run around and modify the outside references
to them as needed. Similarly, make pgc.l's external references to
base_yylval use that variable's true name instead of a macro.
The reason for doing this now is that the quick-hack solution will fail
with future versions of flex, as reported by Дилян Палаузов.
Hence, back-patch into 9.6 where the previous commit appeared, since
it's likely people will build 9.6 with newer flex versions during
its lifetime.
Discussion: https://postgr.es/m/d845c1af-e18d-6651-178f-9f08cdf37e10@aegee.org
Diffstat (limited to 'src/interfaces/ecpg/preproc/ecpg.c')
-rw-r--r-- | src/interfaces/ecpg/preproc/ecpg.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c index 46bacb0e8ee..3b0de973210 100644 --- a/src/interfaces/ecpg/preproc/ecpg.c +++ b/src/interfaces/ecpg/preproc/ecpg.c @@ -165,11 +165,11 @@ main(int argc, char *const argv[]) case 'o': output_filename = mm_strdup(optarg); if (strcmp(output_filename, "-") == 0) - yyout = stdout; + base_yyout = stdout; else - yyout = fopen(output_filename, PG_BINARY_W); + base_yyout = fopen(output_filename, PG_BINARY_W); - if (yyout == NULL) + if (base_yyout == NULL) { fprintf(stderr, _("%s: could not open file \"%s\": %s\n"), progname, output_filename, strerror(errno)); @@ -232,7 +232,7 @@ main(int argc, char *const argv[]) break; case 'd': #ifdef YYDEBUG - yydebug = 1; + base_yydebug = 1; #else fprintf(stderr, _("%s: parser debug support (-d) not available\n"), progname); @@ -280,7 +280,7 @@ main(int argc, char *const argv[]) { input_filename = mm_alloc(strlen("stdin") + 1); strcpy(input_filename, "stdin"); - yyin = stdin; + base_yyin = stdin; } else { @@ -304,13 +304,13 @@ main(int argc, char *const argv[]) ptr2ext[4] = '\0'; } - yyin = fopen(input_filename, PG_BINARY_R); + base_yyin = fopen(input_filename, PG_BINARY_R); } if (out_option == 0) /* calculate the output name */ { if (strcmp(input_filename, "stdin") == 0) - yyout = stdout; + base_yyout = stdout; else { output_filename = mm_strdup(input_filename); @@ -320,8 +320,8 @@ main(int argc, char *const argv[]) ptr2ext[1] = (header_mode == true) ? 'h' : 'c'; ptr2ext[2] = '\0'; - yyout = fopen(output_filename, PG_BINARY_W); - if (yyout == NULL) + base_yyout = fopen(output_filename, PG_BINARY_W); + if (base_yyout == NULL) { fprintf(stderr, _("%s: could not open file \"%s\": %s\n"), progname, output_filename, strerror(errno)); @@ -332,7 +332,7 @@ main(int argc, char *const argv[]) } } - if (yyin == NULL) + if (base_yyin == NULL) fprintf(stderr, _("%s: could not open file \"%s\": %s\n"), progname, argv[fnr], strerror(errno)); else @@ -427,23 +427,23 @@ main(int argc, char *const argv[]) /* we need several includes */ /* but not if we are in header mode */ if (regression_mode) - fprintf(yyout, "/* Processed by ecpg (regression mode) */\n"); + fprintf(base_yyout, "/* Processed by ecpg (regression mode) */\n"); else - fprintf(yyout, "/* Processed by ecpg (%s) */\n", PG_VERSION); + fprintf(base_yyout, "/* Processed by ecpg (%s) */\n", PG_VERSION); if (header_mode == false) { - fprintf(yyout, "/* These include files are added by the preprocessor */\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n"); + fprintf(base_yyout, "/* These include files are added by the preprocessor */\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n"); /* add some compatibility headers */ if (INFORMIX_MODE) - fprintf(yyout, "/* Needed for informix compatibility */\n#include <ecpg_informix.h>\n"); + fprintf(base_yyout, "/* Needed for informix compatibility */\n#include <ecpg_informix.h>\n"); - fprintf(yyout, "/* End of automatic include section */\n"); + fprintf(base_yyout, "/* End of automatic include section */\n"); } if (regression_mode) - fprintf(yyout, "#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))\n"); + fprintf(base_yyout, "#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))\n"); output_line_number(); @@ -458,10 +458,10 @@ main(int argc, char *const argv[]) if (!(ptr->opened)) mmerror(PARSE_ERROR, ET_WARNING, "cursor \"%s\" has been declared but not opened", ptr->name); - if (yyin != NULL && yyin != stdin) - fclose(yyin); - if (out_option == 0 && yyout != stdout) - fclose(yyout); + if (base_yyin != NULL && base_yyin != stdin) + fclose(base_yyin); + if (out_option == 0 && base_yyout != stdout) + fclose(base_yyout); /* * If there was an error, delete the output file. |