scrawl 9 years ago
parent 1a654fa451
commit f875597be5

@ -44,7 +44,7 @@ public:
typename Entry::childen_t::iterator current;
typename Entry::childen_t::iterator next;
current = mRoot.mChildren.find (tolower (*keyword.begin()));
current = mRoot.mChildren.find (Misc::StringUtils::toLower (*keyword.begin()));
if (current == mRoot.mChildren.end())
return false;
else if (current->second.mKeyword.size() && Misc::StringUtils::ciEqual(current->second.mKeyword, keyword))
@ -55,7 +55,7 @@ public:
for (Point i = ++keyword.begin(); i != keyword.end(); ++i)
{
next = current->second.mChildren.find(tolower (*i));
next = current->second.mChildren.find(Misc::StringUtils::toLower (*i));
if (next == current->second.mChildren.end())
return false;
if (Misc::StringUtils::ciEqual(next->second.mKeyword, keyword))
@ -89,7 +89,7 @@ public:
// check first character
typename Entry::childen_t::iterator candidate = mRoot.mChildren.find (tolower (*i));
typename Entry::childen_t::iterator candidate = mRoot.mChildren.find (Misc::StringUtils::toLower (*i));
// no match, on to next character
if (candidate == mRoot.mChildren.end ())
@ -104,7 +104,7 @@ public:
while ((j + 1) != end)
{
typename Entry::childen_t::iterator next = candidate->second.mChildren.find (tolower (*++j));
typename Entry::childen_t::iterator next = candidate->second.mChildren.find (Misc::StringUtils::toLower (*++j));
if (next == candidate->second.mChildren.end ())
{
@ -136,7 +136,7 @@ public:
while (k != end && t != candidate->second.mKeyword.end ())
{
if (tolower (*k) != tolower (*t))
if (Misc::StringUtils::toLower (*k) != Misc::StringUtils::toLower (*t))
break;
++k, ++t;
@ -212,7 +212,7 @@ private:
void seed_impl (string_t keyword, value_t value, size_t depth, Entry & entry)
{
int ch = tolower (keyword.at (depth));
int ch = Misc::StringUtils::toLower (keyword.at (depth));
typename Entry::childen_t::iterator j = entry.mChildren.find (ch);

@ -365,7 +365,7 @@ namespace MWGui
/* Is the beginning of the string different from the input string? If yes skip it. */
for( std::string::iterator iter=tmp.begin(), iter2=(*it).begin(); iter < tmp.end();++iter, ++iter2) {
if( tolower(*iter) != tolower(*iter2) ) {
if( Misc::StringUtils::toLower(*iter) != Misc::StringUtils::toLower(*iter2) ) {
string_different=true;
break;
}
@ -405,7 +405,7 @@ namespace MWGui
for(std::string::iterator iter=matches.front().begin()+tmp.length(); iter < matches.front().end(); ++iter, ++i) {
for(std::vector<std::string>::iterator it=matches.begin(); it < matches.end();++it) {
if( tolower((*it)[i]) != tolower(*iter) ) {
if( Misc::StringUtils::toLower((*it)[i]) != Misc::StringUtils::toLower(*iter) ) {
/* Append the longest match to the end of the output string*/
output.append(matches.front().substr( 0, i));
return output;

@ -315,7 +315,7 @@ struct JournalViewModelImpl : JournalViewModel
for (MWBase::Journal::TTopicIter i = journal->topicBegin (); i != journal->topicEnd (); ++i)
{
if (i->first [0] != tolower (character))
if (i->first [0] != Misc::StringUtils::toLower(character))
continue;
visitor (i->second.getName());

@ -8,6 +8,8 @@
#include <unistd.h>
#include <boost/filesystem/fstream.hpp>
#include <components/misc/stringops.hpp>
namespace
{
@ -139,7 +141,7 @@ boost::filesystem::path LinuxPath::getInstallPath() const
{
// Change drive letter to lowercase, so we could use
// ~/.wine/dosdevices symlinks
mwpath[0] = tolower(mwpath[0]);
mwpath[0] = Misc::StringUtils::toLower(mwpath[0]);
installPath /= homePath;
installPath /= ".wine/dosdevices/";
installPath /= mwpath;

@ -7,6 +7,8 @@
#include <unistd.h>
#include <boost/filesystem/fstream.hpp>
#include <components/misc/stringops.hpp>
namespace
{
boost::filesystem::path getUserHome()
@ -129,7 +131,7 @@ boost::filesystem::path MacOsPath::getInstallPath() const
if (!mwpath.empty())
{
// Change drive letter to lowercase, so we could use ~/.wine/dosdevice symlinks
mwpath[0] = tolower(mwpath[0]);
mwpath[0] = Misc::StringUtils::toLower(mwpath[0]);
installPath /= homePath;
installPath /= ".wine/dosdevices/";
installPath /= mwpath;

@ -8,6 +8,8 @@
#include <boost/filesystem.hpp>
#include <components/misc/stringops.hpp>
namespace Files
{
struct NameEqual
@ -28,8 +30,8 @@ namespace Files
for (std::size_t i=0; i<len; ++i)
{
char l = tolower (left[i]);
char r = tolower (right[i]);
char l = Misc::StringUtils::toLower (left[i]);
char r = Misc::StringUtils::toLower (right[i]);
if (l!=r)
return false;

@ -8,6 +8,8 @@
#include <boost/filesystem/path.hpp>
#include <components/misc/stringops.hpp>
namespace Files
{
typedef std::vector<boost::filesystem::path> PathContainer;
@ -27,8 +29,8 @@ namespace Files
for (std::size_t i=0; i<min; ++i)
{
char l = tolower (left[i]);
char r = tolower (right[i]);
char l = Misc::StringUtils::toLower (left[i]);
char r = Misc::StringUtils::toLower (right[i]);
if (l<r)
return true;

@ -1,11 +1,12 @@
#include "defines.hpp"
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <iostream>
#include <components/misc/stringops.hpp>
namespace Interpreter{
bool check(const std::string& str, const std::string& escword, unsigned int* i, unsigned int* start)
@ -35,7 +36,7 @@ namespace Interpreter{
{
retval << text.substr(start, i - start);
std::string temp = text.substr(i+1, 100);
transform(temp.begin(), temp.end(), temp.begin(), ::tolower);
Misc::StringUtils::lowerCase(temp);
bool found = false;
try

@ -12,11 +12,49 @@ class StringUtils
struct ci
{
bool operator()(char x, char y) const {
return tolower(x) < tolower(y);
return toLower(x) < toLower(y);
}
};
public:
/// Plain and simple locale-unaware toLower. Anything from A to Z is lower-cased, multibyte characters are unchanged.
/// Don't use std::tolower(char, locale&) because that is abysmally slow.
/// Don't use tolower(int) because that depends on global locale.
static char toLower(char c)
{
switch(c)
{
case 'A':return 'a';
case 'B':return 'b';
case 'C':return 'c';
case 'D':return 'd';
case 'E':return 'e';
case 'F':return 'f';
case 'G':return 'g';
case 'H':return 'h';
case 'I':return 'i';
case 'J':return 'j';
case 'K':return 'k';
case 'L':return 'l';
case 'M':return 'm';
case 'N':return 'n';
case 'O':return 'o';
case 'P':return 'p';
case 'Q':return 'q';
case 'R':return 'r';
case 'S':return 's';
case 'T':return 't';
case 'U':return 'u';
case 'V':return 'v';
case 'W':return 'w';
case 'X':return 'x';
case 'Y':return 'y';
case 'Z':return 'z';
default:return c;
};
}
static bool ciLess(const std::string &x, const std::string &y) {
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), ci());
}
@ -28,7 +66,7 @@ public:
std::string::const_iterator xit = x.begin();
std::string::const_iterator yit = y.begin();
for (; xit != x.end(); ++xit, ++yit) {
if (tolower(*xit) != tolower(*yit)) {
if (toLower(*xit) != toLower(*yit)) {
return false;
}
}
@ -42,7 +80,7 @@ public:
for(;xit != x.end() && yit != y.end() && len > 0;++xit,++yit,--len)
{
int res = *xit - *yit;
if(res != 0 && tolower(*xit) != tolower(*yit))
if(res != 0 && toLower(*xit) != toLower(*yit))
return (res > 0) ? 1 : -1;
}
if(len > 0)
@ -58,7 +96,7 @@ public:
/// Transforms input string to lower case w/o copy
static std::string &toLower(std::string &inout) {
for (unsigned int i=0; i<inout.size(); ++i)
inout[i] = tolower(inout[i]);
inout[i] = toLower(inout[i]);
return inout;
}

@ -3,6 +3,8 @@
#include <cctype>
#include <stdexcept>
#include <components/misc/stringops.hpp>
#include "archive.hpp"
namespace
@ -15,7 +17,7 @@ namespace
char nonstrict_normalize_char(char ch)
{
return ch == '\\' ? '/' : tolower(ch);
return ch == '\\' ? '/' : Misc::StringUtils::toLower(ch);
}
void normalize_path(std::string& path, bool strict)

Loading…
Cancel
Save