summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-11-25 14:17:43 +0000
committerJim Meyering <jim@meyering.net>2000-11-25 14:17:43 +0000
commite3db837339959358ec5c8cb521ccac9ce09e1001 (patch)
treefc938c216c2b008cca9e485e128b2509afc16eae
parentb499483abd8724f19d73be070c8c49b34706f5df (diff)
downloadcoreutils-e3db837339959358ec5c8cb521ccac9ce09e1001.tar.xz
more post-merge clean-up.
Fix a merge bug exposed by new test.
-rw-r--r--src/dd.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/dd.c b/src/dd.c
index 658b45579..db0adab8c 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -816,24 +816,20 @@ skip (int fdesc, char const *file, uintmax_t n, Unit units, size_t blocksize,
{
int nread;
- /* Decrement N according to UNITS: if we're counting bytes, then
- decrement N by BLOCKSIZE (the last read may be smaller than BLOCKSIZE),
- otherwise, simply decrement N by 1. */
- if (units == U_BYTES)
+ /* Decrement N according to UNITS: if we're counting blocks, then
+ simply decrement N by 1. Otherwise, decrement N by BLOCKSIZE
+ (the last read may be smaller than BLOCKSIZE). */
+ if (units == U_BLOCKS)
+ --n;
+ else
{
- if (n < blocksize)
+ if (blocksize <= n)
+ n -= blocksize;
+ else
{
n = 0;
blocksize = n;
}
- else
- {
- n -= blocksize;
- }
- }
- else
- {
- --n;
}
nread = safe_read (fdesc, buf, blocksize);
@@ -1210,7 +1206,8 @@ main (int argc, char **argv)
mode_t perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
int opts
= (O_CREAT
- | (seek_record || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC));
+ | ((seek_record || seek_bytes)
+ || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC));
/* Open the output file with *read* access only if we might
need to read to satisfy a `seek=' request. If we can't read