mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-12-25 21:59:30 +01:00
Use toLower() and toUpper()
This commit is contained in:
parent
b039d55c81
commit
d55b3b2bdf
12 changed files with 28 additions and 52 deletions
15
dic/dic.cpp
15
dic/dic.cpp
|
@ -22,7 +22,6 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
@ -45,6 +44,7 @@
|
||||||
#include "header.h"
|
#include "header.h"
|
||||||
#include "dic_exception.h"
|
#include "dic_exception.h"
|
||||||
#include "dic_internals.h"
|
#include "dic_internals.h"
|
||||||
|
#include "encoding.h"
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,14 +81,10 @@ Dictionary::Dictionary(const string &iPath)
|
||||||
initializeTiles();
|
initializeTiles();
|
||||||
|
|
||||||
// Concatenate the uppercase and lowercase letters
|
// Concatenate the uppercase and lowercase letters
|
||||||
wstring lower = m_header->getLetters();
|
m_allLetters = m_header->getLetters() + toLower(m_header->getLetters());
|
||||||
std::transform(lower.begin(), lower.end(), lower.begin(), towlower);
|
|
||||||
m_allLetters = m_header->getLetters() + lower;
|
|
||||||
|
|
||||||
// Same for the input characters
|
// Same for the input characters
|
||||||
lower = m_header->getInputChars();
|
m_allInputChars = m_header->getInputChars() + toLower(m_header->getInputChars());
|
||||||
std::transform(lower.begin(), lower.end(), lower.begin(), towlower);
|
|
||||||
m_allInputChars = m_header->getInputChars() + lower;
|
|
||||||
|
|
||||||
// Build the cache for the convertToDisplay() and convertFromInput()
|
// Build the cache for the convertToDisplay() and convertFromInput()
|
||||||
// methods.
|
// methods.
|
||||||
|
@ -100,10 +96,9 @@ Dictionary::Dictionary(const string &iPath)
|
||||||
BOOST_FOREACH(wstring str, it->second)
|
BOOST_FOREACH(wstring str, it->second)
|
||||||
{
|
{
|
||||||
// Make sure the string is in uppercase
|
// Make sure the string is in uppercase
|
||||||
std::transform(str.begin(), str.end(), str.begin(), towupper);
|
str = toUpper(str);
|
||||||
// Make a lowercase copy
|
// Make a lowercase copy
|
||||||
wstring lower = str;
|
wstring lower = toLower(str);
|
||||||
std::transform(lower.begin(), lower.end(), lower.begin(), towlower);
|
|
||||||
// Fill the cache
|
// Fill the cache
|
||||||
m_displayInputCache[towupper(it->first)].push_back(str);
|
m_displayInputCache[towupper(it->first)].push_back(str);
|
||||||
m_displayInputCache[towlower(it->first)].push_back(lower);
|
m_displayInputCache[towlower(it->first)].push_back(lower);
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <cwctype>
|
#include <cwctype>
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "dic_internals.h"
|
#include "dic_internals.h"
|
||||||
#include "dic_exception.h"
|
#include "dic_exception.h"
|
||||||
|
@ -233,8 +232,7 @@ void Dictionary::searchRacc(const wstring &iWord,
|
||||||
// Transform the given word to make it suitable for display
|
// Transform the given word to make it suitable for display
|
||||||
wdstring displayWord = convertToDisplay(iWord);
|
wdstring displayWord = convertToDisplay(iWord);
|
||||||
// Make it uppercase
|
// Make it uppercase
|
||||||
std::transform(displayWord.begin(), displayWord.end(),
|
displayWord = toUpper(displayWord);
|
||||||
displayWord.begin(), towupper);
|
|
||||||
|
|
||||||
// Try to add a letter at the front
|
// Try to add a letter at the front
|
||||||
const wstring &letters = getHeader().getLetters();
|
const wstring &letters = getHeader().getLetters();
|
||||||
|
@ -288,8 +286,7 @@ void Dictionary::searchBenj(const wstring &iWord, vector<wdstring> &oWordList,
|
||||||
// Transform the given word to make it suitable for display
|
// Transform the given word to make it suitable for display
|
||||||
wdstring displayWord = convertToDisplay(iWord);
|
wdstring displayWord = convertToDisplay(iWord);
|
||||||
// Make it uppercase
|
// Make it uppercase
|
||||||
std::transform(displayWord.begin(), displayWord.end(),
|
displayWord = toUpper(displayWord);
|
||||||
displayWord.begin(), towupper);
|
|
||||||
|
|
||||||
const DicEdge *edge0, *edge1, *edge2, *edgetst;
|
const DicEdge *edge0, *edge1, *edge2, *edgetst;
|
||||||
edge0 = getEdgeAt(getRoot());
|
edge0 = getEdgeAt(getRoot());
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "dic.h"
|
#include "dic.h"
|
||||||
#include "header.h"
|
#include "header.h"
|
||||||
|
#include "encoding.h"
|
||||||
#include "regexp.h"
|
#include "regexp.h"
|
||||||
|
|
||||||
using namespace boost::spirit::classic;
|
using namespace boost::spirit::classic;
|
||||||
|
@ -54,9 +55,7 @@ struct RegexpGrammar : grammar<RegexpGrammar>
|
||||||
|
|
||||||
RegexpGrammar(const wstring &letters)
|
RegexpGrammar(const wstring &letters)
|
||||||
{
|
{
|
||||||
wstring lower = letters;
|
m_allLetters = letters + toLower(letters);
|
||||||
std::transform(lower.begin(), lower.end(), lower.begin(), towlower);
|
|
||||||
m_allLetters = letters + lower;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ScannerT>
|
template <typename ScannerT>
|
||||||
|
@ -138,8 +137,7 @@ void evaluate(const Header &iHeader, iter_t const& i, stack<Node*> &evalStack,
|
||||||
|
|
||||||
wstring choiceLetters(i->value.begin(), i->value.end());
|
wstring choiceLetters(i->value.begin(), i->value.end());
|
||||||
// Make sure the letters are in upper case
|
// Make sure the letters are in upper case
|
||||||
std::transform(choiceLetters.begin(), choiceLetters.end(),
|
choiceLetters = toUpper(choiceLetters);
|
||||||
choiceLetters.begin(), towupper);
|
|
||||||
// The dictionary letters are already in upper case
|
// The dictionary letters are already in upper case
|
||||||
const wstring &letters = iHeader.getLetters();
|
const wstring &letters = iHeader.getLetters();
|
||||||
wstring::const_iterator itLetter;
|
wstring::const_iterator itLetter;
|
||||||
|
|
|
@ -637,9 +637,7 @@ wstring Header::writeDisplayAndInput() const
|
||||||
BOOST_FOREACH(const wstring &str, it->second)
|
BOOST_FOREACH(const wstring &str, it->second)
|
||||||
{
|
{
|
||||||
// Make sure the string is uppercase
|
// Make sure the string is uppercase
|
||||||
wstring upStr = str;
|
serialized += L"|" + toUpper(str);
|
||||||
std::transform(upStr.begin(), upStr.end(), upStr.begin(), towupper);
|
|
||||||
serialized += L"|" + upStr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return serialized;
|
return serialized;
|
||||||
|
|
10
dic/tile.cpp
10
dic/tile.cpp
|
@ -21,8 +21,7 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <cwctype>
|
||||||
#include <wctype.h>
|
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
#include "header.h"
|
#include "header.h"
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
|
@ -30,6 +29,9 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
INIT_LOGGER(dic, Tile);
|
INIT_LOGGER(dic, Tile);
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,9 +116,7 @@ wstring Tile::getDisplayStr() const
|
||||||
throw DicException("Tile::getDisplayStr: Invalid tile");
|
throw DicException("Tile::getDisplayStr: Invalid tile");
|
||||||
if (m_joker && iswalpha(m_char))
|
if (m_joker && iswalpha(m_char))
|
||||||
{
|
{
|
||||||
wstring str = m_header->getDisplayStr(m_code);
|
return ::toLower(m_header->getDisplayStr(m_code));
|
||||||
std::transform(str.begin(), str.end(), str.begin(), towlower);
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
return m_header->getDisplayStr(m_code);
|
return m_header->getDisplayStr(m_code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <algorithm> // For transform
|
|
||||||
#include <cwctype> // For towupper
|
|
||||||
|
|
||||||
#include "arbitration.h"
|
#include "arbitration.h"
|
||||||
#include "rack.h"
|
#include "rack.h"
|
||||||
|
@ -62,9 +60,7 @@ void Arbitration::setRackManual(const wstring &iLetters)
|
||||||
// coming from user input. We do not consider a lowercase
|
// coming from user input. We do not consider a lowercase
|
||||||
// letter to be a joker which has been assigned to a letter.
|
// letter to be a joker which has been assigned to a letter.
|
||||||
// As a result, we simply make all the letters uppercase
|
// As a result, we simply make all the letters uppercase
|
||||||
wstring upperLetters = iLetters;
|
const wstring &upperLetters = toUpper(iLetters);
|
||||||
std::transform(upperLetters.begin(), upperLetters.end(),
|
|
||||||
upperLetters.begin(), towupper);
|
|
||||||
const PlayedRack &newRack = helperSetRackManual(false, upperLetters);
|
const PlayedRack &newRack = helperSetRackManual(false, upperLetters);
|
||||||
setGameAndPlayersRack(newRack);
|
setGameAndPlayersRack(newRack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,7 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <wctype.h>
|
#include <cwctype>
|
||||||
#include <algorithm>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "dic.h"
|
#include "dic.h"
|
||||||
|
@ -32,6 +31,7 @@
|
||||||
#include "round.h"
|
#include "round.h"
|
||||||
#include "rack.h"
|
#include "rack.h"
|
||||||
#include "results.h"
|
#include "results.h"
|
||||||
|
#include "encoding.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#define oo 0
|
#define oo 0
|
||||||
|
@ -129,7 +129,7 @@ wstring Board::getDisplayStr(int iRow, int iCol) const
|
||||||
"Trying to get the display string on an empty board square");
|
"Trying to get the display string on an empty board square");
|
||||||
wstring str = getTile(iRow, iCol).getDisplayStr();
|
wstring str = getTile(iRow, iCol).getDisplayStr();
|
||||||
if (isJoker(iRow, iCol))
|
if (isJoker(iRow, iCol))
|
||||||
std::transform(str.begin(), str.end(), str.begin(), towlower);
|
str = toLower(str);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "move.h"
|
#include "move.h"
|
||||||
#include "rack.h"
|
#include "rack.h"
|
||||||
#include "pldrack.h"
|
#include "pldrack.h"
|
||||||
|
#include "encoding.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,8 +60,7 @@ Move::Move(const wstring &iLetters)
|
||||||
: m_score(0), m_letters(iLetters)
|
: m_score(0), m_letters(iLetters)
|
||||||
{
|
{
|
||||||
// Make the letters uppercase
|
// Make the letters uppercase
|
||||||
std::transform(m_letters.begin(), m_letters.end(),
|
m_letters = toUpper(m_letters);
|
||||||
m_letters.begin(), towupper);
|
|
||||||
|
|
||||||
if (m_letters.empty())
|
if (m_letters.empty())
|
||||||
m_type = PASS;
|
m_type = PASS;
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm> // For std::transform
|
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
#include "round.h"
|
#include "round.h"
|
||||||
|
@ -124,7 +123,7 @@ wstring Round::getWord() const
|
||||||
{
|
{
|
||||||
wstring chr = getTile(i).getDisplayStr();
|
wstring chr = getTile(i).getDisplayStr();
|
||||||
if (isJoker(i))
|
if (isJoker(i))
|
||||||
std::transform(chr.begin(), chr.end(), chr.begin(), towlower);
|
chr = toLower(chr);
|
||||||
s += chr;
|
s += chr;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cwctype> // For towupper
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#if ENABLE_NLS
|
#if ENABLE_NLS
|
||||||
# include <libintl.h>
|
# include <libintl.h>
|
||||||
|
@ -77,9 +74,7 @@ void Training::setRackManual(bool iCheck, const wstring &iLetters)
|
||||||
// coming from user input. We do not consider a lowercase
|
// coming from user input. We do not consider a lowercase
|
||||||
// letter to be a joker which has been assigned to a letter.
|
// letter to be a joker which has been assigned to a letter.
|
||||||
// As a result, we simply make all the letters uppercase
|
// As a result, we simply make all the letters uppercase
|
||||||
wstring upperLetters = iLetters;
|
wstring upperLetters = toUpper(iLetters);
|
||||||
std::transform(upperLetters.begin(), upperLetters.end(),
|
|
||||||
upperLetters.begin(), towupper);
|
|
||||||
const PlayedRack &newRack = helperSetRackManual(iCheck, upperLetters);
|
const PlayedRack &newRack = helperSetRackManual(iCheck, upperLetters);
|
||||||
Command *pCmd1 = new GameRackCmd(*this, newRack);
|
Command *pCmd1 = new GameRackCmd(*this, newRack);
|
||||||
pCmd1->setHumanIndependent(false);
|
pCmd1->setHumanIndependent(false);
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <QtGui/QTreeView>
|
#include <QtGui/QTreeView>
|
||||||
#include <QtGui/QStandardItemModel>
|
#include <QtGui/QStandardItemModel>
|
||||||
|
@ -39,6 +38,7 @@
|
||||||
#include "dic.h"
|
#include "dic.h"
|
||||||
#include "header.h"
|
#include "header.h"
|
||||||
#include "listdic.h"
|
#include "listdic.h"
|
||||||
|
#include "encoding.h"
|
||||||
#include "dic_exception.h"
|
#include "dic_exception.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -169,7 +169,7 @@ void DicToolsWidget::refreshCheck()
|
||||||
wstring input = m_dic->convertFromInput(wfq(rack->text()));
|
wstring input = m_dic->convertFromInput(wfq(rack->text()));
|
||||||
bool res = m_dic->searchWord(input);
|
bool res = m_dic->searchWord(input);
|
||||||
// Convert the input to uppercase
|
// Convert the input to uppercase
|
||||||
std::transform(input.begin(), input.end(), input.begin(), towupper);
|
input = toUpper(input);
|
||||||
const wdstring &dispStr = m_dic->convertToDisplay(input);
|
const wdstring &dispStr = m_dic->convertToDisplay(input);
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <algorithm> // For std::transform
|
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
#include <QtGui/QPaintEvent>
|
#include <QtGui/QPaintEvent>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
|
@ -27,6 +26,7 @@
|
||||||
#include "prefs_dialog.h"
|
#include "prefs_dialog.h"
|
||||||
#include "qtcommon.h"
|
#include "qtcommon.h"
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
|
#include "encoding.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -181,9 +181,8 @@ void TileWidget::paintEvent(QPaintEvent *iEvent)
|
||||||
// Draw the letter
|
// Draw the letter
|
||||||
if (!m_tile.isEmpty())
|
if (!m_tile.isEmpty())
|
||||||
{
|
{
|
||||||
wstring chr = m_tile.getDisplayStr();
|
wstring chr = toUpper(m_tile.getDisplayStr());
|
||||||
// Make the display char in upper case
|
// Make the display char in upper case
|
||||||
std::transform(chr.begin(), chr.end(), chr.begin(), towupper);
|
|
||||||
painter.setPen(m_isJoker ? TextJokerColour : TextNormalColour);
|
painter.setPen(m_isJoker ? TextJokerColour : TextNormalColour);
|
||||||
painter.setFont(letterFont);
|
painter.setFont(letterFont);
|
||||||
if (!m_tile.isPureJoker())
|
if (!m_tile.isPureJoker())
|
||||||
|
|
Loading…
Reference in a new issue