ChatON: Cleanup/Refine initial go at tmpl_apply_ex_capi

This commit is contained in:
HanishKVC 2024-05-07 11:44:25 +05:30
parent 7c288d3dfc
commit 43a3a91b03

View file

@ -608,7 +608,10 @@ inline int32_t chaton_tmpl_apply_ex_capi(
std::string taggedMsgs; std::string taggedMsgs;
std::string types; std::string types;
std::vector<int> lens; std::vector<int> lens;
int32_t taggedLength = chaton_tmpl_apply_ex(tmpl, vMsgs, taggedMsgs, types, lens, alertAssistantAtEnd); if (!chaton_tmpl_apply_ex(tmpl, vMsgs, taggedMsgs, types, lens, alertAssistantAtEnd)) {
return -1;
}
int32_t taggedLength = taggedMsgs.size();
if (taggedLength <= 0) { if (taggedLength <= 0) {
return taggedLength; return taggedLength;
} }
@ -616,11 +619,15 @@ inline int32_t chaton_tmpl_apply_ex_capi(
strlcpy(dest, taggedMsgs.c_str(), destLength); strlcpy(dest, taggedMsgs.c_str(), destLength);
} }
if (*pNumParts > 0) { if (*pNumParts > 0) {
if (partTypes != nullptr) {
strlcpy(partTypes, types.c_str(), *pNumParts); strlcpy(partTypes, types.c_str(), *pNumParts);
}
if (partLengths != nullptr) {
for(int i=0; i < *pNumParts; i++) { for(int i=0; i < *pNumParts; i++) {
partLengths[i] = lens[i]; partLengths[i] = lens[i];
} }
} }
}
*pNumParts = types.length(); *pNumParts = types.length();
return taggedLength; return taggedLength;
} }