From c4c271f1e40a090a3fdbee286a219502d68b8592 Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Thu, 7 Oct 2004 17:33:29 +0000 Subject: [PATCH] The generated patch was missing a line of the diff. genpatch was also depending on the new files being listed first by 'cvs diff' (which is the case but I'm not sure there is any hard guarantee). Use 'perl -w' for more checking, fix the resulting 'undefined value' warnings. In many cases we don't just want $options{xxx} to exist, we want it to be defined. Restrict the scope of variables and remove unneeded variables. --- tools/genpatch | 60 +++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/tools/genpatch b/tools/genpatch index 6d430c3c18..b241889bab 100755 --- a/tools/genpatch +++ b/tools/genpatch @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w # # genpatch - A utility that generates patches for submission to # wine-patches@winehq.org @@ -66,18 +66,13 @@ use Getopt::Std; use File::Basename; use POSIX qw(strftime); -my $gen_date; # date the patch was generated -my %options; # command line options -my @modified_files; # optional list of files that were modified -my @added_files; # added files as an array -my $added_file; # added file being considered -my $cvs_line; # line of output from CVS -my $mod_files_str; # string that describes the modified files +# Command line options +my %options; # Default the patch name to the UTC time. Use a more descriptive date for the # patch generation date. $options{n} = strftime "%Y%m%d%H%M", gmtime; -$gen_date = strftime "%Y/%m/%d %H:%M:%S UTC", gmtime; +my $gen_date = strftime "%Y/%m/%d %H:%M:%S UTC", gmtime; unless(getopts("vn:f:c:m:a:p:", \%options)) { @@ -86,28 +81,27 @@ unless(getopts("vn:f:c:m:a:p:", \%options)) exit 1; } -$options{p} = "patches" unless(exists $options{p}); -$options{f} = "$options{p}/$options{n}.diff" unless(exists $options{f}); +$options{p} = "patches" if (!defined $options{p}); +$options{f} = "$options{p}/$options{n}.diff" if (!defined $options{f}); $options{p} = dirname $options{f}; -@added_files = split ' ', $options{a}; -@modified_files = split ' ', $options{m}; +$options{a} = "" if (!defined $options{a}); +my @added_files = split ' ', $options{a}; +$options{m} = "" if (!defined $options{m}); +$options{c} = "" if (!defined $options{c}); $options{c} =~ s/\\n/\n\t/g; -if(-d $options{p}) +if (!-d $options{p}) { - if(-e $options{f}) - { - print STDERR "$options{f} already exists. Aborting.\n"; - exit 1; - } + mkdir $options{p}, (0777 & ~umask) + or die "Unable to mkdir $options{p}: $!"; } -else +elsif (-e $options{f}) { - mkdir $options{p}, (0777 & ~umask) or - die "Unable to mkdir $options{p}: $!"; + print STDERR "$options{f} already exists. Aborting.\n"; + exit 1; } -$mod_files_str = exists($options{m}) ? $options{m} : ""; +my $mod_files_str = $options{m} ? $options{m} : ""; print "Generating $options{f}.\n" if($options{v}); open OPT_F, ">$options{f}" or die "Unable to open $options{f} for write: $!"; print OPT_F <) +open CVS_IN, "cvs diff -u $options{m} |" +or die "Unable to invoke cvs: $!"; +while (my $cvs_line = ) { - chomp $cvs_line; - if($cvs_line =~ /^\? (.*)/) + if ($cvs_line !~ /^\? (.*)/) { - push @added_files, $1 unless(exists $options{a}); + print OPT_F $cvs_line; } - else + elsif (!$options{a}) { - print OPT_F ; + push @added_files, chomp $1; } } close CVS_IN; -foreach $added_file (@added_files) +foreach my $added_file (@added_files) { print "Adding $added_file as a new file.\n" if($options{v}); - open DIFF_IN, "diff -u /dev/null $added_file|" or die "Unable to " . - "invoke diff: $!"; + open DIFF_IN, "diff -u /dev/null $added_file|" + or die "Unable to invoke diff: $!"; print OPT_F ; close DIFF_IN; } -- 2.32.0.93.g670b81a890