]> xenbits.xensource.com Git - libvirt.git/commitdiff
test-wrap-argv: hold a copy of the original file in an array
authorJán Tomko <jtomko@redhat.com>
Wed, 15 Jun 2016 11:04:52 +0000 (13:04 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 21 Jun 2016 16:13:07 +0000 (18:13 +0200)
This will be useful to check if the file is wrapped already.

tests/test-wrap-argv.pl

index 1f619cc7b08b8cb15ce1a53d851e667ca4ded3aa..96f998a09549bd27436289775a162c62651da57b 100755 (executable)
@@ -33,15 +33,15 @@ sub rewrap {
 
     # Read the original file
     open FILE, "<", $file or die "cannot read $file: $!";
-    my @lines;
-    while (<FILE>) {
+    my @orig_lines = <FILE>;
+    close FILE;
+    my @lines = @orig_lines;
+    foreach (@lines) {
         # If there is a trailing '\' then kill the new line
         if (/\\$/) {
             chomp;
             $_ =~ s/\\$//;
         }
-
-        push @lines, $_;
     }
 
     # Skip empty files
@@ -49,7 +49,6 @@ sub rewrap {
 
     # Kill the last new line in the file
     chomp @lines[$#lines];
-    close FILE;
 
     # Reconstruct the master data by joining all lines
     # and then split again based on the real desired