[shared] StorageFunction::nameWithArgument uses

SymbolAbstract::TruncateExtension instead of reimplementing it
This commit is contained in:
Émilie Feral
2018-10-18 17:48:35 +02:00
parent 651a86b8fa
commit 1205dc50e6

View File

@@ -29,16 +29,9 @@ void StorageFunction::setActive(bool active) {
int StorageFunction::nameWithArgument(char * buffer, size_t bufferSize, char arg) {
const char * functionName = fullName();
size_t index = 0;
k_parenthesedArgument[1] = arg;
while (*functionName != Ion::Storage::k_dotChar
&& index < bufferSize - k_parenthesedArgumentLength - 1)
{
// We keep room to write the final "(x)" //TODO should we?
assert(functionName < fullName() + strlen(fullName()));
buffer[index++] = *functionName++;
}
return index + strlcpy(&buffer[index], k_parenthesedArgument, bufferSize-index);
size_t baseNameLength = SymbolAbstract::TruncateExtension(buffer, functionName, bufferSize - k_parenthesedArgumentLength);
return baseNameLength + strlcpy(&buffer[baseNameLength], k_parenthesedArgument, bufferSize-baseNameLength);
}
template<typename T>