Cleanup a bit the environment handling around the testsuite.

Upstream status: Submitted 060427

---
 Makefile.in |    9 +--------
 test/run    |   20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 8 deletions(-)

Index: b/test/run
===================================================================
--- a/test/run
+++ b/test/run
@@ -62,6 +62,26 @@
 my $lineno;
 my $width = ($ENV{COLUMNS} || 80) >> 1;
 
+# cleanup the environment
+map { 
+  undef $ENV{$_} if defined($ENV{$_}); 
+} qw(QUILT_PATCHES QUILT_PC LANG LC_MESSAGES LC_CTYPE LC_ALL LANGUAGE);
+
+$ENV{'LC_ALL'} = 'C';
+open RC,"test.quiltrc" || die "cannot read RC file: $?\n";
+while (<RC>) {
+    s/#.*$//;
+    if (m/^([^=]*)=(.*)$/) {
+	$ENV{$1}=$2;
+    }
+}
+
+if (defined($ENV{'QUILT_PATCHES_PREFIX'}) && length($ENV{'QUILT_PATCHES_PREFIX'})) {
+    $ENV{'P'}='patches/';
+    $ENV{'_P'}='../patches/';
+}
+
+# Run the tests
 for (;;) {
   my $line = <>; $lineno++;
   if (defined $line) {
Index: b/Makefile.in
===================================================================
--- a/Makefile.in
+++ b/Makefile.in
@@ -383,10 +383,6 @@
 	    -e 's:quilt/setup:quilt/setup quilt/scripts/inspect:' \
 	  > $@
 
-ifneq ($(shell . $(QUILTRC) ;  echo $$QUILT_PATCHES_PREFIX),)
-CHECK_ENV := P=patches/; _P=../patches/; export P _P
-endif
-
 # Each tests dependencies are stored in test/.depend
 ifneq ($(findstring check-,$(MAKECMDGOALS)),)
 test/.%.ok : test/%.test FORCE
@@ -394,10 +390,7 @@
 test/.%.ok : test/%.test
 endif
 	@echo "[$(<F)]"
-	@LANG=C; LC_ALL=C;						\
-	export LANG LC_ALL;						\
-	$(CHECK_ENV);							\
-	cd $(@D);							\
+	@cd $(@D);							\
 	./run $(<F)
 	@touch $@
 
