Index: src/head.c =================================================================== RCS file: /home/gondolin/herbert/src/CVS/debian/textutils/src/head.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 head.c --- src/head.c 22 Apr 1999 05:25:03 -0000 1.1.1.1 +++ src/head.c 22 Sep 2001 22:29:16 -0000 @@ -45,6 +45,10 @@ /* Size of atomic reads. */ #define BUFSIZE (512 * 8) +/* Undefine, to avoid warning about redefinition on some systems. */ +#undef min +#define min(x, y) ((x) < (y) ? (x) : (y)) + /* If nonzero, print filename headers. */ static int print_headers; @@ -125,7 +129,7 @@ while (bytes_to_write) { - bytes_read = safe_read (fd, buffer, BUFSIZE); + bytes_read = safe_read (fd, buffer, min(bytes_to_write, BUFSIZE)); if (bytes_read < 0) { error (0, errno, "%s", filename); @@ -133,8 +137,6 @@ } if (bytes_read == 0) break; - if (bytes_read > bytes_to_write) - bytes_read = bytes_to_write; if (fwrite (buffer, 1, bytes_read, stdout) == 0) error (EXIT_FAILURE, errno, _("write error")); bytes_to_write -= bytes_read;