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

Bug#495176: lintian: false positive: incorrect handling of continuation lines in scripts



package lintian
tags 495176 patch
thanks

* Shachar Shemesh <shachar@debian.org> [2008-08-15 08:47]:

> In order to solve this, lintian needs to do a more complete parsing of
> the lines before passing them on to the rules. I would suggest
> concatanating all the lines that are continuation lines into one string,
> and only then passing them on to the rules.

Attached below is a simple patch to fix the bug.

Cheers,

-- 
Rafael
--- scripts-svn	2008-09-11 15:42:57.000000000 +0200
+++ scripts-new 2008-09-11 16:03:45.000000000 +0200
@@ -470,7 +470,18 @@
     my $cat_string = "";
     my $LEADIN = qr'(?:(?:^|[`&;(|{])\s*|(?:if|then|do|while)\s+)';
 
+    my $previous_line = "";
     while (<C>) {
+	# Concatenate lines containing continuation character (\) at the end
+	if (/\\$/) {
+	    s/\\//;
+	    chomp();
+	    $previous_line .= $_;
+	    next;
+	} else {
+	    $_ = $previous_line . $_;
+	    $previous_line = "";
+	}
 	next if m,^\s*$,;  # skip empty lines
 	next if m,^\s*\#,; # skip comment lines
 	s/\#.*$//;         # eat comments

Reply to: