1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-11 06:34:40 +02:00

split --line-bytes=N (-C N): don't create an empty file.

* src/split.c (line_bytes_split): Don't create an empty line
afterwards if the last buffer happens to be exactly full.
* tests/misc/split-fail: Add a test case for this.
* NEWS: mention this.
This commit is contained in:
Paul Eggert
2007-04-12 00:21:25 +02:00
committed by Jim Meyering
parent f839bfad73
commit 395fcee97a
4 changed files with 23 additions and 2 deletions

View File

@@ -1,3 +1,11 @@
2007-04-11 Paul Eggert <eggert@cs.ucla.edu>
split --line-bytes=N (-C N): don't create an empty file.
* src/split.c (line_bytes_split): Don't create an empty line
afterwards if the last buffer happens to be exactly full.
* tests/misc/split-fail: Add a test case for this.
* NEWS: mention this.
2007-04-10 Jim Meyering <jim@meyering.net>
ls: don't form or compute the length of strings that won't be used.

3
NEWS
View File

@@ -15,6 +15,9 @@ GNU coreutils NEWS -*- outline -*-
ln=target attribute) would mistakenly output the string "target"
before the name of each symlink. [introduced in coreutils-6.0]
split --line-bytes=N (-C N) no longer creates an empty file
[this bug is present at least as far back as textutils-1.22 (Jan, 1997)]
* Noteworthy changes in release 6.9 (2007-03-22) [stable]

View File

@@ -336,7 +336,11 @@ line_bytes_split (size_t n_bytes)
n_buffered += n_read;
if (n_buffered != n_bytes)
eof = true;
{
if (n_buffered == 0)
break;
eof = true;
}
/* Find where to end this chunk. */
bp = buf + n_buffered;

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# split must fail when given length/count of zero.
# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
# Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -47,6 +47,12 @@ split -b 0 in 2> /dev/null && fail=1
split -C 0 in 2> /dev/null && fail=1
split -l 0 in 2> /dev/null && fail=1
# Make sure -C doesn't create empty files.
rm -f x?? || fail=1
echo x | split -C 1 || fail=1
test -f xaa && test -f xab || fail=1
test -f xac && fail=1
# Make sure that the obsolete -N notation still works
split -1 in 2> /dev/null || fail=1