View | Details | Raw Unified | Return to bug 24841
Collapse All | Expand All

(-)a/NEWS (+6 lines)
Lines 2-7 GNU coreutils NEWS -*- outline -*- Link Here
2
2
3
* Noteworthy changes in release ?.? (????-??-??) [?]
3
* Noteworthy changes in release ?.? (????-??-??) [?]
4
4
5
** Bug fixes
6
7
  split no longer creates files with a suffix length that
8
  is dependent on the number of bytes or lines per file.
9
  [bug introduced in coreutils-8.8]
10
5
11
6
* Noteworthy changes in release 8.8 (2010-12-22) [stable]
12
* Noteworthy changes in release 8.8 (2010-12-22) [stable]
7
13
(-)a/src/split.c (-12 / +20 lines)
Lines 78-83 static bool elide_empty_files; Link Here
78
   input to output, which is much slower, so disabled by default.  */
78
   input to output, which is much slower, so disabled by default.  */
79
static bool unbuffered;
79
static bool unbuffered;
80
80
81
/* The split mode to use.  */
82
enum Split_type
83
{
84
  type_undef, type_bytes, type_byteslines, type_lines, type_digits,
85
  type_chunk_bytes, type_chunk_lines, type_rr
86
};
87
81
/* For long options that have no equivalent short option, use a
88
/* For long options that have no equivalent short option, use a
82
   non-character as a pseudo short option, starting with CHAR_MAX + 1.  */
89
   non-character as a pseudo short option, starting with CHAR_MAX + 1.  */
83
enum
90
enum
Lines 105-120 static struct option const longopts[] = Link Here
105
};
112
};
106
113
107
static void
114
static void
108
set_suffix_length (uintmax_t n_units)
115
set_suffix_length (uintmax_t n_units, enum Split_type split_type)
109
{
116
{
110
#define DEFAULT_SUFFIX_LENGTH 2
117
#define DEFAULT_SUFFIX_LENGTH 2
111
118
112
  size_t suffix_needed = 0;
119
  size_t suffix_needed = 0;
113
  size_t alphabet_len = strlen (suffix_alphabet);
120
114
  bool alphabet_slop = (n_units % alphabet_len) != 0;
121
  if (split_type == type_chunk_bytes || split_type == type_chunk_lines
115
  while (n_units /= alphabet_len)
122
      || split_type == type_rr)
116
    suffix_needed++;
123
    {
117
  suffix_needed += alphabet_slop;
124
      size_t alphabet_len = strlen (suffix_alphabet);
125
      bool alphabet_slop = (n_units % alphabet_len) != 0;
126
      while (n_units /= alphabet_len)
127
        suffix_needed++;
128
      suffix_needed += alphabet_slop;
129
    }
118
130
119
  if (suffix_length)            /* set by user */
131
  if (suffix_length)            /* set by user */
120
    {
132
    {
Lines 780-790 int Link Here
780
main (int argc, char **argv)
792
main (int argc, char **argv)
781
{
793
{
782
  struct stat stat_buf;
794
  struct stat stat_buf;
783
  enum
795
  enum Split_type split_type = type_undef;
784
    {
785
      type_undef, type_bytes, type_byteslines, type_lines, type_digits,
786
      type_chunk_bytes, type_chunk_lines, type_rr
787
    } split_type = type_undef;
788
  size_t in_blk_size = 0;	/* optimal block size of input file device */
796
  size_t in_blk_size = 0;	/* optimal block size of input file device */
789
  char *buf;			/* file i/o buffer */
797
  char *buf;			/* file i/o buffer */
790
  size_t page_size = getpagesize ();
798
  size_t page_size = getpagesize ();
Lines 984-990 main (int argc, char **argv) Link Here
984
      usage (EXIT_FAILURE);
992
      usage (EXIT_FAILURE);
985
    }
993
    }
986
994
987
  set_suffix_length (n_units);
995
  set_suffix_length (n_units, split_type);
988
996
989
  /* Get out the filename arguments.  */
997
  /* Get out the filename arguments.  */
990
998
(-)a/tests/misc/split-a (-1 / +5 lines)
Lines 63-66 for f in $files; do Link Here
63
  n=$(expr $n + 1)
63
  n=$(expr $n + 1)
64
done
64
done
65
65
66
# Ensure that -a is independent of -[bCl]
67
split -a2 -b1000 < /dev/null || fail=1
68
split -a2 -l1000 < /dev/null || fail=1
69
split -a2 -C1000 < /dev/null || fail=1
70
66
Exit $fail
71
Exit $fail
67
- 

Return to bug 24841