diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 1af90c871b48fad20adc7cae730d087e6a71488c..a815b15fb3202b8d8354d6fc8fa13c48aa610dd6 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -611,6 +611,41 @@ std::string utf8str_substr(const std::string& utf8str, const S32 index, const S3 return utf8str.substr(index, cur_char); } } + +void utf8str_split(std::list<std::string>& split_list, const std::string& utf8str, size_t maxlen, char split_token) +{ + split_list.clear(); + + std::string::size_type lenMsg = utf8str.length(), lenIt = 0; + + const char* pstrIt = utf8str.c_str(); std::string strTemp; + while (lenIt < lenMsg) + { + if (lenIt + maxlen < lenMsg) + { + // Find the last split character + const char* pstrTemp = pstrIt + maxlen; + while ( (pstrTemp > pstrIt) && (*pstrTemp != split_token) ) + pstrTemp--; + + if (pstrTemp > pstrIt) + strTemp = utf8str.substr(lenIt, pstrTemp - pstrIt); + else + strTemp = utf8str_substr(utf8str, lenIt, maxlen); + } + else + { + strTemp = utf8str.substr(lenIt, std::string::npos); + } + + split_list.push_back(strTemp); + + lenIt += strTemp.length(); + pstrIt = utf8str.c_str() + lenIt; + if (*pstrIt == split_token) + lenIt++; + } +} // [/RLVa:KB] std::string utf8str_symbol_truncate(const std::string& utf8str, const S32 symbol_len) diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index f7d304b55ad73f070ea25f7b5906d190251e8ca9..c9493c30dff6dc8648f16459208a04b238e778f6 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -35,6 +35,9 @@ #include <vector> #include <map> #include "llformat.h" +// [RLVa:KB] - Checked: RLVa-2.1.0 +#include <list> +// [/RLVa:KB] #if LL_LINUX || LL_SOLARIS #include <wctype.h> @@ -559,6 +562,7 @@ LL_COMMON_API std::string utf8str_truncate(const std::string& utf8str, const S32 // [RLVa:KB] - Checked: RLVa-2.1.0 LL_COMMON_API std::string utf8str_substr(const std::string& utf8str, const S32 index, const S32 max_len); +LL_COMMON_API void utf8str_split(std::list<std::string>& split_list, const std::string& utf8str, size_t maxlen, char split_token); // [/RLVa:KB] LL_COMMON_API std::string utf8str_trim(const std::string& utf8str); diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp index 237b10c8697c50e72358e4bb97f451fbc8195412..8d9a87e0341596c3b5db6198941acecb5bfea8b9 100644 --- a/indra/newview/rlvcommon.cpp +++ b/indra/newview/rlvcommon.cpp @@ -613,28 +613,10 @@ void RlvUtil::sendIMMessage(const LLUUID& idRecipient, const std::string& strMsg std::string strAgentName; LLAgentUI::buildFullname(strAgentName); - std::string::size_type lenMsg = strMsg.length(), lenIt = 0; - - const char* pstrIt = strMsg.c_str(); std::string strTemp; - while (lenIt < lenMsg) + std::list<std::string> msgList; + utf8str_split(msgList, strMsg, MAX_MSG_STR_LEN, chSplit); + for (const std::string& strMsg : msgList) { - if (lenIt + MAX_MSG_STR_LEN < lenMsg) - { - // Find the last split character - const char* pstrTemp = pstrIt + MAX_MSG_STR_LEN; - while ( (pstrTemp > pstrIt) && (*pstrTemp != chSplit) ) - pstrTemp--; - - if (pstrTemp > pstrIt) - strTemp = strMsg.substr(lenIt, pstrTemp - pstrIt); - else - strTemp = utf8str_substr(strMsg, lenIt, MAX_MSG_STR_LEN); - } - else - { - strTemp = strMsg.substr(lenIt, std::string::npos); - } - pack_instant_message( gMessageSystem, gAgent.getID(), @@ -642,16 +624,11 @@ void RlvUtil::sendIMMessage(const LLUUID& idRecipient, const std::string& strMsg gAgent.getSessionID(), idRecipient, strAgentName.c_str(), - strTemp.c_str(), - ( (!pBuddyInfo) || (pBuddyInfo->isOnline()) ) ? IM_ONLINE : IM_OFFLINE, + strMsg.c_str(), + ((!pBuddyInfo) || (pBuddyInfo->isOnline())) ? IM_ONLINE : IM_OFFLINE, IM_NOTHING_SPECIAL, idSession); gAgent.sendReliableMessage(); - - lenIt += strTemp.length(); - pstrIt = strMsg.c_str() + lenIt; - if (*pstrIt == chSplit) - lenIt++; } }