|
Boost : |
From: Andrew Walrond (andrew_at_[hidden])
Date: 2006-01-11 10:13:26
Does this patch look correct? I have been trying to extend the copy algorithm
using the Boost::parameter library, and these couple things looked wrong to me.
Andrew Walrond
--- /include/boost/iostreams/copy.hpp 2005-05-26 09:37:30.000000000 +0100
+++ copy.hpp 2006-01-11 14:51:15.000000000 +0000
@@ -49,7 +49,7 @@
typedef pair<char_type*, char_type*> pair_type;
pair_type p1 = iostreams::input_sequence(src);
pair_type p2 = iostreams::output_sequence(snk);
- if (p1.second - p1.first < p2.second - p2.first) {
+ if (p1.second - p1.first <= p2.second - p2.first) {
std::copy(p1.first, p1.second, p2.first);
return static_cast<streamsize>(p1.second - p1.first);
} else {
@@ -92,9 +92,10 @@
while (!done) {
streamsize amt;
done = (amt = iostreams::read(src, buf.data(), buffer_size)) == -1;
- std::copy(buf.data(), buf.data() + amt, p.first + total);
- if (amt != -1)
+ if (amt != -1) {
+ std::copy(buf.data(), buf.data() + amt, p.first + total);
total += amt;
+ }
}
return total;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk