# HG changeset patch # User Jaroslav Hajek # Date 1235458404 -3600 # Node ID 3b5a99b6357010a9be93cd5d717c0c3fe7dc8a36 # Parent a08f22ff5ba18419453e528fcfe006d795576750 backport sorting fixes diff -r a08f22ff5ba1 -r 3b5a99b63570 liboctave/ChangeLog --- a/liboctave/ChangeLog Tue Feb 24 07:48:33 2009 +0100 +++ b/liboctave/ChangeLog Tue Feb 24 07:53:24 2009 +0100 @@ -1,3 +1,8 @@ +2009-02-05 Jaroslav Hajek + + * oct-sort.cc (octave_sort::merge_hi): std::copy -> + std::copy_backward where appropriate. + 2008-01-15 Rafael Laboissiere * oct-md5.cc: Include . diff -r a08f22ff5ba1 -r 3b5a99b63570 liboctave/oct-sort.cc --- a/liboctave/oct-sort.cc Tue Feb 24 07:48:33 2009 +0100 +++ b/liboctave/oct-sort.cc Tue Feb 24 07:53:24 2009 +0100 @@ -29,8 +29,9 @@ replacing PyObject* with the type of the class T. * replaced usages of malloc, free, memcpy and memmove by standard C++ - new [], delete [] and std::copy. Note that replacing memmove by std::copy - is possible if the destination starts before the source. + new [], delete [] and std::copy and std::copy_backward. Note that replacing + memmove by std::copy is possible if the destination starts before the source. + If not, std::copy_backward needs to be used. The Python license is @@ -731,7 +732,7 @@ { dest -= k; pa -= k; - std::copy (pa+1, pa+1 + k, dest+1); + std::copy_backward (pa+1, pa+1 + k, dest+1 + k); na -= k; if (na == 0) goto Succeed; @@ -782,7 +783,7 @@ /* The first element of pb belongs at the front of the merge. */ dest -= na; pa -= na; - std::copy (pa+1, pa+1 + na, dest+1); + std::copy_backward (pa+1, pa+1 + na, dest+1 + na); *dest = *pb; return 0;