T3D 1.1 Beta 3 - getWords returns incorrect number of words when the word count is equal or exceeds that amount in the string - FIXED
by Daniel Eden · in Torque 3D Professional · 09/23/2010 (12:03 am) · 2 replies
Looks like getWords is somewhat broken. It will return the right number of words in every case except when the word count equals or exceeds that of the string (in which case it should be returning the whole string). This means, for example, that if you have six words in a string and try and get all six words -- the last word is always omitted.
To verify, in the console:
It should return the entire string stored in $test. Instead it returns "0AA 1BB 2CC 3DD 4EE ".
The fix should be quite easy. In core/strings/stringUnit.cpp, at line 69, replace:
... with ...
To verify, in the console:
$test = "0AA 1BB 2CC 3DD 4EE 5FF";
echo("Returned '" @ getWords($test, 0, 6) @ "'");It should return the entire string stored in $test. Instead it returns "0AA 1BB 2CC 3DD 4EE ".
The fix should be quite easy. In core/strings/stringUnit.cpp, at line 69, replace:
while(startIndex <= endIndex--)
{
sz = dStrcspn(string, set);
string += sz;
if (*string == 0)
break;
string++;
}... with ...
while(startIndex <= endIndex--)
{
sz = dStrcspn(string, set);
string += sz;
string++;
if (*string == 0)
break;
}
#2
10/06/2010 (6:52 pm)
Rene. Is the solution above the one used to fix it? If not could you post the fix, cause this is causing major bugs for us since this happens a lot with the default parameter of -1 for getWords.
Associate Rene Damm
Yep, thanks for the report. Was noticed by multiple sources and is fixed in the repo.