[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#637595: lintian: please use LC_ALL instead of LANG



Package: lintian
Version: 2.5.2
Tags: patch

In a few places, lintian sets the LANG variable to force a particular locale. This is incorrect, as LANG determines the locale only "in the absence of the LC_ALL and other LC_* (LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, LC_TIME) environment variables."[0] The LC_ALL variable should be used instead.

The attached patch should fix this problem. (I'm not sure what was the purpose of setting LANG=en_US.UTF-8 and LC_CTYPE=C in private/runtests, but apparently using LC_ALL=C there doesn't break anything.)


[0] http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html#tag_002_002

--
Jakub Wilk
# HG changeset patch
# Parent afd9713258f4a63cbd123dbbe544a4216f2cf28d
diff --git a/checks/infofiles b/checks/infofiles
--- a/checks/infofiles
+++ b/checks/infofiles
@@ -89,7 +89,7 @@
 	    fail("cannot fork: $!");
 	} elsif ($pid == 0) {
 	    my $f = quotemeta($info->unpacked($file));
-	    my %newenv = (LANG => 'C', PATH => $ENV{PATH},
+	    my %newenv = (LC_ALL => 'C', PATH => $ENV{PATH},
 			  LOCPATH => $ENV{LOCPATH});
 	    undef %ENV;
 	    %ENV = %newenv;
diff --git a/checks/manpages b/checks/manpages
--- a/checks/manpages
+++ b/checks/manpages
@@ -218,7 +218,7 @@
 	    if (not defined $pid) {
 		fail("cannot run lexgrog: $!");
 	    } elsif ($pid == 0) {
-		my %newenv = (LANG => 'en_US.UTF-8', PATH => $ENV{PATH},
+		my %newenv = (LC_ALL => 'en_US.UTF-8', PATH => $ENV{PATH},
 			      LOCPATH => $ENV{LOCPATH});
 		undef %ENV;
 		%ENV = %newenv;
@@ -252,7 +252,7 @@
 	if (not defined $pid) {
 	    fail("cannot run man -E UTF-8 -l: $!");
 	} elsif ($pid == 0) {
-	    my %newenv = (LANG => 'en_US.UTF-8', PATH => $ENV{PATH},
+	    my %newenv = (LC_ALL => 'en_US.UTF-8', PATH => $ENV{PATH},
 			  MANWIDTH => 80, LOCPATH => $ENV{LOCPATH});
 	    undef %ENV;
 	    %ENV = %newenv;
diff --git a/checks/manpages.desc b/checks/manpages.desc
--- a/checks/manpages.desc
+++ b/checks/manpages.desc
@@ -174,7 +174,7 @@
  "Debugging" in the groff manual.
  .
  To test this for yourself you can use the following command:
-  LANG=en_US.UTF-8 MANWIDTH=80 man --warnings -E UTF-8 -l <file> >/dev/null
+  LC_ALL=en_US.UTF-8 MANWIDTH=80 man --warnings -E UTF-8 -l <file> >/dev/null
 
 Tag: manpage-has-errors-from-pod2man
 Severity: normal
diff --git a/checks/po-debconf b/checks/po-debconf
--- a/checks/po-debconf
+++ b/checks/po-debconf
@@ -170,7 +170,7 @@
 	system_env("msgfmt -o /dev/null \Q$debfiles/po/$file\E 2>/dev/null") == 0
 		or tag 'invalid-po-file', "debian/po/$file";
 
-	my $stats = `LANG=C msgfmt -o /dev/null --statistics \Q$debfiles/po/$file\E 2>&1`;
+	my $stats = `LC_ALL=C msgfmt -o /dev/null --statistics \Q$debfiles/po/$file\E 2>&1`;
 	if (!$full_translation && $stats =~ m/^\w+ \w+ \w+\.$/) {
 		$full_translation = 1;
 	}
diff --git a/debian/rules b/debian/rules
--- a/debian/rules
+++ b/debian/rules
@@ -61,8 +61,8 @@
 build-stamp: $(neededfiles) $(docsource) $(testtarget)
 	@echo .... running build ....
 	dh_testdir
-	cd doc && LANG=C docbook2html  -V "%use-id-as-filename%" -o lintian.html lintian.xml
-	cd doc && LANG=C jw -b txt lintian.xml
+	cd doc && LC_ALL=C docbook2html  -V "%use-id-as-filename%" -o lintian.html lintian.xml
+	cd doc && LC_ALL=C jw -b txt lintian.xml
 	mkdir man/man1/
 	private/generate-lintian-pod | \
 		pod2man --name lintian --center "Debian Package Checker" --section=1 > man/man1/lintian.1
diff --git a/lib/Util.pm b/lib/Util.pm
--- a/lib/Util.pm
+++ b/lib/Util.pm
@@ -235,7 +235,7 @@
 	my ($file, $type, $pkg) = @_;
 	my $non_utf8 = 0;
 
-	open (ICONV, '-|', "env LANG=C iconv -f utf8 -t utf8 \Q$file\E 2>&1")
+	open (ICONV, '-|', "env LC_ALL=C iconv -f utf8 -t utf8 \Q$file\E 2>&1")
 	    or fail("failure while checking encoding of $file for $type package $pkg");
 	my $line = 1;
 	while (<ICONV>) {
diff --git a/private/refresh-archs b/private/refresh-archs
--- a/private/refresh-archs
+++ b/private/refresh-archs
@@ -26,7 +26,7 @@
     exit 0
 fi
 
-export LANG=C
+export LC_ALL=C
 
 dpkg_version="$(dpkg-architecture --version | head -n1)"
 
diff --git a/private/refresh-locale-codes b/private/refresh-locale-codes
--- a/private/refresh-locale-codes
+++ b/private/refresh-locale-codes
@@ -54,7 +54,7 @@
 
 EOF
 
-export LANG=C
+export LC_ALL=C
 
 {
     isoquery -i 639
diff --git a/private/runtests b/private/runtests
--- a/private/runtests
+++ b/private/runtests
@@ -15,8 +15,7 @@
     TAG=yes
 fi
 
-LANG="en_US.UTF-8"
-LC_COLLATE="C"
+LC_ALL=C
 LINTIAN_ROOT=""
 LINTIAN_PROFILE=debian
 LINTIAN_INTERNAL_TESTSUITE=1
@@ -25,8 +24,7 @@
 
 [ "$TEST_WORK_DIR" ] || TEST_WORK_DIR="debian/test-out"
 
-export LANG
-export LC_COLLCATE
+export LC_ALL
 export LINTIAN_ROOT
 export LINTIAN_PROFILE
 export LINTIAN_INTERNAL_TESTSUITE

Reply to: