From 5b3a2ca850718e1fd74f26bc2886e880676b2cd6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 19 Feb 2017 16:41:51 -0500 Subject: Dept of second thoughts: rename new perl script. It didn't take long at all for me to become irritated that the original choice of name for this script resulted in "warning" showing up in several places in build logs, because I tend to grep for that. Change the script name to avoid that. --- src/Makefile.global.in | 2 +- src/tools/fix-flex-warning.pl | 65 ------------------------------------------ src/tools/fix-old-flex-code.pl | 65 ++++++++++++++++++++++++++++++++++++++++++ src/tools/msvc/pgflex.pl | 2 +- 4 files changed, 67 insertions(+), 67 deletions(-) delete mode 100644 src/tools/fix-flex-warning.pl create mode 100644 src/tools/fix-old-flex-code.pl (limited to 'src') diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 35c8cb826ec..831d39a9d13 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -627,7 +627,7 @@ TAS = @TAS@ ifdef FLEX $(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $< @$(if $(FLEX_NO_BACKUP),if [ `wc -l &2; exit 1; fi) - $(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-flex-warning.pl '$@') + $(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@') else @$(missing) flex $< '$@' endif diff --git a/src/tools/fix-flex-warning.pl b/src/tools/fix-flex-warning.pl deleted file mode 100644 index 14df02198fb..00000000000 --- a/src/tools/fix-flex-warning.pl +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/perl -w -#---------------------------------------------------------------------- -# -# fix-flex-warning.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-2017, PostgreSQL Global Development Group -# Portions Copyright (c) 1994, Regents of the University of California -# -# src/tools/fix-flex-warning.pl -# -#---------------------------------------------------------------------- - -use strict; -use warnings; - -# 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 -} diff --git a/src/tools/fix-old-flex-code.pl b/src/tools/fix-old-flex-code.pl new file mode 100644 index 00000000000..8dafcae15e2 --- /dev/null +++ b/src/tools/fix-old-flex-code.pl @@ -0,0 +1,65 @@ +#!/usr/bin/perl -w +#---------------------------------------------------------------------- +# +# 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-2017, 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; + +# 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 +} diff --git a/src/tools/msvc/pgflex.pl b/src/tools/msvc/pgflex.pl index d590155f106..fab0efa79fb 100644 --- a/src/tools/msvc/pgflex.pl +++ b/src/tools/msvc/pgflex.pl @@ -60,7 +60,7 @@ if ($? == 0) { # Reentrant scanners usually need a fix to prevent # "unused variable" warnings with older flex versions. - system("perl src\\tools\\fix-flex-warning.pl $output"); + system("perl src\\tools\\fix-old-flex-code.pl $output"); } else { -- cgit v1.2.3