mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Drop warning-free support for Flex 2.5.35
This removes all the various workarounds for avoiding compiler warnings with Flex 2.5.35. Several recent patches have added additional warnings that would either need to be fixed along the lines of the existing workarounds, or we decide to no longer care about this, which we do here. Flex 2.5.35 is extremely outdated, and you can't even download it anymore from any of the Flex project sites, so it's nearly impossible to support. After this, using Flex 2.5.35 will still work, but the generated code will produce numerous compiler warnings. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/1a204ccd-7ae6-478c-a431-407b5c48ccc6@eisentraut.org
This commit is contained in:
@ -788,7 +788,6 @@ TAS = @TAS@
|
||||
%.c: %.l
|
||||
$(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
|
||||
@$(if $(FLEX_NO_BACKUP),if [ `wc -l <lex.backup` -eq 1 ]; then rm lex.backup; else echo "Scanner requires backup; see lex.backup." 1>&2; exit 1; fi)
|
||||
$(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@')
|
||||
|
||||
%.c: %.y
|
||||
$(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
|
||||
|
@ -59,7 +59,6 @@ gram.c: BISON_CHECK_CMD = $(PERL) $(srcdir)/check_keywords.pl $< $(top_srcdir)/s
|
||||
|
||||
scan.c: FLEXFLAGS = -CF -p -p
|
||||
scan.c: FLEX_NO_BACKUP=yes
|
||||
scan.c: FLEX_FIX_WARNING=yes
|
||||
|
||||
|
||||
# Force these dependencies to be known even without dependency info built:
|
||||
|
@ -30,7 +30,7 @@ parser_sources = files('parser.c')
|
||||
backend_scanner = custom_target('scan',
|
||||
input: 'scan.l',
|
||||
output: 'scan.c',
|
||||
command: [flex_cmd, '--no-backup', '--fix-warnings', '--', '-CF', '-p', '-p'],
|
||||
command: [flex_cmd, '--no-backup', '--', '-CF', '-p', '-p'],
|
||||
)
|
||||
generated_sources += backend_scanner
|
||||
parser_sources += backend_scanner
|
||||
|
@ -130,15 +130,6 @@ static void addunicode(pg_wchar c, yyscan_t yyscanner);
|
||||
static void check_string_escape_warning(unsigned char ychar, core_yyscan_t yyscanner);
|
||||
static void check_escape_warning(core_yyscan_t yyscanner);
|
||||
|
||||
/*
|
||||
* Work around a bug in flex 2.5.35: it emits a couple of functions that
|
||||
* it forgets to emit declarations for. Since we use -Wmissing-prototypes,
|
||||
* this would cause warnings. Providing our own declarations should be
|
||||
* harmless even when the bug gets fixed.
|
||||
*/
|
||||
extern int core_yyget_column(yyscan_t yyscanner);
|
||||
extern void core_yyset_column(int column_no, yyscan_t yyscanner);
|
||||
|
||||
%}
|
||||
|
||||
%option reentrant
|
||||
|
@ -44,15 +44,6 @@ static const char *expr_command = NULL;
|
||||
/* indicates whether last yylex() call read a newline */
|
||||
static bool last_was_newline = false;
|
||||
|
||||
/*
|
||||
* Work around a bug in flex 2.5.35: it emits a couple of functions that
|
||||
* it forgets to emit declarations for. Since we use -Wmissing-prototypes,
|
||||
* this would cause warnings. Providing our own declarations should be
|
||||
* harmless even when the bug gets fixed.
|
||||
*/
|
||||
extern int expr_yyget_column(yyscan_t yyscanner);
|
||||
extern void expr_yyset_column(int column_no, yyscan_t yyscanner);
|
||||
|
||||
/* LCOV_EXCL_START */
|
||||
|
||||
%}
|
||||
|
@ -60,7 +60,6 @@ sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
|
||||
|
||||
psqlscanslash.c: FLEXFLAGS = -Cfe -p -p
|
||||
psqlscanslash.c: FLEX_NO_BACKUP=yes
|
||||
psqlscanslash.c: FLEX_FIX_WARNING=yes
|
||||
|
||||
tab-complete.c: gen_tabcomplete.pl tab-complete.in.c
|
||||
$(PERL) $^ --outfile $@
|
||||
|
@ -19,7 +19,7 @@ psql_sources = files(
|
||||
psqlscanslash = custom_target('psqlscanslash',
|
||||
input: 'psqlscanslash.l',
|
||||
output: 'psqlscanslash.c',
|
||||
command: [flex_cmd, '--no-backup', '--fix-warnings', '--', '-Cfe', '-p', '-p'])
|
||||
command: [flex_cmd, '--no-backup', '--', '-Cfe', '-p', '-p'])
|
||||
generated_sources += psqlscanslash
|
||||
psql_sources += psqlscanslash
|
||||
|
||||
|
@ -57,15 +57,6 @@ static void evaluate_backtick(PsqlScanState state);
|
||||
|
||||
#define ECHO psqlscan_emit(cur_state, yytext, yyleng)
|
||||
|
||||
/*
|
||||
* Work around a bug in flex 2.5.35: it emits a couple of functions that
|
||||
* it forgets to emit declarations for. Since we use -Wmissing-prototypes,
|
||||
* this would cause warnings. Providing our own declarations should be
|
||||
* harmless even when the bug gets fixed.
|
||||
*/
|
||||
extern int slash_yyget_column(yyscan_t yyscanner);
|
||||
extern void slash_yyset_column(int column_no, yyscan_t yyscanner);
|
||||
|
||||
/* LCOV_EXCL_START */
|
||||
|
||||
%}
|
||||
|
@ -51,7 +51,6 @@ libpgfeutils.a: $(OBJS)
|
||||
|
||||
psqlscan.c: FLEXFLAGS = -Cfe -p -p
|
||||
psqlscan.c: FLEX_NO_BACKUP=yes
|
||||
psqlscan.c: FLEX_FIX_WARNING=yes
|
||||
|
||||
# libpgfeutils could be useful to contrib, so install it
|
||||
install: all installdirs
|
||||
|
@ -23,7 +23,7 @@ fe_utils_sources = files(
|
||||
psqlscan = custom_target('psqlscan',
|
||||
input: 'psqlscan.l',
|
||||
output: 'psqlscan.c',
|
||||
command: [flex_cmd, '--no-backup', '--fix-warnings', '--', '-Cfe', '-p', '-p'],
|
||||
command: [flex_cmd, '--no-backup', '--', '-Cfe', '-p', '-p'],
|
||||
)
|
||||
generated_sources += psqlscan
|
||||
fe_utils_sources += psqlscan
|
||||
|
@ -61,15 +61,6 @@ typedef int YYSTYPE;
|
||||
|
||||
#define ECHO psqlscan_emit(cur_state, yytext, yyleng)
|
||||
|
||||
/*
|
||||
* Work around a bug in flex 2.5.35: it emits a couple of functions that
|
||||
* it forgets to emit declarations for. Since we use -Wmissing-prototypes,
|
||||
* this would cause warnings. Providing our own declarations should be
|
||||
* harmless even when the bug gets fixed.
|
||||
*/
|
||||
extern int psql_yyget_column(yyscan_t yyscanner);
|
||||
extern void psql_yyset_column(int column_no, yyscan_t yyscanner);
|
||||
|
||||
%}
|
||||
|
||||
%option reentrant
|
||||
|
@ -1,66 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#----------------------------------------------------------------------
|
||||
#
|
||||
# fix-old-flex-code.pl
|
||||
#
|
||||
# flex versions before 2.5.36, with certain option combinations, produce
|
||||
# code that causes an "unused variable" warning. That's annoying, so
|
||||
# let's suppress it by inserting a dummy reference to the variable.
|
||||
# (That's exactly what 2.5.36 and later do ...)
|
||||
#
|
||||
# Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
||||
# Portions Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# src/tools/fix-old-flex-code.pl
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
|
||||
# Get command line argument.
|
||||
usage() if $#ARGV != 0;
|
||||
my $filename = shift;
|
||||
|
||||
# Suck in the whole file.
|
||||
local $/ = undef;
|
||||
my $cfile;
|
||||
open($cfile, '<', $filename) || die "opening $filename for reading: $!";
|
||||
my $ccode = <$cfile>;
|
||||
close($cfile);
|
||||
|
||||
# No need to do anything if it's not flex 2.5.x for x < 36.
|
||||
exit 0 if $ccode !~ m/^#define YY_FLEX_MAJOR_VERSION 2$/m;
|
||||
exit 0 if $ccode !~ m/^#define YY_FLEX_MINOR_VERSION 5$/m;
|
||||
exit 0 if $ccode !~ m/^#define YY_FLEX_SUBMINOR_VERSION (\d+)$/m;
|
||||
exit 0 if $1 >= 36;
|
||||
|
||||
# Apply the desired patch.
|
||||
$ccode =~
|
||||
s|(struct yyguts_t \* yyg = \(struct yyguts_t\*\)yyscanner; /\* This var may be unused depending upon options. \*/
|
||||
.*?)
|
||||
return yy_is_jam \? 0 : yy_current_state;
|
||||
|$1
|
||||
(void) yyg;
|
||||
return yy_is_jam ? 0 : yy_current_state;
|
||||
|s;
|
||||
|
||||
# Write the modified file back out.
|
||||
open($cfile, '>', $filename) || die "opening $filename for writing: $!";
|
||||
print $cfile $ccode;
|
||||
close($cfile);
|
||||
|
||||
exit 0;
|
||||
|
||||
|
||||
sub usage
|
||||
{
|
||||
die <<EOM;
|
||||
Usage: fix-old-flex-code.pl c-file-name
|
||||
|
||||
fix-old-flex-code.pl modifies a flex output file to suppress
|
||||
an unused-variable warning that occurs with older flex versions.
|
||||
|
||||
Report bugs to <pgsql-bugs\@lists.postgresql.org>.
|
||||
EOM
|
||||
}
|
@ -4,7 +4,6 @@
|
||||
# Wrapper around flex that:
|
||||
# - ensures lex.backup is created in a private directory
|
||||
# - can error out if lex.backup is created (--no-backup)
|
||||
# - can fix warnings (--fix-warnings)
|
||||
# - works around concurrency issues with win_flex.exe:
|
||||
# https://github.com/lexxmark/winflexbison/issues/86
|
||||
|
||||
@ -28,8 +27,6 @@ parser.add_argument('-o', dest='output_file', type=abspath, required=True,
|
||||
parser.add_argument('-i', dest='input_file', type=abspath, help='input file')
|
||||
|
||||
|
||||
parser.add_argument('--fix-warnings', action='store_true',
|
||||
help='whether to fix warnings in generated file')
|
||||
parser.add_argument('--no-backup', action='store_true',
|
||||
help='whether no_backup is enabled or not')
|
||||
|
||||
@ -72,14 +69,4 @@ if args.no_backup:
|
||||
sys.exit('Scanner requires backup; see lex.backup.')
|
||||
os.remove('lex.backup')
|
||||
|
||||
# fix warnings
|
||||
if args.fix_warnings:
|
||||
fix_warning_script = os.path.join(args.srcdir,
|
||||
'src/tools/fix-old-flex-code.pl')
|
||||
|
||||
command = [args.perl, fix_warning_script, args.output_file]
|
||||
sp = subprocess.run(command)
|
||||
if sp.returncode != 0:
|
||||
sys.exit(sp.returncode)
|
||||
|
||||
sys.exit(0)
|
||||
|
Reference in New Issue
Block a user