[Libreoffice-commits] .: solenv/gbuild

Jan Holesovsky kendy at kemper.freedesktop.org
Fri Mar 30 04:46:33 PDT 2012


 solenv/gbuild/filter-showIncludes.pl |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

New commits:
commit 3cf66a899ec1c8eed3a95b7f08824d5c8db0d0a8
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Fri Mar 30 13:44:33 2012 +0200

    filter-showIncludes.pl: Attempt to prevent creating incomplete .d files.

diff --git a/solenv/gbuild/filter-showIncludes.pl b/solenv/gbuild/filter-showIncludes.pl
index ee9a34b..d7082a2 100755
--- a/solenv/gbuild/filter-showIncludes.pl
+++ b/solenv/gbuild/filter-showIncludes.pl
@@ -13,6 +13,10 @@
 #
 # Original author: Jan Holesovsky <kendy at suse.cz>
 
+use File::Basename;
+use File::Copy;
+use File::Temp qw/tempfile/;
+
 my $outfile = $ARGV[0];
 my $objfile = $ARGV[1];
 my $srcfile = $ARGV[2];
@@ -25,8 +29,9 @@ if ( !defined( $showincludes_prefix ) || $showincludes_prefix eq "" ) {
     $showincludes_prefix = 'Note: including file:';
 }
 
-open( OUT, "> $outfile" ) or die "Cannot open $outfile for writing.";
-print OUT "$objfile: \\\n $srcfile";
+my ($OUT, $tmp_filename) = tempfile( 'showIncludesXXXXXX', DIR => dirname( $outfile ) ) or die "Cannot create a temp file.";
+
+print $OUT "$objfile: \\\n $srcfile";
 
 my %seen;
 my $first_line = 1;
@@ -45,7 +50,7 @@ while ( <STDIN> ) {
 
         if ( !defined $seen{$_} ) {
             $seen{$_} = 1;
-            print OUT " \\\n  $_";
+            print $OUT " \\\n  $_";
         }
     }
     else {
@@ -56,7 +61,7 @@ while ( <STDIN> ) {
     $first_line = 0;
 }
 
-print OUT "\n";
+print $OUT "\n";
 
 # fdo#40099 if header.h does not exist, it will simply be considered out of
 # date and any targets that use it as a prerequisite will be updated,
@@ -64,9 +69,11 @@ print OUT "\n";
 # as an include
 # see http://www.makelinux.net/make3/make3-CHP-8-SECT-3
 foreach my $key ( keys %seen ) {
-  print OUT "\n$key:\n";
+  print $OUT "\n$key:\n";
 }
 
-close( OUT ) or die "Cannot close $outfile.";
+close( $OUT ) or die "Cannot close $tmp_filename.";
+
+move( $tmp_filename, $outfile ) or die "Cannot move $tmp_filename to $outfile.";
 
 # vim: shiftwidth=4 softtabstop=4 expandtab:


More information about the Libreoffice-commits mailing list