Fixed "white-spaces" in licence text issue in convert_to_eula.pl
authorChetan Kapoor <chetank@symbian.org>
Tue, 06 Oct 2009 17:09:32 +0100
changeset 88 d22c49c5048f
parent 79 ce6215be051a
child 89 670d944088a7
Fixed "white-spaces" in licence text issue in convert_to_eula.pl
williamr/convert_to_eula.pl
--- a/williamr/convert_to_eula.pl	Wed Sep 23 17:41:26 2009 +0100
+++ b/williamr/convert_to_eula.pl	Tue Oct 06 17:09:32 2009 +0100
@@ -58,15 +58,28 @@
         push @newlines, $line;
         next;
         }
-      my $midline = shift @lines;
-      my $urlline = shift @lines;
+	  my @midlines = ();
+      my $nextline;
+	  my $midlinecount = 1;
+	  while ($nextline = shift @lines)
+		{
+		if ($nextline !~ /^\s$/)
+		  {
+		  # non-blank line
+		  last if ($midlinecount == 0);
+		  $midlinecount -= 1;
+		  # keep going
+		  }
+		push @midlines, $nextline;
+		}
+      my $urlline = $nextline;
       my $pos2 = index $urlline, $oldtext[1];
       if ($pos2 >= 0)
         {
         # Found it - assume that there's only one instance
         substr $line, $pos1, length($oldtext[0]), $newtext[0];
         substr $urlline, $pos2, length($oldtext[1]), $newtext[1];
-        push @newlines, $line, $midline, $urlline;
+        push @newlines, $line, @midlines, $urlline;
         $updated += 1;
         next;
         }
@@ -75,7 +88,7 @@
         if(!$updated)
           {
           my $lineno = 1 + (scalar @newlines);
-          print STDERR "Problem in $file at $lineno: incorrectly formatted >\n$line$midline$urlline\n";
+          print STDERR "Problem in $file at $lineno: incorrectly formatted >\n$line", join("",@midlines), "$urlline\n";
           push @errorfiles, $file;
           }	
         last;