From 400a9ba2a541709f8f9293a610e73e465fe1cd67 Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Fri, 20 Oct 2000 23:14:12 +0000 Subject: [PATCH] Add error handling to die if the input file cannot be read. Also detabbed the file. r=cls git-svn-id: svn://10.0.0.236/trunk@81541 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/config/mozBDate.pm | 72 +++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/mozilla/config/mozBDate.pm b/mozilla/config/mozBDate.pm index 6e279286e27..5bdd36ac19a 100755 --- a/mozilla/config/mozBDate.pm +++ b/mozilla/config/mozBDate.pm @@ -56,27 +56,27 @@ sub UpdateBuildNumber($$) { my $build_number = sprintf("%04d%02d%02d%02d", $year, 1+$mon, $mday, $hour); if ("$outfile" eq "") { - print "$build_number\n"; - return; + print "$build_number\n"; + return; } if ($official) { - &write_number($outfile, $build_number); + &write_number($outfile, $build_number); } else { - my $old_num = -1; - - # Only overwrite file if contents are not already set to 0 - if ( -e $outfile ) { - open(OLD, "<$outfile") || die "$outfile: $!\n"; - $old_num = ; - chomp($old_num); - close(OLD); - } - - if ($old_num != 0) { - &write_number($outfile, "0000000000"); - } + my $old_num = -1; + + # Only overwrite file if contents are not already set to 0 + if ( -e $outfile ) { + open(OLD, "<$outfile") || die "$outfile: $!\n"; + $old_num = ; + chomp($old_num); + close(OLD); + } + + if ($old_num != 0) { + &write_number($outfile, "0000000000"); + } } return; } @@ -86,36 +86,36 @@ sub SubstituteBuildNumber($$$) { my ($outfile, $build_num, $infile) = @_; my $INFILE = new IO::File; my $OUTFILE = new IO::File; - + open $INFILE, "<$build_num"; my $build = <$INFILE>; close $INFILE; chomp $build; - if ("$infile" ne "") { - open $INFILE, "<$infile" || die; + if ($infile ne "") { + open($INFILE, "< $infile") || die "$infile: $!\n"; } else { - open $INFILE, "<$outfile" || die; + open($INFILE, "< $outfile") || die "$outfile: $!\n"; } open $OUTFILE, ">${outfile}.old" || die; while (<$INFILE>) { - - my $id = $_; - my $temp; - if ($id =~ "Build ID:") { - $temp = "Build ID: " . $build; - $id =~ s/Build ID:\s\d+/$temp/; - print $OUTFILE $id; - } - elsif ($id =~ "NS_BUILD_ID") { - $temp = "NS_BUILD_ID " . $build; - $id =~ s/NS_BUILD_ID\s\d+/$temp/; - print $OUTFILE $id; - } - else { - print $OUTFILE $_; - } + + my $id = $_; + my $temp; + if ($id =~ "Build ID:") { + $temp = "Build ID: " . $build; + $id =~ s/Build ID:\s\d+/$temp/; + print $OUTFILE $id; + } + elsif ($id =~ "NS_BUILD_ID") { + $temp = "NS_BUILD_ID " . $build; + $id =~ s/NS_BUILD_ID\s\d+/$temp/; + print $OUTFILE $id; + } + else { + print $OUTFILE $_; + } } close $INFILE;