Subject: [PATCH 08/14] checkbashisms: handle line continuations

From: Raphael Geissert <[email-masked]>
Date: Wed, 12 May 2010 15:51:21 -0500

Closes: #531327

Signed-off-by: Raphael Geissert <[email-masked]>
---
 scripts/checkbashisms.pl |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/scripts/checkbashisms.pl b/scripts/checkbashisms.pl
index 1117a9c..5b5a34c 100755
--- a/scripts/checkbashisms.pl
+++ b/scripts/checkbashisms.pl
@@ -105,6 +105,7 @@ foreach my $filename (@ARGV) {
     my $last_continued = 0;
     my $continued = 0;
     my $found_rules = 0;
+    my $buffered_line = "";
 
     while (<C>) {
 	next unless ($check_lines_count == -1 or $. <= $check_lines_count);
@@ -170,6 +171,18 @@ foreach my $filename (@ARGV) {
 	    $_ = $orig_line;
 	}
 
+	# Handle line continuation
+	if (!$makefile && $cat_string eq '' && m/\\$/) {
+	    chop;
+	    $buffered_line .= $_;
+	    next;
+	}
+
+	if ($buffered_line ne '') {
+	    $_ = $buffered_line . $_;
+	    $buffered_line ='';
+	}
+
 	if ($makefile) {
 	    $last_continued = $continued;
 	    if (/[^\\]\\$/) {
-- 
1.7.1