From e6a2df9c7a013ac1db0ead439680eddfb4ef7892 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 2 Dec 2016 16:01:43 +0100 Subject: [PATCH] Changed: Constification of addSlashR and removeSlashR --- code/nel/include/nel/misc/string_common.h | 4 ++-- code/nel/src/misc/string_common.cpp | 6 +++--- code/nel/src/net/email.cpp | 11 ++--------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/code/nel/include/nel/misc/string_common.h b/code/nel/include/nel/misc/string_common.h index b8a12ad77..2839c2bfc 100644 --- a/code/nel/include/nel/misc/string_common.h +++ b/code/nel/include/nel/misc/string_common.h @@ -28,8 +28,8 @@ namespace NLMISC { // get a string and add \r before \n if necessary -std::string addSlashR (std::string str); -std::string removeSlashR (std::string str); +std::string addSlashR (const std::string &str); +std::string removeSlashR (const std::string &str); /** * \def MaxCStringSize diff --git a/code/nel/src/misc/string_common.cpp b/code/nel/src/misc/string_common.cpp index dd8d1fe96..9c9085e4e 100644 --- a/code/nel/src/misc/string_common.cpp +++ b/code/nel/src/misc/string_common.cpp @@ -27,7 +27,7 @@ using namespace std; namespace NLMISC { -string addSlashR (string str) +string addSlashR (const string &str) { string formatedStr; // replace \n with \r\n @@ -42,10 +42,10 @@ string addSlashR (string str) return formatedStr; } -string removeSlashR (string str) +string removeSlashR (const string &str) { string formatedStr; - // replace \n with \r\n + // remove \r for (uint i = 0; i < str.size(); i++) { if (str[i] != '\r') diff --git a/code/nel/src/net/email.cpp b/code/nel/src/net/email.cpp index 9ac22c886..f402edd65 100644 --- a/code/nel/src/net/email.cpp +++ b/code/nel/src/net/email.cpp @@ -196,15 +196,8 @@ bool sendEmail (const string &smtpServer, const string &from, const string &to, // we must skip the first line formatedBody = "\r\n"; - // replace \n with \r\n - for (i = 0; i < body.size(); i++) - { - if (body[i] == '\n' && i > 0 && body[i-1] != '\r') - { - formatedBody += '\r'; - } - formatedBody += body[i]; - } + // replace \n by \r\n + formatedBody += addSlashR(body); // add attachment if any if (!attachedFile.empty())