summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-16 19:28:16 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-16 19:28:16 +0300
commitcd24ed1c6c5aab358b4f18d262bd4c00c0ebfe96 (patch)
treefdda7e2c3d93b35771f6eb79c22dce9301082f19 /src/utils
parentf8fc3380197c078a6dcff02351d835c3022411e1 (diff)
downloadmv-cd24ed1c6c5aab358b4f18d262bd4c00c0ebfe96.tar.gz
mv-cd24ed1c6c5aab358b4f18d262bd4c00c0ebfe96.tar.bz2
mv-cd24ed1c6c5aab358b4f18d262bd4c00c0ebfe96.tar.xz
mv-cd24ed1c6c5aab358b4f18d262bd4c00c0ebfe96.zip
Add const to variables with type size_t.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/mkdir.cpp2
-rw-r--r--src/utils/paths.cpp2
-rw-r--r--src/utils/stringutils.cpp20
-rw-r--r--src/utils/translation/translationmanager.cpp2
4 files changed, 13 insertions, 13 deletions
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index e07b3979f..c7cacf0cb 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -113,7 +113,7 @@ int mkdir_r(const char *const pathname)
/// Create a directory, making leading components first if necessary
int mkdir_r(const char *const pathname)
{
- size_t len = static_cast<int>(strlen(pathname));
+ const size_t len = static_cast<int>(strlen(pathname));
char *tmp = new char[len + 2];
char *p;
diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp
index 05a00c1ea..11ad19a2e 100644
--- a/src/utils/paths.cpp
+++ b/src/utils/paths.cpp
@@ -88,7 +88,7 @@ std::string &fixDirSeparators(std::string &str)
std::string removeLast(std::string str)
{
size_t pos2 = str.rfind("/");
- size_t pos3 = str.rfind("\\");
+ const size_t pos3 = str.rfind("\\");
if (pos3 != std::string::npos)
{
if (pos2 == std::string::npos || pos3 > pos2)
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 2daad464b..2ceab5b92 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -186,7 +186,7 @@ const std::string findSameSubstringI(const std::string &s1,
toLower(str1);
toLower(str2);
- size_t minLength = str1.length() > str2.length()
+ const size_t minLength = str1.length() > str2.length()
? str2.length() : str1.length();
for (size_t f = 0; f < minLength; f ++)
{
@@ -256,11 +256,11 @@ unsigned int decodeStr(const std::string &str)
std::string extractNameFromSprite(std::string str)
{
- size_t pos1 = str.rfind(".");
+ const size_t pos1 = str.rfind(".");
if (pos1 != std::string::npos)
{
size_t pos2 = str.rfind("/");
- size_t pos3 = str.rfind("\\");
+ const size_t pos3 = str.rfind("\\");
if (pos3 != std::string::npos)
{
if (pos2 == std::string::npos || pos3 > pos2)
@@ -278,12 +278,12 @@ std::string extractNameFromSprite(std::string str)
std::string removeSpriteIndex(std::string str)
{
- size_t pos1 = str.rfind("[");
+ const size_t pos1 = str.rfind("[");
if (pos1 != std::string::npos)
{
size_t pos2 = str.rfind("/");
- size_t pos3 = str.rfind("\\");
+ const size_t pos3 = str.rfind("\\");
if (pos3 != std::string::npos)
{
if (pos2 == std::string::npos || pos3 > pos2)
@@ -321,7 +321,7 @@ void getSafeUtf8String(std::string text, char *const buf)
std::string getFileName(std::string path)
{
size_t pos1 = path.rfind("/");
- size_t pos2 = path.rfind("\\");
+ const size_t pos2 = path.rfind("\\");
if (pos1 == std::string::npos)
pos1 = pos2;
else if (pos2 != std::string::npos && pos2 > pos1)
@@ -335,7 +335,7 @@ std::string getFileName(std::string path)
std::string getFileDir(std::string path)
{
size_t pos1 = path.rfind("/");
- size_t pos2 = path.rfind("\\");
+ const size_t pos2 = path.rfind("\\");
if (pos1 == std::string::npos)
pos1 = pos2;
else if (pos2 != std::string::npos && pos2 > pos1)
@@ -477,7 +477,7 @@ std::string combineDye(std::string file, std::string dye)
{
if (dye.empty())
return file;
- size_t pos = file.find_last_of("|");
+ const size_t pos = file.find_last_of("|");
if (pos != std::string::npos)
return file.substr(0, pos) + "|" + dye;
return file + "|" + dye;
@@ -488,7 +488,7 @@ std::string combineDye2(std::string file, std::string dye)
if (dye.empty())
return file;
- size_t pos = file.find_last_of("|");
+ const size_t pos = file.find_last_of("|");
if (pos != std::string::npos)
{
std::string dye1 = file.substr(pos + 1);
@@ -611,7 +611,7 @@ bool findCutFirst(std::string &str1, std::string str2)
std::string &removeProtocol(std::string &url)
{
- size_t i = url.find("://");
+ const size_t i = url.find("://");
if (i != std::string::npos)
url = url.substr(i + 3);
return url;
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
index 110353baf..fe5d0951a 100644
--- a/src/utils/translation/translationmanager.cpp
+++ b/src/utils/translation/translationmanager.cpp
@@ -109,7 +109,7 @@ bool TranslationManager::translateFile(const std::string &fileName,
{
if (pos1 == oldPos1)
break; // detected infinite loop
- size_t pos2 = str.find(">>", pos1 + 2);
+ const size_t pos2 = str.find(">>", pos1 + 2);
if (pos2 == std::string::npos)
break;
const std::string key = str.substr(pos1 + 2, pos2 - pos1 - 2);