(skip): Perform the `records < blocksize' test
authorJim Meyering <jim@meyering.net>
Sun, 26 Nov 2000 21:35:53 +0000 (21:35 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 26 Nov 2000 21:35:53 +0000 (21:35 +0000)
at the top of the loop, not at the bottom.

src/dd.c

index b6b3a5897f064b96765c1bc17964d9ac48f4ae4d..4bcd2d1d34b4d111d94723d7946f3ca89961398d 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -805,6 +805,9 @@ skip (int fdesc, char *file, int count_bytes, uintmax_t records,
        {
          int nread;
 
+         if (count_bytes && records < blocksize)
+           blocksize = records;
+
          nread = safe_read (fdesc, buf, blocksize);
          if (nread < 0)
            {
@@ -817,14 +820,7 @@ skip (int fdesc, char *file, int count_bytes, uintmax_t records,
          if (nread == 0)
            break;
 
-         if (count_bytes)
-           {
-             records -= nread;
-             if (records < blocksize)
-               blocksize = records;
-           }
-         else
-           records--;
+         records -= (count_bytes ? nread : 1);
        }
     }
 }