diff -ur psutils-1.21.orig/epsffit.c psutils-1.21/epsffit.c --- psutils-1.21.orig/epsffit.c 2013-10-21 23:28:08.000000000 +0200 +++ psutils-1.21/epsffit.c 2013-10-25 13:06:05.000000000 +0200 @@ -17,7 +17,9 @@ #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include "psutil.h" @@ -37,6 +39,9 @@ FILE *output = stdout; int opt; + SET_BINARY(stdin); + SET_BINARY(stdout); + program = *argv; while((opt = getopt(argc, argv, "csramv")) != EOF) { diff -ur psutils-1.21.orig/psbook.c psutils-1.21/psbook.c --- psutils-1.21.orig/psbook.c 2013-10-21 23:28:08.000000000 +0200 +++ psutils-1.21/psbook.c 2013-10-25 13:06:05.000000000 +0200 @@ -7,9 +7,9 @@ */ #include "config.h" - +#ifdef HAVE_UNISTD_H #include - +#endif #include "psutil.h" const char *syntax = "[-q] [-sSIGNATURE] [INFILE [OUTFILE]]\n SIGNATURE must be positive and divisible by 4\n"; @@ -23,6 +23,9 @@ int currentpg, maxpage; int opt; + SET_BINARY(stdin); + SET_BINARY(stdout); + verbose = 1; program = *argv; diff -ur psutils-1.21.orig/psnup.c psutils-1.21/psnup.c --- psutils-1.21.orig/psnup.c 2013-10-21 23:28:08.000000000 +0200 +++ psutils-1.21/psnup.c 2013-10-25 13:06:05.000000000 +0200 @@ -7,8 +7,9 @@ */ #include "config.h" - +#ifdef HAVE_UNISTD_H #include +#endif #include #include @@ -49,6 +50,9 @@ int opt; const struct paper *paper = NULL; + SET_BINARY(stdin); + SET_BINARY(stdout); + set_paper_size(NULL); margin = border = vshift = hshift = column = flip = 0; diff -ur psutils-1.21.orig/psresize.c psutils-1.21/psresize.c --- psutils-1.21.orig/psresize.c 2013-10-21 23:28:08.000000000 +0200 +++ psutils-1.21/psresize.c 2013-10-25 13:06:05.000000000 +0200 @@ -7,8 +7,9 @@ */ #include "config.h" - +#ifdef HAVE_UNISTD_H #include +#endif #include #include "psutil.h" @@ -32,6 +33,9 @@ int opt; const struct paper *paper = NULL; + SET_BINARY(stdin); + SET_BINARY(stdout); + set_paper_size(NULL); vshift = hshift = 0; diff -ur psutils-1.21.orig/psselect.c psutils-1.21/psselect.c --- psutils-1.21.orig/psselect.c 2013-10-21 23:28:08.000000000 +0200 +++ psutils-1.21/psselect.c 2013-10-25 13:06:05.000000000 +0200 @@ -7,9 +7,9 @@ */ #include "config.h" - +#ifdef HAVE_UNISTD_H #include - +#endif #include "psutil.h" const char *syntax = "[-q] [-e] [-o] [-r] [-pPAGES] [INFILE [OUTFILE]]\n"; @@ -88,6 +88,9 @@ int pass, all; PageRange *pagerange = NULL; + SET_BINARY(stdin); + SET_BINARY(stdout); + verbose = 1; program = *argv; diff -ur psutils-1.21.orig/pstops.c psutils-1.21/pstops.c --- psutils-1.21.orig/pstops.c 2013-10-21 23:28:08.000000000 +0200 +++ psutils-1.21/pstops.c 2013-10-25 13:06:05.000000000 +0200 @@ -7,8 +7,9 @@ */ #include "config.h" - +#ifdef HAVE_UNISTD_H #include +#endif #include #include @@ -107,6 +108,9 @@ const struct paper *paper = NULL; int opt; + SET_BINARY(stdin); + SET_BINARY(stdout); + set_paper_size(NULL); verbose = 1; diff -ur psutils-1.21.orig/psutil.h psutils-1.21/psutil.h --- psutils-1.21.orig/psutil.h 2013-10-21 23:28:08.000000000 +0200 +++ psutils-1.21/psutil.h 2013-10-25 13:06:05.000000000 +0200 @@ -21,6 +21,15 @@ #define WARN (MESSAGE_NL|MESSAGE_PROGRAM) #define LOG 0 +/* change mode of a file pointer on Windows */ +#if defined(WIN32) +#include +#include +#define SET_BINARY(fp) (void)_setmode(fileno(fp), _O_BINARY) +#else /* !WIN32 */ +#define SET_BINARY(fp) (void)0 +#endif + /* Definitions for functions found in psutil.c */ extern void usage(void); extern void message(int flags, const char *format, ...);