From: Jim Meyering Date: Sat, 2 Mar 1996 05:45:45 +0000 (+0000) Subject: (WINDOWS_SETFILEMODE_BINARY): New macro. X-Git-Tag: FILEUTILS-3_12j~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=815b5ca1d577ad6b9f07d50219c1870d24930545;p=platform%2Fupstream%2Fcoreutils.git (WINDOWS_SETFILEMODE_BINARY): New macro. (skip) [_WIN32 && _O_BINARY]: Use it. (read_char): Likewise. (read_block): Likewise. Based on changes by Gary Newman . --- diff --git a/src/od.c b/src/od.c index deea367..c54e253 100644 --- a/src/od.c +++ b/src/od.c @@ -29,7 +29,12 @@ #ifdef _AIX #pragma alloca #else /* not _AIX */ +#ifdef _WIN32 +#include +#include +#else char *alloca (); +#endif /* not _WIN32 */ #endif /* not _AIX */ #endif /* not HAVE_ALLOCA_H */ #endif /* not __GNUC__ */ @@ -87,6 +92,22 @@ typedef double LONG_DOUBLE; # define MIN(a,b) (((a) < (b)) ? (a) : (b)) #endif +#if defined (_WIN32) && defined (_O_BINARY) +# define WINDOWS_SETFILEMODE_BINARY(IN_STREAM, FILENAME) \ + do \ + { /* Turn off DOS text file modes, "rb" doesn't work on stdin. */\ + if (_setmode (_fileno ((IN_STREAM)), _O_BINARY) == -1) \ + { \ + error (0, errno, "%s", (FILENAME)); \ + err = 1; \ + continue; \ + } \ + } \ + while (0) +#else +# define WINDOWS_SETFILEMODE_BINARY(IN_STREAM, FILENAME) /* empty */ +#endif + /* The default number of input bytes per output line. */ #define DEFAULT_BYTES_PER_BLOCK 16 @@ -941,6 +962,7 @@ skip (off_t n_skip) continue; } } + WINDOWS_SETFILEMODE_BINARY (in_stream, input_filename); if (n_skip == 0) break; @@ -1189,6 +1211,7 @@ read_char (int *c) err = 1; } } + WINDOWS_SETFILEMODE_BINARY (in_stream, input_filename); } while (in_stream == NULL); } @@ -1261,6 +1284,7 @@ read_block (size_t n, char *block, size_t *n_bytes_in_buffer) err = 1; } } + WINDOWS_SETFILEMODE_BINARY (in_stream, input_filename); } while (in_stream == NULL); }