Thread overview
std.stream.Stream.copyFrom()
Mar 25, 2005
derick_eddington
Mar 25, 2005
Ben Hinkle
Mar 25, 2005
Ben Hinkle
Mar 26, 2005
derick_eddington
Mar 27, 2005
Nick
March 25, 2005
std.stream.Stream.copyFrom(Stream):

void copyFrom(Stream s)
{
//BUG  uint pos = position();    // not position of this
uint pos = s.position();     // save position of s
s.position(0);
copyFrom(s, s.size());
s.position(pos);
}


std.stream.Stream.copyFrom(Stream, uint):

void copyFrom(Stream s, uint count)
{
ubyte[] buf;
//BUG  buf.length = s.size();    // not size of s
buf.length = count;          // use specified size
s.readExact(buf, buf.length);
writeExact(buf, buf.length);
}



March 25, 2005
<derick_eddington@nospam.dot.yahoo.dot.com> wrote in message news:d1vuka$1ed1$1@digitaldaemon.com...
> std.stream.Stream.copyFrom(Stream):
>
> void copyFrom(Stream s)
> {
> //BUG  uint pos = position();    // not position of this
> uint pos = s.position();     // save position of s
> s.position(0);
> copyFrom(s, s.size());
> s.position(pos);
> }
>
>
> std.stream.Stream.copyFrom(Stream, uint):
>
> void copyFrom(Stream s, uint count)
> {
> ubyte[] buf;
> //BUG  buf.length = s.size();    // not size of s
> buf.length = count;          // use specified size
> s.readExact(buf, buf.length);
> writeExact(buf, buf.length);
> }

wow. Those are bad bugs - I guess you're one of the first people to try to use copyFrom. I wonder if it ever worked or if those bugs crept in by accident somehow. Have you sent the fix to Walter? Just email him the fixed file. I would add a unittest, too, if you have time since I notice it isn't tested anywhere.


March 25, 2005
"Ben Hinkle" <ben.hinkle@gmail.com> wrote in message news:d200sa$1gvm$1@digitaldaemon.com...
>
> <derick_eddington@nospam.dot.yahoo.dot.com> wrote in message news:d1vuka$1ed1$1@digitaldaemon.com...
>> std.stream.Stream.copyFrom(Stream):
>>
>> void copyFrom(Stream s)
>> {
>> //BUG  uint pos = position();    // not position of this
>> uint pos = s.position();     // save position of s
>> s.position(0);
>> copyFrom(s, s.size());
>> s.position(pos);
>> }
>>
>>
>> std.stream.Stream.copyFrom(Stream, uint):
>>
>> void copyFrom(Stream s, uint count)
>> {
>> ubyte[] buf;
>> //BUG  buf.length = s.size();    // not size of s
>> buf.length = count;          // use specified size
>> s.readExact(buf, buf.length);
>> writeExact(buf, buf.length);
>> }
>
> wow. Those are bad bugs - I guess you're one of the first people to try to use copyFrom. I wonder if it ever worked or if those bugs crept in by accident somehow. Have you sent the fix to Walter? Just email him the fixed file. I would add a unittest, too, if you have time since I notice it isn't tested anywhere.

actually there's another change to std.stream that I want to send to Walter so I'll just put your changes in with mine.


March 26, 2005
Actually, I was just reading the source because I'm thinking of using Stream in the future and saw it.  Thanks for sending the fix.


In article <d2016e$1hdj$1@digitaldaemon.com>, Ben Hinkle says...
>
>
>"Ben Hinkle" <ben.hinkle@gmail.com> wrote in message news:d200sa$1gvm$1@digitaldaemon.com...
>>
>> <derick_eddington@nospam.dot.yahoo.dot.com> wrote in message news:d1vuka$1ed1$1@digitaldaemon.com...
>>> std.stream.Stream.copyFrom(Stream):
>>>
>>> void copyFrom(Stream s)
>>> {
>>> //BUG  uint pos = position();    // not position of this
>>> uint pos = s.position();     // save position of s
>>> s.position(0);
>>> copyFrom(s, s.size());
>>> s.position(pos);
>>> }
>>>
>>>
>>> std.stream.Stream.copyFrom(Stream, uint):
>>>
>>> void copyFrom(Stream s, uint count)
>>> {
>>> ubyte[] buf;
>>> //BUG  buf.length = s.size();    // not size of s
>>> buf.length = count;          // use specified size
>>> s.readExact(buf, buf.length);
>>> writeExact(buf, buf.length);
>>> }
>>
>> wow. Those are bad bugs - I guess you're one of the first people to try to use copyFrom. I wonder if it ever worked or if those bugs crept in by accident somehow. Have you sent the fix to Walter? Just email him the fixed file. I would add a unittest, too, if you have time since I notice it isn't tested anywhere.
>
>actually there's another change to std.stream that I want to send to Walter so I'll just put your changes in with mine.
>
>


March 27, 2005
In article <d1vuka$1ed1$1@digitaldaemon.com>, derick_eddington@nospam.dot.yahoo.dot.com says...
>
>void copyFrom(Stream s, uint count)
>{
>  ubyte[] buf;
>  //BUG  buf.length = s.size();    // not size of s
>  buf.length = count;          // use specified size
>  s.readExact(buf, buf.length);
>  writeExact(buf, buf.length);
>}

By the way, is it not a bit risky to assume the entire stream can fit in a memory buffer?

And is it really appropriate to use uints for stream sizes? Why not use ulongs?

Nick