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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Feb 7 16:02:26 EST 2010


Author: rblazek
Date: 2010-02-07 16:02:25 -0500 (Sun, 07 Feb 2010)
New Revision: 12896

Modified:
   trunk/qgis/src/providers/grass/qgis.d.rast.c
Log:
force binary mode for stdout

Modified: trunk/qgis/src/providers/grass/qgis.d.rast.c
===================================================================
--- trunk/qgis/src/providers/grass/qgis.d.rast.c	2010-02-07 18:57:36 UTC (rev 12895)
+++ trunk/qgis/src/providers/grass/qgis.d.rast.c	2010-02-07 21:02:25 UTC (rev 12896)
@@ -116,6 +116,7 @@
     void *ptr;
     int big_endian;
     long one= 1;
+    FILE *fo;
 
     big_endian = !(*((char *)(&one)));
 
@@ -132,6 +133,10 @@
     grn = G_malloc(ncols);
     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");
     
     /* loop for array rows */
     for ( row = 0; row < nrows; row++ ) {
@@ -155,9 +160,9 @@
             // consider byte order (well, middle endian ignored)
             if ( big_endian ) {
                 // I have never tested this 
-                fprintf(stdout, "%c%c%c%c", alpha, red[i],grn[i],blu[i]);
+                fprintf(fo, "%c%c%c%c", alpha, red[i],grn[i],blu[i]);
             } else {
-                fprintf(stdout, "%c%c%c%c", blu[i],grn[i],red[i],alpha);
+                fprintf(fo, "%c%c%c%c", blu[i],grn[i],red[i],alpha);
             }
         }
     }



More information about the QGIS-commit mailing list