summaryrefslogtreecommitdiff
path: root/src/sum.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-01-01 22:48:51 +0000
committerJim Meyering <jim@meyering.net>1999-01-01 22:48:51 +0000
commitf92719d4dc54c4c2ff14ce37de35ca0ce1c5c659 (patch)
tree896e7735047ba217b08f96322b26e637bed868e5 /src/sum.c
parente60b747ade42ec381fee53e54c82b208fd1d165a (diff)
downloadcoreutils-f92719d4dc54c4c2ff14ce37de35ca0ce1c5c659.tar.gz
coreutils-f92719d4dc54c4c2ff14ce37de35ca0ce1c5c659.tar.bz2
coreutils-f92719d4dc54c4c2ff14ce37de35ca0ce1c5c659.zip
(bsd_sum_file, sysv_sum_file) [O_BINARY]: Read input in binary mode.
Diffstat (limited to 'src/sum.c')
-rw-r--r--src/sum.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/sum.c b/src/sum.c
index e3321d586..bb97e10a0 100644
--- a/src/sum.c
+++ b/src/sum.c
@@ -1,5 +1,5 @@
/* sum -- checksum and count the blocks in a file
- Copyright (C) 86, 89, 91, 95, 96, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 86, 89, 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
@@ -106,6 +106,8 @@ bsd_sum_file (const char *file, int print_name)
return -1;
}
}
+ /* Need binary I/O, or else byte counts and checksums are incorrect. */
+ SET_BINARY (fileno(fp));
while ((ch = getc (fp)) != EOF)
{
@@ -165,6 +167,8 @@ sysv_sum_file (const char *file, int print_name)
return -1;
}
}
+ /* Need binary I/O, or else byte counts and checksums are incorrect. */
+ SET_BINARY (fd);
while ((bytes_read = safe_read (fd, buf, sizeof buf)) > 0)
{
@@ -256,4 +260,3 @@ main (int argc, char **argv)
error (EXIT_FAILURE, errno, "-");
exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
-