1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-24 00:23:06 +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:
Peter Eisentraut
2025-01-15 15:35:08 +01:00
parent 630f9a43ce
commit 6fdd5d9563
13 changed files with 3 additions and 122 deletions

View File

@@ -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
}

View File

@@ -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)