The suffix length was dependent on the number of bytes or lines per file (#666293)
This commit is contained in:
parent
1dfeb25767
commit
1c281144c3
98
coreutils-8.8-split-suffix.patch
Normal file
98
coreutils-8.8-split-suffix.patch
Normal file
@ -0,0 +1,98 @@
|
||||
From ec19e2a647cb64d4a5620787d4ecf5964d85fcf6 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
|
||||
Date: Thu, 30 Dec 2010 01:36:59 +0000
|
||||
Subject: [PATCH] split: fix the suffix length calculation
|
||||
|
||||
* src/split.c (set_suffix_length): Only auto calculate
|
||||
the suffix length when the number of files is specified.
|
||||
* tests/misc/split-a: Add a case to trigger the bug.
|
||||
---
|
||||
src/split.c | 32 ++++++++++++++++++++------------
|
||||
tests/misc/split-a | 5 +++++
|
||||
2 files changed, 25 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/split.c b/src/split.c
|
||||
index ae98bc7..9e9efbf 100644
|
||||
--- a/src/split.c
|
||||
+++ b/src/split.c
|
||||
@@ -78,6 +78,13 @@ static bool elide_empty_files;
|
||||
input to output, which is much slower, so disabled by default. */
|
||||
static bool unbuffered;
|
||||
|
||||
+/* The split mode to use. */
|
||||
+enum Split_type
|
||||
+{
|
||||
+ type_undef, type_bytes, type_byteslines, type_lines, type_digits,
|
||||
+ type_chunk_bytes, type_chunk_lines, type_rr
|
||||
+};
|
||||
+
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
@@ -105,16 +112,21 @@ static struct option const longopts[] =
|
||||
};
|
||||
|
||||
static void
|
||||
-set_suffix_length (uintmax_t n_units)
|
||||
+set_suffix_length (uintmax_t n_units, enum Split_type split_type)
|
||||
{
|
||||
#define DEFAULT_SUFFIX_LENGTH 2
|
||||
|
||||
size_t suffix_needed = 0;
|
||||
- size_t alphabet_len = strlen (suffix_alphabet);
|
||||
- bool alphabet_slop = (n_units % alphabet_len) != 0;
|
||||
- while (n_units /= alphabet_len)
|
||||
- suffix_needed++;
|
||||
- suffix_needed += alphabet_slop;
|
||||
+
|
||||
+ if (split_type == type_chunk_bytes || split_type == type_chunk_lines
|
||||
+ || split_type == type_rr)
|
||||
+ {
|
||||
+ size_t alphabet_len = strlen (suffix_alphabet);
|
||||
+ bool alphabet_slop = (n_units % alphabet_len) != 0;
|
||||
+ while (n_units /= alphabet_len)
|
||||
+ suffix_needed++;
|
||||
+ suffix_needed += alphabet_slop;
|
||||
+ }
|
||||
|
||||
if (suffix_length) /* set by user */
|
||||
{
|
||||
@@ -780,11 +792,7 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
- enum
|
||||
- {
|
||||
- type_undef, type_bytes, type_byteslines, type_lines, type_digits,
|
||||
- type_chunk_bytes, type_chunk_lines, type_rr
|
||||
- } split_type = type_undef;
|
||||
+ enum Split_type split_type = type_undef;
|
||||
size_t in_blk_size = 0; /* optimal block size of input file device */
|
||||
char *buf; /* file i/o buffer */
|
||||
size_t page_size = getpagesize ();
|
||||
@@ -984,7 +992,7 @@ main (int argc, char **argv)
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
- set_suffix_length (n_units);
|
||||
+ set_suffix_length (n_units, split_type);
|
||||
|
||||
/* Get out the filename arguments. */
|
||||
|
||||
diff --git a/tests/misc/split-a b/tests/misc/split-a
|
||||
index d861b92..b0526bc 100755
|
||||
--- a/tests/misc/split-a
|
||||
+++ b/tests/misc/split-a
|
||||
@@ -63,4 +63,9 @@ for f in $files; do
|
||||
n=$(expr $n + 1)
|
||||
done
|
||||
|
||||
+# Ensure that -a is independent of -[bCl]
|
||||
+split -a2 -b1000 < /dev/null || fail=1
|
||||
+split -a2 -l1000 < /dev/null || fail=1
|
||||
+split -a2 -C1000 < /dev/null || fail=1
|
||||
+
|
||||
Exit $fail
|
||||
--
|
||||
1.7.3.4
|
||||
|
@ -1,7 +1,7 @@
|
||||
Summary: A set of basic GNU tools commonly used in shell scripts
|
||||
Name: coreutils
|
||||
Version: 8.8
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
License: GPLv3+
|
||||
Group: System Environment/Base
|
||||
Url: http://www.gnu.org/software/coreutils/
|
||||
@ -18,6 +18,8 @@ Source202: coreutils-su-l.pamd
|
||||
Source203: coreutils-runuser-l.pamd
|
||||
|
||||
# From upstream
|
||||
#The suffix length was dependent on the number of bytes or lines per file(#666293)
|
||||
Patch1: coreutils-8.8-split-suffix.patch
|
||||
|
||||
# Our patches
|
||||
#general patch to workaround koji build system issues
|
||||
@ -115,6 +117,7 @@ Libraries for coreutils package.
|
||||
%setup -q
|
||||
|
||||
# From upstream
|
||||
%patch1 -p1 -b .splitsuffix
|
||||
|
||||
# Our patches
|
||||
%patch100 -p1 -b .configure
|
||||
@ -332,6 +335,10 @@ fi
|
||||
%{_libdir}/coreutils
|
||||
|
||||
%changelog
|
||||
* Fri Dec 31 2010 Ondrej Vasik <ovasik@redhat.com> - 8.8-2
|
||||
- The suffix length was dependent on the number of bytes
|
||||
or lines per file (#666293)
|
||||
|
||||
* Thu Dec 23 2010 Ondrej Vasik <ovasik@redhat.com> - 8.8-1
|
||||
- fix parallel sorting issue (#655096)
|
||||
- new upstream release coreutils-8.8 (#665164)
|
||||
|
Loading…
Reference in New Issue
Block a user