Re: [PATCH (incomplete)] Make regcomp use SV* sv, instead of char* exp, char* xend
[p5sagit/p5-mst-13.2.git] / uupacktool.pl
index 5656cef..20554d7 100644 (file)
@@ -5,6 +5,8 @@ use warnings;
 use Getopt::Long;
 use File::Basename;
 
+Getopt::Long::Configure('no_ignore_case');
+
 our $LastUpdate = -M $0;
 
 sub handle_file {
@@ -14,7 +16,7 @@ sub handle_file {
     my $mode    = (stat($file))[2] & 07777;
 
     open my $fh, "<", $file
-        or die "Could not open input file $file: $!";
+        or do { warn "Could not open input file $file: $!"; exit 0 };
     binmode $fh;
     my $str = do { local $/; <$fh> };
 
@@ -27,7 +29,7 @@ sub handle_file {
         }
         my ($head, $body) = split /__UU__\n/, $str;
         die "Can't unpack malformed data in '$file'\n"
-            if !$head or !$body;
+            if !$head;
         $outstr = unpack 'u', $body;
 
     } else {
@@ -60,9 +62,10 @@ EOFBLURB
     } else {
         print "Writing $file into $outfile\n" if $opts->{'v'};
         open my $outfh, ">", $outfile
-            or die "Could not open $outfile for writing: $!";
+            or do { warn "Could not open $outfile for writing: $!"; exit 0 };
         binmode $outfh;
-        print $outfh $outstr;
+        ### $outstr might be empty, if the file was empty
+        print $outfh $outstr if $outstr;
         close $outfh;
 
         chmod $mode, $outfile;
@@ -156,7 +159,7 @@ Options:
 }
 
 my $opts = {};
-GetOptions($opts,'u','p','c','m:s','s','d=s','v','h');
+GetOptions($opts,'u','p','c', 'D', 'm:s','s','d=s','v','h');
 
 die "Can't pack and unpack at the same time!\n", usage()
     if $opts->{'u'} && $opts->{'p'};