From e1c4ed3b37ccc1e3bb3a38c863f9caacc2acc398 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Thu, 8 Sep 2011 07:27:24 +0000 Subject: [PATCH] Revert binary mode for popen Unlike fopen, popen only supports "r" and "w" --- src/gzip.c | 4 ++-- src/image_gen.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gzip.c b/src/gzip.c index 8a34fa4..9c2ef31 100644 --- a/src/gzip.c +++ b/src/gzip.c @@ -81,7 +81,7 @@ FILE *uncompress_pipe (FILE *fp) return NULL; } - fpipe = popen("gzip -q -d -f --stdout", "rb"); + fpipe = popen("gzip -q -d -f --stdout", "r"); if (fpipe == NULL) perror("uncompress_pipe"); close(0); if (dup(save_fd) < 0) { @@ -108,7 +108,7 @@ FILE *compress_pipe (FILE *fp) return NULL; } - fpipe = popen("gzip -q -1 -c", "wb"); + fpipe = popen("gzip -q -1 -c", "w"); if (fpipe == NULL) perror("compress_pipe"); close(1); if (dup(save_fd) < 0) { diff --git a/src/image_gen.c b/src/image_gen.c index 3c69b7b..f5e7971 100644 --- a/src/image_gen.c +++ b/src/image_gen.c @@ -522,7 +522,7 @@ void RSL_write_gif(char *outfile, unsigned char *image, int xdim, int ydim, char fpipe = NULL; nbytes = xdim*ydim; (void)sprintf(pipecmd, "ppmtogif > %s 2>/dev/null", outfile); - fpipe = popen(pipecmd, "wb"); /* Global FILE * */ + fpipe = popen(pipecmd, "w"); /* Global FILE * */ if (fpipe == NULL) { perror("RSL_write_gif1"); return; @@ -563,7 +563,7 @@ void RSL_write_pict(char *outfile, unsigned char *image, int xdim, int ydim, cha } nbytes = xdim*ydim; (void)sprintf(pipecmd, "ppmtopict > %s 2>/dev/null", outfile); - fpipe = popen(pipecmd, "wb"); /* Global FILE * */ + fpipe = popen(pipecmd, "w"); /* Global FILE * */ fprintf(fpipe, "P6\n# %s\n%d %d\n255\n",outfile, xdim, ydim); for (i=0; i %s.gz 2>/dev/null", outfile); - fpipe = popen(pipecmd, "wb"); /* Global FILE * */ + fpipe = popen(pipecmd, "w"); /* Global FILE * */ fprintf(fpipe, "P5\n# %s\n%d %d\n255\n",outfile, xdim, ydim); if (fwrite(image, sizeof(char), nbytes, fpipe) != nbytes) fprintf(stderr, "RSL_write_pgm: short write\n"); -- 2.43.2