]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Include full-write.h.
authorJim Meyering <jim@meyering.net>
Fri, 31 Aug 2001 07:45:12 +0000 (07:45 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 31 Aug 2001 07:45:12 +0000 (07:45 +0000)
(full_write): Remove decl; not needed.
(simple_cat, cat): Don't assume read and write size fits in int.

src/cat.c

index 11c60082043246690520888a224d69ae3ed31c53..c4fa65db6bd74d3b31175cd98403a6c26ceacc0f 100644 (file)
--- a/src/cat.c
+++ b/src/cat.c
@@ -33,6 +33,7 @@
 #include "system.h"
 #include "closeout.h"
 #include "error.h"
+#include "full-write.h"
 #include "safe-read.h"
 
 /* The official name of this program (e.g., no `g' prefix).  */
@@ -44,8 +45,6 @@
 #undef max
 #define max(h,i) ((h) > (i) ? (h) : (i))
 
-int full_write ();
-
 /* Name under which this program was invoked.  */
 char *program_name;
 
@@ -156,7 +155,7 @@ simple_cat (
      int bufsize)
 {
   /* Actual number of characters read, and therefore written.  */
-  int n_read;
+  ssize_t n_read;
 
   /* Loop until the end of the file.  */
 
@@ -179,7 +178,7 @@ simple_cat (
 
       /* Write this block out.  */
 
-      if (full_write (STDOUT_FILENO, buf, n_read) < 0)
+      if (full_write (STDOUT_FILENO, buf, n_read) != n_read)
        error (EXIT_FAILURE, errno, _("write error"));
     }
 }
@@ -226,7 +225,7 @@ cat (
   unsigned char *bpout;
 
   /* Number of characters read by the last read call.  */
-  int n_read;
+  ssize_t n_read;
 
   /* Determines how many consecutive newlines there have been in the
      input.  0 newlines makes NEWLINES -1, 1 newline makes NEWLINES 1,