On Sat, Dec 09, 2000 at 08:46:17AM -0800, [EMAIL PROTECTED] wrote: > > > then split_any() could just tell it how much to read, and this wouldn't > > > be as much > > > of an issue. Alternately, split_any() could just keep track of how much > > > was read > > > and loop through an arbitrary number of reads, incrementing until the > > > totals > > > matched. That's the least intrusive approach. I'll implement it if > > > people agree. > > > Thoughts? > > > > This is the approach that I had in mind. It is quite simple, actually: loop > > until the read() returns a length such that point <= length. If point > > > length, then subtract the length from point, and read the next bucket. > > > > Note that *no* split should occur when point == length. > > This is different than all of the other split functions. If point == > length, then we get one bucket with length == point and one bucket with > length == 0. This makes the code much easier to deal with, because it > removes special cases.
Per my other email, I see the split_any() as a way to "ensure" that the brigade has a break point at the specified offset. (which allows us to actually cut the brigade in two, or copy buckets, or whatever) Given that viewpoint: creating a zero-length bucket isn't important. Also, the split function would return the "bucket-after-point". So if you had a brigade such as: B1 -> B2 and you split at P==len(B1), then you get back a pointer to B2 (rather than a pointer to a new zero-len bucket inserted before B2). Cheers, -g -- Greg Stein, http://www.lyra.org/