Index: src/tools/msvc/vcregress.pl
===================================================================
RCS file: /cvsroot/pgsql/src/tools/msvc/vcregress.pl,v
retrieving revision 1.10
diff -c -r1.10 vcregress.pl
*** src/tools/msvc/vcregress.pl	1 Dec 2008 13:39:45 -0000	1.10
--- src/tools/msvc/vcregress.pl	18 Aug 2009 18:12:59 -0000
***************
*** 185,194 ****
  		print "============================================================\n";
          print "Checking $module\n";
          my @tests = fetchTests();
          my @args = (
              "../../$Config/pg_regress/pg_regress",
              "--psqldir=../../$Config/psql",
!             "--dbname=contrib_regression",@tests
          );
          system(@args);
          my $status = $? >> 8;
--- 185,195 ----
  		print "============================================================\n";
          print "Checking $module\n";
          my @tests = fetchTests();
+ 		my @opts = fetchRegressOpts();
          my @args = (
              "../../$Config/pg_regress/pg_regress",
              "--psqldir=../../$Config/psql",
!             "--dbname=contrib_regression",@opts,@tests
          );
          system(@args);
          my $status = $? >> 8;
***************
*** 198,203 ****
--- 199,223 ----
      exit $mstat if $mstat;
  }
  
+ sub fetchRegressOpts
+ {
+     my $handle;
+     open($handle,"<Makefile")
+       || open($handle,"<GNUmakefile")
+       || die "Could not open Makefile";
+     local($/) = undef;
+     my $m = <$handle>;
+     close($handle);
+ 	my @opts;
+ 	if ($m =~ /^\s*REGRESS_OPTS\s*=(.*)/m)
+ 	{
+ 		# ignore options that use makefile variables - can't handle those
+ 		# ignore anything that isn't an option staring with --
+ 		@opts = grep { $_ !~ /\$\(/ && $_ =~ /^--/ } split(/\s+/,$1);
+ 	}
+ 	return @opts;
+ }
+ 
  sub fetchTests
  {
  
