Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/usr.bin/split



# John Darrow 2007-06-01:
> On 31 May 2007 12:00:13 -0500, Jan Schaumann 
> <jschauma%netmeister.org@localhost> wrote:
> >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).
> 
> This "miscounting" is a very rare special case, only _possibly_
> occurring when (st_size / chunks) <= chunks, and even then only for
> certain particular degenerate sizes (e.g. replacing 100 by 99 or 101
> in your example will result in his code still producing 11 files).
> 
> Normally, the number of bytes per chunk is much larger than number
> of chunks, in which case Alan's version still yields the proper number
> of chunks, and greatly simplifies the rest of the code, so I think we
> should go with it (possibly including a comment indicating awareness
> of the degenerate case).

If the user asks for N chunks than that's exactly the number of chunks
he should get. At least that seems to be POLA in this case ;-)

        -- Jachym



Home | Main Index | Thread Index | Old Index