Skip to content

Commit 7df3c9c

Browse files
author
rblazek
committed
another attempt to set stdout binary mode on win
git-svn-id: http://svn.osgeo.org/qgis/trunk@12906 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f4c042d commit 7df3c9c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/providers/grass/qgis.d.rast.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#include <stdlib.h>
1414
#include <stdio.h>
1515
#include <string.h>
16+
#ifdef WIN32
17+
#include <fcntl.h>
18+
#include <io.h>
19+
#endif
1620
#include <grass/gis.h>
1721
#include <grass/raster.h>
1822
#include <grass/display.h>
@@ -131,10 +135,14 @@ static int cell_draw( char *name,
131135
blu = G_malloc( ncols );
132136
set = G_malloc( ncols );
133137

134-
/* some buggy C libraries require BOTH setmode() and fdopen(bin) ? */
135-
//setmode(fileno(stdin), O_BINARY);
136-
fo = fdopen( fileno( stdout ), "wb" );
137-
138+
/* some buggy C libraries require BOTH setmode() and fdopen(bin) */
139+
#ifdef WIN32
140+
if ( _setmode( _fileno( stdout ), _O_BINARY ) == -1 )
141+
G_fatal_error( "Cannot set stdout mode" );
142+
#endif
143+
// Unfortunately this is not sufficient on Windows to switch stdout to binary mode
144+
fo = fdopen (fileno(stdout), "wb");
145+
138146
/* loop for array rows */
139147
for ( row = 0; row < nrows; row++ )
140148
{

0 commit comments

Comments
 (0)