Distinguish variables with same names
...to resolve C4457 warnings.
This commit is contained in:
parent
073311be78
commit
3831012af9
@ -638,7 +638,7 @@ bool ZRCola::DBSource::GetTagNames(const winstd::com_obj<ADOField>& f, LCID lcid
|
||||
|
||||
// Parse the field. Must be "name, name, name..." sequence.
|
||||
names.clear();
|
||||
for (UINT i = 0, n = ::SysStringLen(V_BSTR(&v)); i < n && V_BSTR(&v)[i];) {
|
||||
for (UINT i = 0, i_end = ::SysStringLen(V_BSTR(&v)); i < i_end && V_BSTR(&v)[i];) {
|
||||
if (iswspace(V_BSTR(&v)[i])) {
|
||||
// Skip leading white space.
|
||||
i++; continue;
|
||||
@ -646,7 +646,7 @@ bool ZRCola::DBSource::GetTagNames(const winstd::com_obj<ADOField>& f, LCID lcid
|
||||
|
||||
// Parse name.
|
||||
UINT j = i, j_end = i;
|
||||
for (; i < n && V_BSTR(&v)[i]; i++) {
|
||||
for (; i < i_end && V_BSTR(&v)[i]; i++) {
|
||||
if (V_BSTR(&v)[i] == L',' || V_BSTR(&v)[i] == L';') {
|
||||
// Delimiter found.
|
||||
i++; break;
|
||||
@ -793,9 +793,9 @@ bool ZRCola::DBSource::GetTranslation(const com_obj<ADORecordset>& rs, ZRCola::D
|
||||
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"Kanoniziraj"), &f)));
|
||||
wxCHECK(GetValue(f, norm), false);
|
||||
if (norm) {
|
||||
com_obj<ADOField> f;
|
||||
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"Kano"), &f)));
|
||||
wxCHECK(GetValue(f, t.norm), false);
|
||||
com_obj<ADOField> f2;
|
||||
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"Kano"), &f2)));
|
||||
wxCHECK(GetValue(f2, t.norm), false);
|
||||
} else
|
||||
t.norm.clear();
|
||||
}
|
||||
@ -927,10 +927,10 @@ bool ZRCola::DBSource::GetTranslationSeq(const com_obj<ADORecordset>& rs, ZRCola
|
||||
|
||||
{
|
||||
ts.sets.clear();
|
||||
com_obj<ADOFields> flds;
|
||||
wxVERIFY(SUCCEEDED(rs_chars->get_Fields(&flds)));
|
||||
com_obj<ADOFields> flds2;
|
||||
wxVERIFY(SUCCEEDED(rs_chars->get_Fields(&flds2)));
|
||||
com_obj<ADOField> f_set;
|
||||
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"Script"), &f_set)));
|
||||
wxVERIFY(SUCCEEDED(flds2->get_Item(variant(L"Script"), &f_set)));
|
||||
size_t n = 0;
|
||||
for (VARIANT_BOOL eof = VARIANT_TRUE; SUCCEEDED(rs_chars->get_EOF(&eof)) && !eof; rs_chars->MoveNext(), n++) {
|
||||
int set;
|
||||
@ -1188,11 +1188,11 @@ bool ZRCola::DBSource::GetCharacterGroup(const com_obj<ADORecordset>& rs, chrgrp
|
||||
{
|
||||
cg.chars.clear();
|
||||
cg.show.clear();
|
||||
com_obj<ADOFields> flds;
|
||||
wxVERIFY(SUCCEEDED(rs_chars->get_Fields(&flds)));
|
||||
com_obj<ADOFields> flds2;
|
||||
wxVERIFY(SUCCEEDED(rs_chars->get_Fields(&flds2)));
|
||||
com_obj<ADOField> f_char, f_show;
|
||||
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"Znak" ), &f_char)));
|
||||
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"pogost"), &f_show)));
|
||||
wxVERIFY(SUCCEEDED(flds2->get_Item(variant(L"Znak" ), &f_char)));
|
||||
wxVERIFY(SUCCEEDED(flds2->get_Item(variant(L"pogost"), &f_show)));
|
||||
size_t n = 0;
|
||||
for (VARIANT_BOOL eof = VARIANT_TRUE; SUCCEEDED(rs_chars->get_EOF(&eof)) && !eof; rs_chars->MoveNext(), n++) {
|
||||
wstring c;
|
||||
|
@ -449,8 +449,7 @@ int _tmain(int argc, _TCHAR *argv[])
|
||||
// Get translations.
|
||||
com_obj<ADORecordset> rs_tran;
|
||||
if (src.SelectTranslations(ts.set, rs_tran)) {
|
||||
size_t count = src.GetRecordsetCount(rs_tran);
|
||||
if (count < 0xffffffff) { // 4G check (-1 is reserved for error condition)
|
||||
if (src.GetRecordsetCount(rs_tran) < 0xffffffff) { // 4G check (-1 is reserved for error condition)
|
||||
// Parse translations and build temporary database.
|
||||
ZRCola::DBSource::translation trans;
|
||||
trans.set = ts.set;
|
||||
@ -747,11 +746,11 @@ int _tmain(int argc, _TCHAR *argv[])
|
||||
ZRCola::DBSource::character_desc_idx idxChrDsc, idxChrDscSub;
|
||||
|
||||
ZRCola::DBSource::character_bank chrs;
|
||||
ZRCola::DBSource::character chr;
|
||||
|
||||
// Phase 1: Parse characters and build indexes.
|
||||
for (; !ZRCola::DBSource::IsEOF(rs); rs->MoveNext()) {
|
||||
// Read character from the database.
|
||||
ZRCola::DBSource::character chr;
|
||||
if (src.GetCharacter(rs, chr))
|
||||
chrs[chr.first] = std::move(chr.second);
|
||||
else
|
||||
@ -936,9 +935,9 @@ int _tmain(int argc, _TCHAR *argv[])
|
||||
|
||||
if (!has_errors && build_pot) {
|
||||
const wxString& filenamePot = parser.GetParam(2);
|
||||
fstream dst((LPCTSTR)filenamePot, ios_base::out | ios_base::trunc);
|
||||
if (dst.good()) {
|
||||
dst << "msgid \"\"" << endl
|
||||
fstream dst_pot((LPCTSTR)filenamePot, ios_base::out | ios_base::trunc);
|
||||
if (dst_pot.good()) {
|
||||
dst_pot << "msgid \"\"" << endl
|
||||
<< "msgstr \"\"" << endl
|
||||
<< "\"Project-Id-Version: ZRCola.zrcdb\\n\"" << endl
|
||||
<< "\"Language: en\\n\"" << endl
|
||||
@ -948,9 +947,9 @@ int _tmain(int argc, _TCHAR *argv[])
|
||||
<< "\"X-Generator: ZRColaCompile\\n\"" << endl;
|
||||
|
||||
wstring_convert<codecvt_utf8<wchar_t>> conv;
|
||||
for (auto i = pot.cbegin(); i != pot.cend(); ++i) {
|
||||
for (auto p = pot.cbegin(); p != pot.cend(); ++p) {
|
||||
// Convert UTF-16 to UTF-8 and escape.
|
||||
string t(conv.to_bytes(*i)), u;
|
||||
string t(conv.to_bytes(*p)), u;
|
||||
for (size_t i = 0, n = t.size(); i < n; i++) {
|
||||
char c = t[i];
|
||||
switch (c) {
|
||||
@ -961,17 +960,17 @@ int _tmain(int argc, _TCHAR *argv[])
|
||||
default : u += c;
|
||||
}
|
||||
}
|
||||
dst << endl
|
||||
dst_pot << endl
|
||||
<< "msgid \"" << u << "\"" << endl
|
||||
<< "msgstr \"\"" << endl;
|
||||
}
|
||||
|
||||
if (dst.fail()) {
|
||||
if (dst_pot.fail()) {
|
||||
_ftprintf(stderr, wxT("%s: error ZCC0013: Writing to POT catalog failed.\n"), (LPCTSTR)filenameOut.c_str());
|
||||
has_errors = true;
|
||||
}
|
||||
|
||||
dst.close();
|
||||
dst_pot.close();
|
||||
} else {
|
||||
_ftprintf(stderr, wxT("%s: error ZCC0012: Error opening POT catalog.\n"), filenameOut.fn_str());
|
||||
has_errors = true;
|
||||
|
@ -363,16 +363,14 @@ namespace ZRCola {
|
||||
else {
|
||||
// Narrow the search area on the left to start at the first element in the run.
|
||||
for (size_type end2 = m; start < end2;) {
|
||||
size_type m = (start + end2) / 2;
|
||||
int r = compare(el, at(m));
|
||||
if (r <= 0) end2 = m; else start = m + 1;
|
||||
size_type m2 = (start + end2) / 2;
|
||||
if (compare(el, at(m2)) <= 0) end2 = m2; else start = m2 + 1;
|
||||
}
|
||||
|
||||
// Narrow the search area on the right to end at the first element not in the run.
|
||||
for (size_type start2 = m + 1; start2 < end;) {
|
||||
size_type m = (start2 + end) / 2;
|
||||
int r = compare(el, at(m));
|
||||
if (0 <= r) start2 = m + 1; else end = m;
|
||||
size_type m2 = (start2 + end) / 2;
|
||||
if (0 <= compare(el, at(m2))) start2 = m2 + 1; else end = m2;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -404,9 +402,8 @@ namespace ZRCola {
|
||||
else {
|
||||
// Narrow the search area on the left to start at the first element in the run.
|
||||
for (size_type end2 = m; start < end2;) {
|
||||
size_type m = (start + end2) / 2;
|
||||
int r = compare(el, at(m));
|
||||
if (r <= 0) end2 = m; else start = m + 1;
|
||||
m = (start + end2) / 2;
|
||||
if (compare(el, at(m)) <= 0) end2 = m; else start = m + 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -478,9 +475,9 @@ namespace ZRCola {
|
||||
else if (r > 0) start = m + 1;
|
||||
else {
|
||||
// Get values at position m.
|
||||
size_t start = base_t::at(m ).idx_val;
|
||||
*val_len = (m < size() ? base_t::at(m + 1).idx_val : values.size()) - start;
|
||||
*val = &values.at(start);
|
||||
start = base_t::at(m ).idx_val;
|
||||
*val_len = (m < size() ? base_t::at(m + 1).idx_val : values.size()) - start;
|
||||
*val = &values.at(start);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -71,42 +71,42 @@ bool ZRCola::character_db::Search(_In_z_ const wchar_t *str, _In_ const std::set
|
||||
|
||||
if (fn_abort && fn_abort(cookie)) return false;
|
||||
|
||||
const wchar_t *data;
|
||||
size_t len;
|
||||
const wchar_t *val;
|
||||
size_t val_len;
|
||||
|
||||
if (idxDsc.find(term.c_str(), term.size(), &data, &len)) {
|
||||
if (idxDsc.find(term.c_str(), term.size(), &val, &val_len)) {
|
||||
// The term was found.
|
||||
for (size_t i = 0, j = 0; i < len; i += j + 1) {
|
||||
for (size_t i = 0, j = 0; i < val_len; i += j + 1) {
|
||||
if (fn_abort && fn_abort(cookie)) return false;
|
||||
j = wcsnlen(data + i, len - i);
|
||||
if (cats.find(GetCharCat(data + i, j)) != cats.end()) {
|
||||
std::wstring c(data + i, j);
|
||||
j = wcsnlen(val + i, val_len - i);
|
||||
if (cats.find(GetCharCat(val + i, j)) != cats.end()) {
|
||||
std::wstring c(val + i, j);
|
||||
auto idx = hits.find(c);
|
||||
if (idx == hits.end()) {
|
||||
// New character.
|
||||
hits.insert(std::make_pair(std::move(c), 1.0/len));
|
||||
hits.insert(std::make_pair(std::move(c), 1.0/val_len));
|
||||
} else {
|
||||
// Increase rating of existing character.
|
||||
idx->second += 1.0/len;
|
||||
idx->second += 1.0/val_len;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (idxDscSub.find(term.c_str(), term.size(), &data, &len)) {
|
||||
if (idxDscSub.find(term.c_str(), term.size(), &val, &val_len)) {
|
||||
// The term was found in the sub-term index.
|
||||
for (size_t i = 0, j = 0; i < len; i += j + 1) {
|
||||
for (size_t i = 0, j = 0; i < val_len; i += j + 1) {
|
||||
if (fn_abort && fn_abort(cookie)) return false;
|
||||
j = wcsnlen(data + i, len - i);
|
||||
if (cats.find(GetCharCat(data + i, j)) != cats.end()) {
|
||||
std::wstring c(data + i, j);
|
||||
j = wcsnlen(val + i, val_len - i);
|
||||
if (cats.find(GetCharCat(val + i, j)) != cats.end()) {
|
||||
std::wstring c(val + i, j);
|
||||
auto idx = hits_sub.find(c);
|
||||
if (idx == hits_sub.end()) {
|
||||
// New character.
|
||||
hits_sub.insert(std::make_pair(c, 1.0/len));
|
||||
hits_sub.insert(std::make_pair(c, 1.0/val_len));
|
||||
} else {
|
||||
// Increase rating of existing character.
|
||||
idx->second += 1.0/len;
|
||||
idx->second += 1.0/val_len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,11 +102,11 @@ bool ZRCola::tagname_db::Search(_In_z_ const wchar_t *str, _In_ LCID locale, _In
|
||||
// The name was found.
|
||||
for (size_t i = start; i < end; i++) {
|
||||
if (fn_abort && fn_abort(cookie)) return false;
|
||||
const tagname &name = idxName[i];
|
||||
auto idx = hits.find(name.tag);
|
||||
const tagname &val = idxName[i];
|
||||
auto idx = hits.find(val.tag);
|
||||
if (idx == hits.end()) {
|
||||
// New tag.
|
||||
hits.insert(std::make_pair(name.tag, 1));
|
||||
hits.insert(std::make_pair(val.tag, 1));
|
||||
} else {
|
||||
// Increase count for existing tag.
|
||||
idx->second++;
|
||||
|
@ -50,8 +50,7 @@ void ZRCola::translation_db::Translate(_In_ transetid_t set, _In_z_count_(inputM
|
||||
// Get the j-th character of the translation.
|
||||
// All translations that get short on characters are lexically ordered before.
|
||||
// Thus the j-th character is considered 0.
|
||||
const translation &trans = idxSrc[m];
|
||||
wchar_t s = trans.src_at(j);
|
||||
wchar_t s = idxSrc[m].src_at(j);
|
||||
|
||||
// Do the bisection test.
|
||||
if (c < s) r = m;
|
||||
@ -60,23 +59,18 @@ void ZRCola::translation_db::Translate(_In_ transetid_t set, _In_z_count_(inputM
|
||||
// Character found.
|
||||
|
||||
// Narrow the search area on the left to start at the first translation in the run.
|
||||
for (size_t rr = m; l < rr;) {
|
||||
size_t m = (l + rr) / 2;
|
||||
const translation &trans = idxSrc[m];
|
||||
wchar_t s = trans.src_at(j);
|
||||
if (c <= s) rr = m; else l = m + 1;
|
||||
for (size_t r2 = m; l < r2;) {
|
||||
size_t m2 = (l + r2) / 2;
|
||||
if (c <= idxSrc[m2].src_at(j)) r2 = m2; else l = m2 + 1;
|
||||
}
|
||||
|
||||
// Narrow the search area on the right to end at the first translation not in the run.
|
||||
for (size_t ll = m + 1; ll < r;) {
|
||||
size_t m = (ll + r) / 2;
|
||||
const translation &trans = idxSrc[m];
|
||||
wchar_t s = trans.src_at(j);
|
||||
if (s <= c) ll = m + 1; else r = m;
|
||||
for (size_t l2 = m + 1; l2 < r;) {
|
||||
size_t m2 = (l2 + r) / 2;
|
||||
if (idxSrc[m2].src_at(j) <= c) l2 = m2 + 1; else r = m2;
|
||||
}
|
||||
|
||||
const translation &trans = idxSrc[l];
|
||||
if (j + 1 == trans.src_len()) {
|
||||
if (j + 1 == idxSrc[l].src_len()) {
|
||||
// The first translation of the run was a match (thus far). Save it.
|
||||
l_match = l;
|
||||
}
|
||||
@ -134,8 +128,7 @@ void ZRCola::translation_db::TranslateInv(_In_ transetid_t set, _In_z_count_(inp
|
||||
// Get the j-th character of the inverse translation.
|
||||
// All inverse translations that get short on characters are lexically ordered before.
|
||||
// Thus the j-th character is considered 0.
|
||||
const translation &trans = idxDst[m];
|
||||
wchar_t s = trans.dst_at(j);
|
||||
wchar_t s = idxDst[m].dst_at(j);
|
||||
|
||||
// Do the bisection test.
|
||||
if (c < s) r = m;
|
||||
@ -144,23 +137,18 @@ void ZRCola::translation_db::TranslateInv(_In_ transetid_t set, _In_z_count_(inp
|
||||
// Character found.
|
||||
|
||||
// Narrow the search area on the left to start at the first inverse translation in the run.
|
||||
for (size_t rr = m; l < rr;) {
|
||||
size_t m = (l + rr) / 2;
|
||||
const translation &trans = idxDst[m];
|
||||
wchar_t s = trans.dst_at(j);
|
||||
if (c <= s) rr = m; else l = m + 1;
|
||||
for (size_t r2 = m; l < r2;) {
|
||||
size_t m2 = (l + r2) / 2;
|
||||
if (c <= idxDst[m2].dst_at(j)) r2 = m2; else l = m2 + 1;
|
||||
}
|
||||
|
||||
// Narrow the search area on the right to end at the first inverse translation not in the run.
|
||||
for (size_t ll = m + 1; ll < r;) {
|
||||
size_t m = (ll + r) / 2;
|
||||
const translation &trans = idxDst[m];
|
||||
wchar_t s = trans.dst_at(j);
|
||||
if (s <= c) ll = m + 1; else r = m;
|
||||
for (size_t l2 = m + 1; l2 < r;) {
|
||||
size_t m2 = (l2 + r) / 2;
|
||||
if (idxDst[m2].dst_at(j) <= c) l2 = m2 + 1; else r = m2;
|
||||
}
|
||||
|
||||
const translation &trans = idxDst[l];
|
||||
if (j + 1 == trans.dst_len()) {
|
||||
if (j + 1 == idxDst[l].dst_len()) {
|
||||
// The first inverse translation of the run was a match (thus far). Save it.
|
||||
l_match = l;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user