mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Tier1: exclude delimiter from split string
A string "test3,test4" using the delimiter ',' would be split into "test3," and "test4", but should be "test3" and "test4". The delimiter should not be included. This patch fixes the issue.
This commit is contained in:
parent
7e1e4e902a
commit
057a2c801a
@ -446,7 +446,15 @@ void V_SplitString2(const char* pString, const char** pSeparators, ssize_t nSepa
|
||||
|
||||
if (pFirstSeparator > pCurPos)
|
||||
{
|
||||
outStrings.AddToTail(AllocString(pCurPos, pFirstSeparator - pCurPos));
|
||||
const ssize_t nLen = (pFirstSeparator-1) - pCurPos;
|
||||
char* const pSplit = AllocString(pCurPos, nLen);
|
||||
|
||||
// We need to terminate the array here since we copy the string
|
||||
// from the list minus the delimiter, and AllocString assumes
|
||||
// the null is already in the source buffer (also reserving
|
||||
// space for it). therefore we need len+1 to terminate it.
|
||||
pSplit[nLen + 1] = '\0';
|
||||
outStrings.AddToTail(pSplit);
|
||||
}
|
||||
|
||||
pCurPos = pFirstSeparator + separatorLen;
|
||||
|
Loading…
x
Reference in New Issue
Block a user