Bugs in StringArray::joinIntoString with 2 elements array?

First lines of StringArray::joinIntoString function body:


const int last = (numberToJoin < 0) ? size()  // <-----------  HERE (A)
                                    : jmin (size(), start + numberToJoin);

if (start < 0)
    start = 0;

if (start >= last)
    return String::empty;

if (start == last - 1) // <---------- HERE (B)
    return *(const String*)(strings.getLast());

I suppose the test in (B) should be:

  if (start == last)

because with 2 element arrays and with start=0 and numberToJoin=1 then the function is returning the last element, not the first one as it should.

Also, I suppose the calculation of ‘last’ (A) is wrong and that ti should be like this:


  const int last = (numberToJoin < 0) ? size()-1
                                    : jmin (size()-1, start + numberToJoin);

… (notice the "-1"s) so that it will point to the last element of the array.

Am I out for track?
Toot

Hi there

Thanks for spotting that - yes, it is a little bit wrong, though it looks to me like the only change needed is this:

if (start == last - 1) return *(const String*) strings [start];

…does that seem sensible?