[QGIS Commit] r12906 - trunk/qgis/src/providers/grass

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Feb 9 09:07:12 EST 2010


Author: rblazek
Date: 2010-02-09 09:07:12 -0500 (Tue, 09 Feb 2010)
New Revision: 12906

Modified:
   trunk/qgis/src/providers/grass/qgis.d.rast.c
Log:
another attempt to set stdout binary mode on win

Modified: trunk/qgis/src/providers/grass/qgis.d.rast.c
===================================================================
--- trunk/qgis/src/providers/grass/qgis.d.rast.c	2010-02-09 13:14:53 UTC (rev 12905)
+++ trunk/qgis/src/providers/grass/qgis.d.rast.c	2010-02-09 14:07:12 UTC (rev 12906)
@@ -13,6 +13,10 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifdef WIN32
+#include <fcntl.h>
+#include <io.h>
+#endif
 #include <grass/gis.h>
 #include <grass/raster.h>
 #include <grass/display.h>
@@ -131,10 +135,14 @@
   blu = G_malloc( ncols );
   set = G_malloc( ncols );
 
-  /* some buggy C libraries require BOTH setmode() and fdopen(bin) ? */
-  //setmode(fileno(stdin), O_BINARY);
-  fo = fdopen( fileno( stdout ), "wb" );
-
+  /* some buggy C libraries require BOTH setmode() and fdopen(bin) */
+#ifdef WIN32
+  if ( _setmode( _fileno( stdout ), _O_BINARY ) == -1 )
+      G_fatal_error( "Cannot set stdout mode" );
+#endif
+  // Unfortunately this is not sufficient on Windows to switch stdout to binary mode
+  fo = fdopen (fileno(stdout), "wb");
+    
   /* loop for array rows */
   for ( row = 0; row < nrows; row++ )
   {



More information about the QGIS-commit mailing list