off_t chunk_end = chunk_size - 1;
off_t n_written = 0;
bool new_file_flag = true;
+ bool chunk_truncated = false;
if (k > 1)
{
error (EXIT_FAILURE, errno, "%s", infile);
else if (n_read == 0)
break; /* eof. */
+ chunk_truncated = false;
eob = buf + n_read;
while (bp != eob)
if (!next && bp == eob)
{
/* replenish buf, before going to next chunk. */
-
- /* If we're going to stop reading,
- then count the current chunk. */
- if (n_written >= file_size)
- chunk_no++;
+ chunk_truncated = true;
break;
}
chunk_no++;
}
}
+ if (chunk_truncated)
+ chunk_no++;
+
/* Ensure NUMBER files are created, which truncates
any existing files or notifies any consumers on fifos.
FIXME: Should we do this before EXIT_FAILURE? */
rm -f x*
if test -z "$ELIDE_EMPTY"; then
- split ---io-blksize=$IO_BLKSIZE $ELIDE_EMPTY -n l/2/$N in > chunk.k
- stat x* >/dev/null 2>/dev/null && fail=1
+ split ---io-blksize=$IO_BLKSIZE -n l/2/$N in > chunk.k
+ stat x* 2>/dev/null && fail=1
fi
split ---io-blksize=$IO_BLKSIZE $ELIDE_EMPTY -n l/$N in