diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/copynpaste.cpp | 8 | ||||
-rw-r--r-- | src/utils/copynpaste.h | 2 | ||||
-rw-r--r-- | src/utils/langs.cpp | 12 | ||||
-rw-r--r-- | src/utils/mkdir.cpp | 2 | ||||
-rw-r--r-- | src/utils/sha256.cpp | 3 | ||||
-rw-r--r-- | src/utils/stringutils.cpp | 32 | ||||
-rw-r--r-- | src/utils/translation/translationmanager.cpp | 6 |
7 files changed, 33 insertions, 32 deletions
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index 763b579d0..a53e0b63f 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -39,7 +39,7 @@ #include "debug.h" #ifdef WIN32 -bool retrieveBuffer(std::string& text, std::string::size_type& pos) +bool retrieveBuffer(std::string& text, size_t& pos) { bool ret = false; @@ -262,7 +262,7 @@ PasteboardCreateFailed: return false; } -bool retrieveBuffer(std::string& text, std::string::size_type& pos) +bool retrieveBuffer(std::string& text, size_t& pos) { const int bufSize = 512; char buffer[bufSize + 1]; @@ -365,7 +365,7 @@ static char* getSelection(Display *dpy, Window us, Atom selection) return data; } -bool retrieveBuffer(std::string& text, std::string::size_type& pos) +bool retrieveBuffer(std::string& text, size_t& pos) { SDL_SysWMinfo info; @@ -468,7 +468,7 @@ bool runxsel(std::string& text, const char *p1, const char *p2) } #else -bool retrieveBuffer(std::string&, std::string::size_type&) +bool retrieveBuffer(std::string&, size_t&) { return false; } diff --git a/src/utils/copynpaste.h b/src/utils/copynpaste.h index 5e95a1152..53f00453b 100644 --- a/src/utils/copynpaste.h +++ b/src/utils/copynpaste.h @@ -30,6 +30,6 @@ * @return <code>true</code> when successful or <code>false</code> when there * was a problem retrieving the clipboard buffer. */ -bool retrieveBuffer(std::string& text, std::string::size_type& pos); +bool retrieveBuffer(std::string& text, size_t& pos); bool sendBuffer(std::string& text); diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp index 1aa3e472d..90a83d6c4 100644 --- a/src/utils/langs.cpp +++ b/src/utils/langs.cpp @@ -43,12 +43,12 @@ LangVect getLang() lang = lng; } - int dot = lang.find("."); - if (dot != static_cast<signed>(std::string::npos)) + size_t dot = lang.find("."); + if (dot != std::string::npos) lang = lang.substr(0, dot); langs.push_back(lang); dot = lang.find("_"); - if (dot != static_cast<signed>(std::string::npos)) + if (dot != std::string::npos) langs.push_back(lang.substr(0, dot)); return langs; } @@ -77,11 +77,11 @@ std::string getLangShort() lang = lng; } - int dot = lang.find("."); - if (dot != static_cast<signed>(std::string::npos)) + size_t dot = lang.find("."); + if (dot != std::string::npos) lang = lang.substr(0, dot); dot = lang.find("_"); - if (dot != static_cast<signed>(std::string::npos)) + if (dot != std::string::npos) return lang.substr(0, dot); return lang; } diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp index 582c9c7dc..5eb1b0388 100644 --- a/src/utils/mkdir.cpp +++ b/src/utils/mkdir.cpp @@ -67,7 +67,7 @@ int mkdir_r(const char *pathname) { *p = '\0'; // ignore a slash at the beginning of a path - if (strlen(tmp) == 0) + if (tmp[0] == 0) { *p = '/'; continue; diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp index ac9c78b2a..d28fa43fb 100644 --- a/src/utils/sha256.cpp +++ b/src/utils/sha256.cpp @@ -279,7 +279,8 @@ std::string SHA256Hash(const char *src, int len) unsigned char bytehash[SHA256_DIGEST_SIZE]; SHA256Context ctx; SHA256Init(&ctx); - SHA256Update(&ctx, (unsigned char *)src, (unsigned int)len); + SHA256Update(&ctx, static_cast<unsigned char *>(src), + static_casr<unsigned int>(len)); SHA256Final(&ctx, bytehash); // Convert it to hex const char* hxc = "0123456789abcdef"; diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 5ec7fb931..9d57c58a7 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -36,7 +36,7 @@ static int UTF8_MAX_SIZE = 10; std::string &trim(std::string &str) { - std::string::size_type pos = str.find_last_not_of(' '); + size_t pos = str.find_last_not_of(' '); if (pos != std::string::npos) { str.erase(pos + 1); @@ -110,7 +110,7 @@ std::string strprintf(char const *format, ...) /* std::string &removeBadChars(std::string &str) { - std::string::size_type pos; + size_t pos; do { pos = str.find_first_of("@#[]"); @@ -186,9 +186,9 @@ const std::string findSameSubstringI(const std::string &s1, toLower(str1); toLower(str2); - int minLength = str1.length() > str2.length() - ? static_cast<int>(str2.length()) : static_cast<int>(str1.length()); - for (int f = 0; f < minLength; f ++) + size_t minLength = str1.length() > str2.length() + ? str2.length() : str1.length(); + for (size_t f = 0; f < minLength; f ++) { if (str1.at(f) != str2.at(f)) return s1.substr(0, f); @@ -206,7 +206,7 @@ size_t findI(std::string str, std::string subStr) size_t findI(std::string text, StringVect &list) { std::string str = toLower(text); - unsigned long idx; + size_t idx; for (StringVectCIter i = list.begin(); i != list.end(); ++ i) { std::string subStr = *i; @@ -544,8 +544,8 @@ void deleteCharLeft(std::string &str, unsigned *pos) bool findLast(std::string &str1, std::string str2) { - const unsigned s1 = str1.size(); - const unsigned s2 = str2.size(); + const size_t s1 = str1.size(); + const size_t s2 = str2.size(); if (s1 < s2) return false; std::string tmp = str1.substr(s1 - s2); @@ -556,8 +556,8 @@ bool findLast(std::string &str1, std::string str2) bool findFirst(std::string &str1, std::string str2) { - const unsigned s1 = str1.size(); - const unsigned s2 = str2.size(); + const size_t s1 = str1.size(); + const size_t s2 = str2.size(); if (s1 < s2) return false; std::string tmp = str1.substr(0, s2); @@ -568,8 +568,8 @@ bool findFirst(std::string &str1, std::string str2) bool findCutLast(std::string &str1, std::string str2) { - const unsigned s1 = str1.size(); - const unsigned s2 = str2.size(); + const size_t s1 = str1.size(); + const size_t s2 = str2.size(); if (s1 < s2) return false; std::string tmp = str1.substr(s1 - s2); @@ -583,8 +583,8 @@ bool findCutLast(std::string &str1, std::string str2) bool findCutFirst(std::string &str1, std::string str2) { - const unsigned s1 = str1.size(); - const unsigned s2 = str2.size(); + const size_t s1 = str1.size(); + const size_t s2 = str2.size(); if (s1 < s2) return false; std::string tmp = str1.substr(0, s2); @@ -598,8 +598,8 @@ bool findCutFirst(std::string &str1, std::string str2) std::string &removeProtocol(std::string &url) { - int i = url.find("://"); - if (i != static_cast<int>(std::string::npos)) + 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 2a962913a..81fb612e4 100644 --- a/src/utils/translation/translationmanager.cpp +++ b/src/utils/translation/translationmanager.cpp @@ -105,13 +105,13 @@ bool TranslationManager::translateFile(const std::string &fileName, } std::string str = std::string(fileContents, contentsLength); - std::string::size_type oldPos1 = 0; - std::string::size_type pos1; + size_t oldPos1 = 0; + size_t pos1; while ((pos1 = str.find("<<")) != std::string::npos) { if (pos1 == oldPos1) break; // detected infinite loop - std::string::size_type pos2 = str.find(">>", pos1 + 2); + size_t pos2 = str.find(">>", pos1 + 2); if (pos2 == std::string::npos) break; const std::string key = str.substr(pos1 + 2, pos2 - pos1 - 2); |