Clean code up a bit

pull/1558/head
Andrei Kortunov 7 years ago
parent ba91cd658b
commit 5f41f7c48d

@ -239,16 +239,13 @@ BookTypesetter::Ptr JournalBooks::createLatinJournalIndex ()
{
char ch = 'A' + i;
char buffer [32];
sprintf (buffer, "( %c )", ch);
char buffer2 [32];
sprintf(buffer2, "%c", ch);
const char * c = buffer2;
Utf8Stream stream ((unsigned char*) c,(unsigned char*) c + strlen(c));
Utf8Stream stream (buffer2);
uint32_t first = stream.peek();
// TODO: find a way to store a multibyte character in the InteractiveId (this is a intptr_t)
const MWGui::TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
BookTypesetter::Style* style = typesetter->createHotStyle (body, textColours.journalTopic,
textColours.journalTopicOver,
@ -274,13 +271,12 @@ BookTypesetter::Ptr JournalBooks::createCyrillicJournalIndex ()
for (int i = 0; i < 32; ++i)
{
char buffer [32];
sprintf(buffer, "( %c%c )", 0xd0, 0x90 + i); // CYRILLIC CAPITAL A is a 0xd090 in UTF-8
char buffer2 [32];
sprintf(buffer2, "%c%c", 0xd0, 0x90 + i);
const char * c = buffer2;
Utf8Stream stream ((unsigned char*) c,(unsigned char*) c + strlen(c));
Utf8Stream stream (buffer2);
uint32_t first = stream.peek();
const MWGui::TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();

@ -313,8 +313,7 @@ struct JournalViewModelImpl : JournalViewModel
for (MWBase::Journal::TTopicIter i = journal->topicBegin (); i != journal->topicEnd (); ++i)
{
const char * c = i->first.c_str();
Utf8Stream stream ((unsigned char*) c,(unsigned char*) c + strlen(c));
Utf8Stream stream (i->first.c_str());
uint32_t first = Misc::StringUtils::toUpper(stream.peek());
if (first != character)

@ -58,7 +58,7 @@ public:
static uint32_t toUpper(uint32_t ch)
{
// Russian alphabete
// Russian alphabet
if (ch >= 0x0430 && ch < 0x0450)
ch -= 0x20;
@ -66,7 +66,7 @@ public:
if (ch == 0x0451)
ch -= 0x50;
// Latin alphabete
// Latin alphabet
if (ch >= 0x61 && ch < 0x80)
ch -= 0x20;

@ -18,6 +18,11 @@ public:
{
}
Utf8Stream (const char * str) :
cur ((unsigned char*) str), nxt ((unsigned char*) str), end ((unsigned char*) str + strlen(str)), val(Utf8Stream::sBadChar())
{
}
Utf8Stream (std::pair <Point, Point> range) :
cur (range.first), nxt (range.first), end (range.second), val(Utf8Stream::sBadChar())
{

Loading…
Cancel
Save