|
|
|
@ -47,22 +47,22 @@ STRPTR StringArrayJoinedParts(StringArray array, BYTE linkCharacter, ULONG start |
|
|
|
|
ULONG index = 0; |
|
|
|
|
ULONG cursor = 0; |
|
|
|
|
STRPTR result = NULL; |
|
|
|
|
ULONG howManyParts = MIN(maxParts, SizeOfArray(array)); |
|
|
|
|
ULONG lastIndex = MIN(startIndex+maxParts, SizeOfArray(array)-1); |
|
|
|
|
|
|
|
|
|
if( howManyParts <= 0 ) |
|
|
|
|
if( lastIndex-startIndex < 0 ) |
|
|
|
|
{ |
|
|
|
|
return (STRPTR)AllocVec(1, MEMF_CLEAR); //return an empty string
|
|
|
|
|
} |
|
|
|
|
for( index = startIndex; index < howManyParts; index++ ) |
|
|
|
|
for( index = startIndex; index < lastIndex; index++ ) |
|
|
|
|
{ |
|
|
|
|
requiredSize += strlen(StringArrayValues(array)[index]); |
|
|
|
|
} |
|
|
|
|
requiredSize += (howManyParts - 1); // add the joins
|
|
|
|
|
requiredSize += (maxParts == 0 ? 0 : maxParts - 1); // add the join characters
|
|
|
|
|
|
|
|
|
|
requiredSize += 1; // trailing NULL
|
|
|
|
|
|
|
|
|
|
result = AllocVec(requiredSize, MEMF_CLEAR); |
|
|
|
|
for( index = startIndex; index < howManyParts; index++ ) |
|
|
|
|
for( index = startIndex; index < lastIndex; index++ ) |
|
|
|
|
{ |
|
|
|
|
CONST_STRPTR entry = StringArrayValues(array)[index]; |
|
|
|
|
CopyMem((STRPTR)entry, result+cursor, strlen(entry)); |
|
|
|
|