www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - stream copyfrom(Stream s, uint count) method mistake?

reply "Rick S." <flvstrahl2 hotmail.com> writes:
I don't know if this is pertinent, but I was just wondering, in the file
stream.d, the copyFrom(Stream s, uint count) method does not seem to utilize
the count parameter and doesnt seem to function correctly. Am I right in
this assumption? Here is the code.

 // copies specified number of bytes from given stream into
  // this one, may throw ReadError or WriteError on failure
  void copyFrom(Stream s, uint count)
  {
    ubyte[] buf;
    buf.length = s.size();
    s.readExact(buf, buf.length);
    writeExact(buf, buf.length);
  }



Shouldn't it be something like

 // copies specified number of bytes from given stream into
  // this one, may throw ReadError or WriteError on failure
  void copyFrom(Stream s, uint count)
  {
    ubyte[] buf;
    buf.length = count;
    s.readExact(buf, buf.length);
    writeExact(buf, buf.length);
  }

I wanted to test this but that leaves me to my next question. If we make
personal changes to the D source code, how do we make it so next time we run
the compiler, these changes go inter effect?

Sorry if this was already a noted bug.
Jun 16 2004
next sibling parent reply Charlie <Charlie_member pathlink.com> writes:
It indeed looks like a bug, im not surprised.

how do we make it so next time we run
the compiler, these changes go inter effect?

Youll need to rebuild phobos ( each time a new compiler comes out ) , see dmd/src/win32.mak . I wish someone would teach Walter how to delegate ... maybe he doubts our abilities. Charlie In article <caqv7i$24a9$1 digitaldaemon.com>, Rick S. says...
I don't know if this is pertinent, but I was just wondering, in the file
stream.d, the copyFrom(Stream s, uint count) method does not seem to utilize
the count parameter and doesnt seem to function correctly. Am I right in
this assumption? Here is the code.

 // copies specified number of bytes from given stream into
  // this one, may throw ReadError or WriteError on failure
  void copyFrom(Stream s, uint count)
  {
    ubyte[] buf;
    buf.length = s.size();
    s.readExact(buf, buf.length);
    writeExact(buf, buf.length);
  }



Shouldn't it be something like

 // copies specified number of bytes from given stream into
  // this one, may throw ReadError or WriteError on failure
  void copyFrom(Stream s, uint count)
  {
    ubyte[] buf;
    buf.length = count;
    s.readExact(buf, buf.length);
    writeExact(buf, buf.length);
  }

I wanted to test this but that leaves me to my next question. If we make
personal changes to the D source code, how do we make it so next time we run
the compiler, these changes go inter effect?

Sorry if this was already a noted bug.

Jun 16 2004
parent Brad Anderson <brad sankaty.dot.com> writes:
It's been discussed before, but what about getting a bug tracker and 
source code management for Phobos.  I would be happy to host Phobos at 
dsource.org.

http://projects.edgewall.com/trac/

The above link is a product that I am attempting to rig up to dsource so 
you can have Subversion browsing, Changesets, Wiki, Ticket Tracker, and 
Roadmap, all integrated.  (a good example: 
http://projects.edgewall.com/trac/ticket/461 - they put the patch in a 
comment, not as an attachment, but whatever)

Walter would have write-access to Subversion, and all of us yahoos can 
submit patches as attachments to tickets.  Walter can patch the source, 
resolve the tickets, and include the code in the next build.  He could 
even delegate, as Charlie said, to someone worthy (i.e. not me).

At some point, Linus had to get some good lieutenants.  I know we're 
pre-1.0, but Walter's pounding out a compiler, language spec website, 
standard library, and listening to us whine about a whole lot of stuff 
in the NG.  Maybe this is a good starting point to offloading some of 
Walter's plate.

Or he could stay status-quo with his Outlook Express folders.  It's up 
to Walter.  Either way, we still get to use DMD and Phobos, and that's 
pretty cool.

BA





Charlie wrote:
 It indeed looks like a bug, im not surprised.
 
 
how do we make it so next time we run
the compiler, these changes go inter effect?

Youll need to rebuild phobos ( each time a new compiler comes out ) , see dmd/src/win32.mak . I wish someone would teach Walter how to delegate ... maybe he doubts our abilities. Charlie In article <caqv7i$24a9$1 digitaldaemon.com>, Rick S. says...
I don't know if this is pertinent, but I was just wondering, in the file
stream.d, the copyFrom(Stream s, uint count) method does not seem to utilize
the count parameter and doesnt seem to function correctly. Am I right in
this assumption? Here is the code.

// copies specified number of bytes from given stream into
 // this one, may throw ReadError or WriteError on failure
 void copyFrom(Stream s, uint count)
 {
   ubyte[] buf;
   buf.length = s.size();
   s.readExact(buf, buf.length);
   writeExact(buf, buf.length);
 }



Shouldn't it be something like

// copies specified number of bytes from given stream into
 // this one, may throw ReadError or WriteError on failure
 void copyFrom(Stream s, uint count)
 {
   ubyte[] buf;
   buf.length = count;
   s.readExact(buf, buf.length);
   writeExact(buf, buf.length);
 }

I wanted to test this but that leaves me to my next question. If we make
personal changes to the D source code, how do we make it so next time we run
the compiler, these changes go inter effect?

Sorry if this was already a noted bug.


Jun 18 2004
prev sibling parent Ben Hinkle <bhinkle4 juno.com> writes:
Rick S. wrote:

 I don't know if this is pertinent, but I was just wondering, in the file
 stream.d, the copyFrom(Stream s, uint count) method does not seem to
 utilize the count parameter and doesnt seem to function correctly. Am I
 right in this assumption? Here is the code.
 
  // copies specified number of bytes from given stream into
   // this one, may throw ReadError or WriteError on failure
   void copyFrom(Stream s, uint count)
   {
     ubyte[] buf;
     buf.length = s.size();
     s.readExact(buf, buf.length);
     writeExact(buf, buf.length);
   }
 
 
 
 Shouldn't it be something like
 
  // copies specified number of bytes from given stream into
   // this one, may throw ReadError or WriteError on failure
   void copyFrom(Stream s, uint count)
   {
     ubyte[] buf;
     buf.length = count;
     s.readExact(buf, buf.length);
     writeExact(buf, buf.length);
   }

Good catch. It's too bad it always allocates a new buffer, too. All that garbage... sigh. An optional buffer input might be nice: void copyFrom(Stream s, uint count, ubyte[] buf = null) { if (buf.length == 0) buf.length = count; do { uint bufcount = count > buf.length ? buf.length : count; s.readExact(buf, bufcount); writeExact(buf, bufcount); count -= buf.length; } while (count > 0) }
 I wanted to test this but that leaves me to my next question. If we make
 personal changes to the D source code, how do we make it so next time we
 run the compiler, these changes go inter effect?
 
 Sorry if this was already a noted bug.

Try sending Walter some email. Since the code fragment is small he might just pop it in himself once he sees it here.
Jun 17 2004