Skip to content

Commit 837059c

Browse files
author
rblazek
committed
force binary mode for stdout
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12896 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent a1b22f5 commit 837059c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ static int cell_draw(char *name,
116116
void *ptr;
117117
int big_endian;
118118
long one= 1;
119+
FILE *fo;
119120

120121
big_endian = !(*((char *)(&one)));
121122

@@ -132,6 +133,10 @@ static int cell_draw(char *name,
132133
grn = G_malloc(ncols);
133134
blu = G_malloc(ncols);
134135
set = G_malloc(ncols);
136+
137+
/* some buggy C libraries require BOTH setmode() and fdopen(bin) ? */
138+
//setmode(fileno(stdin), O_BINARY);
139+
fo = fdopen (fileno(stdout), "wb");
135140

136141
/* loop for array rows */
137142
for ( row = 0; row < nrows; row++ ) {
@@ -155,9 +160,9 @@ static int cell_draw(char *name,
155160
// consider byte order (well, middle endian ignored)
156161
if ( big_endian ) {
157162
// I have never tested this
158-
fprintf(stdout, "%c%c%c%c", alpha, red[i],grn[i],blu[i]);
163+
fprintf(fo, "%c%c%c%c", alpha, red[i],grn[i],blu[i]);
159164
} else {
160-
fprintf(stdout, "%c%c%c%c", blu[i],grn[i],red[i],alpha);
165+
fprintf(fo, "%c%c%c%c", blu[i],grn[i],red[i],alpha);
161166
}
162167
}
163168
}

0 commit comments

Comments
 (0)