r53321 - /trunk/dh-make-perl/lib/DhMakePerl.pm

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Wed Feb 24 20:15:11 UTC 2010


Author: dmn
Date: Wed Feb 24 20:14:59 2010
New Revision: 53321

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=53321
Log:
drop_quilt(): improve avoiding extra empty lines when removing targets

bikeshed++

Modified:
    trunk/dh-make-perl/lib/DhMakePerl.pm

Modified: trunk/dh-make-perl/lib/DhMakePerl.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/DhMakePerl.pm?rev=53321&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/DhMakePerl.pm (original)
+++ trunk/dh-make-perl/lib/DhMakePerl.pm Wed Feb 24 20:14:59 2010
@@ -1393,9 +1393,17 @@
 
     # look for the quilt include line and remove it and the previous empty one
     for( my $i = 1; $i < @rules; $i++ ) {
-        if ( $rules[$i] eq ''
-                and $rules[$i+1] eq 'include /usr/share/quilt/quilt.make' ) {
-            splice @rules, $i, 2;
+        if ( $rules[$i] eq 'include /usr/share/quilt/quilt.make' ) {
+            splice @rules, $i, 1;
+
+            # collapse two sequencial empty lines
+            # NOTE: this won't work if the include statement was the last line
+            # in the rules, but this is highly unlikely
+            splice( @rules, $i, 1 )
+                if $i < @rules
+                    and $rules[$i] eq ''
+                    and $rules[ $i - 1 ] eq '';
+
             last;
         }
     }
@@ -1434,10 +1442,15 @@
             splice @rules, $i, 2;
 
             # At this point there may be an extra empty line left.
-            # There may also be no empty line, if the clean override
-            # was at the end of the file
-            splice( @rules, $i, 1 )
-                if $#rules >= $i and $rules[$i] eq '';
+            # Remove an empty line after the removed target
+            # Or any trailing empty line (if the target was at EOF)
+            if ( $i > $#rules ) {
+                $#rules-- if $rules[-1] eq '';    # trim trailing empty line
+            }
+            elsif ( $rules[$i] eq '' ) {
+                splice( @rules, $i, 1 );
+            }
+
             last;
         }
     }




More information about the Pkg-perl-cvs-commits mailing list