Subject: Re: CVS commit: src/usr.bin/split
To: Alan Barrett <apb@cequrux.com>
From: Jan Schaumann <jschauma@netmeister.org>
List: source-changes
Date: 05/31/2007 09:59:49
--yEPQxsgoJgBvi8ip
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Alan Barrett <apb@cequrux.com> wrote:
> On Thu, 31 May 2007, Jan Schaumann wrote:
> > Modified Files:
> > src/usr.bin/split: split.1 split.c
> >=20
> > Log Message:
> > Add a new command-line option "-n chunk_count", that splits the input
> > file into chunk_count smaller files. Each file will be size/chunk_count
> > bytes large, with whatever spillover there is ending up in the chunk_co=
unth
> > file.
>=20
> If you change this line in split3() from
>=20
> split1(sb.st_size/chunks, chunks);
>=20
> to
>=20
> split1((sb.st_size + chunks - 1)/chunks, chunks);
>=20
> then the last file will never be larger than the others, there won't
> be any "spillover", and you can remove all the new special cases in
> split1().
If by "all the new special cases", you mean the counting of the files
created, then I'm not sure if using your approach does the right thing.
Consider a file of 100 bytes size that you want to split into 11 files:
My approach says "split bytewise into files with 100/11 =3D 9 bytes, no
more than 11 files" (ie 10 files with 9 bytes each, one file is 10
bytes, total # of files is 11).
Your approach says "split bytewise into files with (100 + 11 - 1)/11 =3D
10 bytes" (ie 10 files with 10 bytes each).
Or did you mean something else?
-Jan
--=20
Ancient Principle of WYGIWYGAINGW:
What You Get Is What You're Given, And It's No Good Whining.
--Terry Pratchett et al. (The Science of Discworld)
--yEPQxsgoJgBvi8ip
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (NetBSD)
iD8DBQFGXv8FfFtkr68iakwRAg8JAJ9CfMbLFa8Cj2xH3tNp1JgNRsXIVQCgvl7a
9n25YIKL8Y/XzOZ2cGao/tE=
=y8JW
-----END PGP SIGNATURE-----
--yEPQxsgoJgBvi8ip--