Skip to content

Commit

Permalink
fix to make stdin/stdout options work under Win32
Browse files Browse the repository at this point in the history
  • Loading branch information
tjko committed Apr 11, 2015
1 parent a5d36b5 commit 4e82d0c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jpegoptim.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ int main(int argc, char **argv)
do {
if (stdin_mode) {
infile=stdin;
set_filemode_binary(infile);
} else {
if (!argv[i][0]) continue;
if (argv[i][0]=='-') continue;
Expand Down Expand Up @@ -789,6 +790,7 @@ int main(int argc, char **argv)

if (stdout_mode) {
outfname=NULL;
set_filemode_binary(stdout);
if (fwrite(outbuffer,outbuffersize,1,stdout) != 1)
fatal("write failed to stdout");
} else {
Expand Down
1 change: 1 addition & 0 deletions jpegoptim.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern "C" {
#include <utime.h>
#define DIR_SEPARATOR_C '/'
#define DIR_SEPARATOR_S "/"
#define set_filemode_binary(file) {}
#endif
#include <sys/types.h>
#include <sys/stat.h>
Expand Down
2 changes: 2 additions & 0 deletions win32_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ extern "C" {
#define realpath(N,R) _fullpath((R),(N),MAXPATHLEN)
#define ftruncate(fildes,length) open(fildes, O_TRUNC|O_WRONLY)

#define set_filemode_binary(file) _setmode(_fileno(file), _O_BINARY)

#define round(x) ((int) (x))
#define getuid(x) 0
#define geteuid() 0
Expand Down

0 comments on commit 4e82d0c

Please sign in to comment.