Index: ccc-analyzer
===================================================================
--- ccc-analyzer	(revision 168392)
+++ ccc-analyzer	(working copy)
@@ -20,6 +20,7 @@
 use File::Path qw / mkpath /;
 use File::Basename;
 use Text::ParseWords;
+use English qw/OSNAME/ ;
 
 ##===----------------------------------------------------------------------===##
 # Compiler command setup.
@@ -31,11 +32,11 @@
 my $DefaultCXXCompiler;
 
 if (`uname -a` =~ m/Darwin/) { 
-	$DefaultCCompiler = 'clang';
-	$DefaultCXXCompiler = 'clang++'; 
+  $DefaultCCompiler = 'clang';
+  $DefaultCXXCompiler = 'clang++'; 
 } else {
-    $DefaultCCompiler = 'gcc';
-    $DefaultCXXCompiler = 'g++'; 	
+  $DefaultCCompiler = 'gcc';
+  $DefaultCXXCompiler = 'g++';
 }
 
 if ($FindBin::Script =~ /c\+\+-analyzer/) {
@@ -252,6 +253,7 @@
     print $ofh $_;
     print STDERR $_;
   }
+  close $ofh || die "close of '$HtmlDir/clang_output_XXXXXX' failed\n" ;
 
   waitpid($pid,0);
   close(FROM_CHILD);
@@ -269,7 +271,7 @@
                             $HtmlDir, $ParserRejects, $ofile);
       } else {
         ProcessClangFailure($Clang, $Lang, $file, \@CmdArgsSansAnalyses,
-                            $HtmlDir, $OtherError, $ofile);      	
+                            $HtmlDir, $OtherError, $ofile);
       }
     }
     else {
@@ -396,6 +398,19 @@
   'mm'  => 'objective-c++'
 );
 
+# match either MSWin32 or cygwin (and perhaps MSWin64?)
+my $amWindows = ( $OSNAME =~ /win/i ) ? 1 : 0 ;
+
+#
+# don't assume a case sensitive file system on Windows (using a .C (capital-C)
+# suffix for C++ code that will also be compiled on Windows is a bad idea,
+# even if some build systems can be coersed into doing it right).
+#
+unless ( $amWindows )
+{
+  $LangMap{'C'} = 'c++' ;
+}
+
 my %UniqueOptions = (
   '-isysroot' => 0  
 );
@@ -617,7 +632,7 @@
   my @Archs = keys %ArchsSeen;
   # Skip the file if we don't support the architectures specified.
   exit 0 if ($HadArch && scalar(@Archs) == 0);
-  
+
   foreach my $file (@Files) {
     # Determine the language for the file.
     my $FileLang = $Lang;
@@ -671,7 +686,7 @@
         $ResultFile = $f;
         # If the HtmlDir is not set, we sould clean up the plist files.
         if (!defined $HtmlDir || -z $HtmlDir) {
-        	$CleanupFile = $f; 
+          $CleanupFile = $f; 
         }
       }
     }
