From 35d19a9a37c245ff7c640743f37b8df227fd24dc Mon Sep 17 00:00:00 2001
From: Noah Misch <noah@leadboat.com>
Date: Mon, 14 Jul 2014 14:07:27 -0400
Subject: [PATCH] MSVC: Process Makefile line continuations more like "make"
 does.

Unlike "make" itself, the MSVC build process recognized a continuation
even with whitespace after the backslash.  (Due to a typo, some code
sites accepted the letter "s" instead of whitespace).  Also, it would
consume any number of newlines following a single backslash.  This is
mere cleanup; those behaviors were unlikely to cause bugs.
---
 src/tools/msvc/Install.pm   | 10 +++++-----
 src/tools/msvc/Mkvcbuild.pm |  6 +++---
 src/tools/msvc/Project.pm   |  2 +-
 src/tools/msvc/Solution.pm  |  2 +-
 src/tools/msvc/vcregress.pl |  2 +-
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
index ce17f72ec5..eba9aa08f1 100644
--- a/src/tools/msvc/Install.pm
+++ b/src/tools/msvc/Install.pm
@@ -307,7 +307,7 @@ sub GenerateConversionScript
 
 	print "Generating conversion proc script...";
 	my $mf = read_file('src/backend/utils/mb/conversion_procs/Makefile');
-	$mf =~ s{\\\s*[\r\n]+}{}mg;
+	$mf =~ s{\\\r?\n}{}g;
 	$mf =~ /^CONVERSIONS\s*=\s*(.*)$/m
 	  || die "Could not find CONVERSIONS line in conversions Makefile\n";
 	my @pieces = split /\s+/, $1;
@@ -341,7 +341,7 @@ sub GenerateTimezoneFiles
 	my $target = shift;
 	my $conf   = shift;
 	my $mf     = read_file("src/timezone/Makefile");
-	$mf =~ s{\\\s*[\r\n]+}{}mg;
+	$mf =~ s{\\\r?\n}{}g;
 	$mf =~ /^TZDATA\s*:?=\s*(.*)$/m
 	  || die "Could not find TZDATA row in timezone makefile\n";
 	my @tzfiles = split /\s+/, $1;
@@ -360,7 +360,7 @@ sub GenerateTsearchFiles
 	my $F;
 	my $tmpl = read_file('src/backend/snowball/snowball.sql.in');
 	my $mf   = read_file('src/backend/snowball/Makefile');
-	$mf =~ s{\\\s*[\r\n]+}{}mg;
+	$mf =~ s{\\\r?\n}{}g;
 	$mf =~ /^LANGUAGES\s*=\s*(.*)$/m
 	  || die "Could not find LANGUAGES line in snowball Makefile\n";
 	my @pieces = split /\s+/, $1;
@@ -415,7 +415,7 @@ sub CopyContribFiles
 		next if ($d eq "sepgsql");
 
 		my $mf = read_file("contrib/$d/Makefile");
-		$mf =~ s{\\s*[\r\n]+}{}mg;
+		$mf =~ s{\\\r?\n}{}g;
 
 		# Note: we currently don't support setting MODULEDIR in the makefile
 		my $moduledir = 'contrib';
@@ -587,7 +587,7 @@ qq{xcopy /s /i /q /r /y src\\include\\$d\\*.h "$ctarget\\include\\server\\$d\\"}
 	closedir($D);
 
 	my $mf = read_file('src/interfaces/ecpg/include/Makefile');
-	$mf =~ s{\\s*[\r\n]+}{}mg;
+	$mf =~ s{\\\r?\n}{}g;
 	$mf =~ /^ecpg_headers\s*=\s*(.*)$/m
 	  || croak "Could not find ecpg_headers line\n";
 	CopyFiles(
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 71450f4773..d3220696c0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -524,7 +524,7 @@ sub mkvcbuild
 
 	$mf =
 	  Project::read_file('src\backend\utils\mb\conversion_procs\Makefile');
-	$mf =~ s{\\s*[\r\n]+}{}mg;
+	$mf =~ s{\\\r?\n}{}g;
 	$mf =~ m{SUBDIRS\s*=\s*(.*)$}m
 	  || die 'Could not match in conversion makefile' . "\n";
 	foreach my $sub (split /\s+/, $1)
@@ -536,7 +536,7 @@ sub mkvcbuild
 	}
 
 	$mf = Project::read_file('src\bin\scripts\Makefile');
-	$mf =~ s{\\s*[\r\n]+}{}mg;
+	$mf =~ s{\\\r?\n}{}g;
 	$mf =~ m{PROGRAMS\s*=\s*(.*)$}m
 	  || die 'Could not match in bin\scripts\Makefile' . "\n";
 	foreach my $prg (split /\s+/, $1)
@@ -674,7 +674,7 @@ sub GenerateContribSqlFiles
 {
 	my $n  = shift;
 	my $mf = shift;
-	$mf =~ s{\\\s*[\r\n]+}{}mg;
+	$mf =~ s{\\\r?\n}{}g;
 	if ($mf =~ /^DATA_built\s*=\s*(.*)$/mg)
 	{
 		my $l = $1;
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 9ca5b1f13a..f343b2b9b8 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -193,7 +193,7 @@ sub AddDir
 	my $mf = <$MF>;
 	close($MF);
 
-	$mf =~ s{\\\s*[\r\n]+}{}mg;
+	$mf =~ s{\\\r?\n}{}g;
 	if ($mf =~ m{^(?:SUB)?DIRS[^=]*=\s*(.*)$}mg)
 	{
 		foreach my $subdir (split /\s+/, $1)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 89e4b07c80..e49c3f4275 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -422,7 +422,7 @@ EOF
 	}
 
 	my $mf = Project::read_file('src\backend\catalog\Makefile');
-	$mf =~ s{\\s*[\r\n]+}{}mg;
+	$mf =~ s{\\\r?\n}{}g;
 	$mf =~ /^POSTGRES_BKI_SRCS\s*:?=[^,]+,(.*)\)$/gm
 	  || croak "Could not find POSTGRES_BKI_SRCS in Makefile\n";
 	my @allbki = split /\s+/, $1;
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 2c8cd50a2f..39698ee7ee 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -358,7 +358,7 @@ sub fetchTests
 	close($handle);
 	my $t = "";
 
-	$m =~ s/\\[\r\n]*//gs;
+	$m =~ s{\\\r?\n}{}g;
 	if ($m =~ /^REGRESS\s*=\s*(.*)$/gm)
 	{
 		$t = $1;
-- 
2.50.0