From 13e5d174943e86143aa8b317ec84d6b3558c42c8 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 1 Jan 1999 22:49:44 +0000 Subject: [PATCH] (cwrite) [O_BINARY]: Write output in binary mode. (main) [O_BINARY]: Read input in binary mode. --- src/split.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/split.c b/src/split.c index f6caacc8de..288ee5ec92 100644 --- a/src/split.c +++ b/src/split.c @@ -1,5 +1,5 @@ /* split.c -- split a file into pieces. - Copyright (C) 88, 91, 95, 96, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 88, 91, 1995-1998, 1999 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -156,7 +156,8 @@ cwrite (int new_file_flag, const char *bp, int bytes) next_file_name (); if (verbose) fprintf (stderr, _("creating file `%s'\n"), outfile); - output_desc = open (outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666); + output_desc = open (outfile, + O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); if (output_desc < 0) error (EXIT_FAILURE, errno, "%s", outfile); } @@ -494,6 +495,8 @@ main (int argc, char **argv) if (input_desc < 0) error (EXIT_FAILURE, errno, "%s", infile); } + /* Binary I/O is safer when bytecounts are used. */ + SET_BINARY (input_desc); /* No output file is open now. */ output_desc = -1; -- 2.47.3