Enable recommended code analysis and address warnings

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2020-02-12 19:27:11 +01:00
parent 62702a0194
commit ebdbb84a29
45 changed files with 278 additions and 155 deletions

@ -1 +1 @@
Subproject commit cb745393289f049ee6b5ffafb6cea7d5a65230d4
Subproject commit e975f5bc31e86a1ae847027a0159363aeebaf980

@ -1 +1 @@
Subproject commit 154cd798e49c9d748de5c206969ff569e86145c3
Subproject commit 349c42fe5797baae2161402eeca4bdd4c1108142

View File

@ -39,6 +39,8 @@
#include <wxex/persist/auimanager.h>
#include <wxex/persist/toplevel.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/clipbrd.h>
#include <wx/dcclient.h>
#include <wx/ffile.h>
@ -49,6 +51,7 @@
#include <wx/tokenzr.h>
#include <wx/utils.h>
#include <wx/valtext.h>
#pragma warning(pop)
#include <WinStd/MSI.h>

View File

@ -25,7 +25,11 @@ class wxZRColaAbout;
#pragma once
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include "zrcolagui.h"
#pragma warning(pop)
///

View File

@ -27,11 +27,13 @@
// ZRColaApp
//////////////////////////////////////////////////////////////////////////
#pragma warning(suppress: 28251) // wxWidgets implement WinMain without code analysis annotations.
wxIMPLEMENT_APP(ZRColaApp);
ZRColaApp::ZRColaApp() :
m_mainWnd(NULL),
#pragma warning(suppress: 26812) // wxLanguage is unscoped
m_lang_ui(wxLANGUAGE_DEFAULT),
wxApp()
{

View File

@ -27,9 +27,13 @@ class ZRColaApp;
#include "zrcolafrm.h"
#include <WinStd/Win.h>
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/app.h>
#include <wx/config.h>
#include <wx/intl.h>
#pragma warning(pop)
#include <zrcola/character.h>
#include <zrcola/language.h>
#include <zrcola/translate.h>

View File

@ -29,7 +29,9 @@ BEGIN_EVENT_TABLE(wxZRColaCharacterCatalogPanel, wxZRColaCharacterCatalogPanelBa
END_EVENT_TABLE()
wxZRColaCharacterCatalogPanel::wxZRColaCharacterCatalogPanel(wxWindow* parent) : wxZRColaCharacterCatalogPanelBase(parent)
wxZRColaCharacterCatalogPanel::wxZRColaCharacterCatalogPanel(wxWindow* parent) :
m_cg_id(0),
wxZRColaCharacterCatalogPanelBase(parent)
{
std::fstream dat((LPCTSTR)dynamic_cast<ZRColaApp*>(wxTheApp)->GetDatabaseFilePath(), std::ios_base::in | std::ios_base::binary);
if (dat.good()) {
@ -60,7 +62,7 @@ wxZRColaCharacterCatalogPanel::wxZRColaCharacterCatalogPanel(wxWindow* parent) :
wxString
label(cg.name(), cg.name_len()),
label_tran2(wxGetTranslation(label, wxT("ZRCola-zrcdb")));
m_choice->Insert(label_tran2, i);
m_choice->Insert(label_tran2, (unsigned int)i);
}
m_cg_id = m_cg_db.idxRank[0].grp;
m_choice->Select(0);
@ -216,7 +218,7 @@ bool wxPersistentZRColaCharacterCatalogPanel::Restore()
if (cg.grp == cg_id) {
if (wnd->m_cg_id != cg.grp) {
wnd->m_cg_id = cg.grp;
wnd->m_choice->Select(i);
wnd->m_choice->Select((int)i);
update = true;
}

View File

@ -25,9 +25,16 @@ class wxZRColaCharacterCatalogPanel;
#pragma once
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include "zrcolagui.h"
#pragma warning(pop)
#include <zrcolaui/chargroup.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/persist/window.h>
#pragma warning(pop)
///

View File

@ -156,13 +156,13 @@ void wxZRColaCharGrid::OnSize(wxSizeEvent& event)
row_height = FromDIP(wxZRColaCharacterGridRowHeight),
width = size.GetWidth() - m_rowLabelWidth - m_extraWidth,
cols = std::max<int>(width / col_width, 1),
rows = std::max<int>((char_count + cols - 1) / cols, 1);
rows = std::max<int>((int)((char_count + cols - 1) / cols), 1);
if (m_colLabelHeight + rows*row_height + m_extraHeight > size.GetHeight()) {
// Vertical scrollbar will be shown. Adjust the width and recalculate layout to avoid horizontal scrollbar.
width = std::max<int>(width - wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, this), 0);
cols = std::max<int>(width / col_width, 1);
rows = std::max<int>((char_count + cols - 1) / cols, 1);
rows = std::max<int>((int)((char_count + cols - 1) / cols), 1);
}
BeginBatch();
@ -242,7 +242,7 @@ void wxZRColaCharGrid::OnMotion(wxMouseEvent& event)
if (col == wxNOT_FOUND || row == wxNOT_FOUND )
return;
size_t toolTipIdx = row*m_numCols + col;
size_t toolTipIdx = (size_t)row*m_numCols + col;
if (toolTipIdx >= m_chars.GetCount()) {
// Index out of range.
m_toolTipIdx = (size_t)-1;
@ -254,7 +254,7 @@ void wxZRColaCharGrid::OnMotion(wxMouseEvent& event)
wxWindow *gridWnd = GetGridWindow();
if (gridWnd->GetToolTip()) {
// The tooltip is already shown. Update it immediately.
gridWnd->SetToolTip(GetToolTipText(m_toolTipIdx));
gridWnd->SetToolTip(GetToolTipText((int)m_toolTipIdx));
} else {
// This must be our initial entry. Schedule tooltip display after 1s.
m_timerToolTip.Start(1000, true);
@ -270,5 +270,5 @@ void wxZRColaCharGrid::OnTooltipTimer(wxTimerEvent& event)
if (m_toolTipIdx >= m_chars.GetCount())
return;
GetGridWindow()->SetToolTip(GetToolTipText(m_toolTipIdx));
GetGridWindow()->SetToolTip(GetToolTipText((int)m_toolTipIdx));
}

View File

@ -25,7 +25,11 @@ class wxZRColaCharGrid;
#pragma once
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/grid.h>
#pragma warning(pop)
///
@ -96,7 +100,7 @@ public:
if (i >= n)
return wxGridCellCoords(-1, -1);
else if (m_chars[i] == c)
return wxGridCellCoords(i / m_numCols, i % m_numCols);
return wxGridCellCoords((int)(i / m_numCols), i % m_numCols);
}
}

View File

@ -26,7 +26,11 @@ class wxPersistentZRColaCharRequest;
#pragma once
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include "zrcolagui.h"
#pragma warning(pop)
#include "zrcolakeyhndlr.h"
#include <wxex/persist/toplevel.h>

View File

@ -85,7 +85,7 @@ bool wxZRColaUTF16CharValidator::Parse(const wxString &val_in, size_t i_start, s
} else if (i >= i_start + 4) {
// Maximum characters exceeded.
ctrl->SetFocus();
ctrl->SetSelection(i, i_end);
ctrl->SetSelection((int)i, (int)i_end);
wxMessageBox(_("Too many digits in Unicode."), _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent);
return false;
} else if (_T('0') <= buf[i] && buf[i] <= _T('9')) {
@ -103,7 +103,7 @@ bool wxZRColaUTF16CharValidator::Parse(const wxString &val_in, size_t i_start, s
} else {
// Invalid character found.
ctrl->SetFocus();
ctrl->SetSelection(i, i + 1);
ctrl->SetSelection((long)i, (long)(i + 1));
wxMessageBox(wxString::Format(_("Invalid character in Unicode found: %c"), buf[i]), _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent);
return false;
}
@ -202,6 +202,7 @@ wxZRColaCharSelect::wxZRColaCharSelect(wxWindow* parent) :
wxZRColaCharSelectBase(parent)
{
// Set tag lookup locale.
#pragma warning(suppress: 26812) // wxLanguage is unscoped
wxLanguage language = dynamic_cast<ZRColaApp*>(wxTheApp)->m_lang_ui;
if (wxLANGUAGE_DEFAULT == language ||
wxLANGUAGE_ENGLISH <= language && language <= wxLANGUAGE_ENGLISH_ZIMBABWE) m_locale = MAKELCID(MAKELANGID(LANG_ENGLISH , SUBLANG_DEFAULT), SORT_DEFAULT);
@ -219,7 +220,7 @@ wxZRColaCharSelect::wxZRColaCharSelect(wxWindow* parent) :
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
for (size_t i = 0, n = app->m_cc_db.idxRank.size(); i < n; i++) {
const auto &cc = app->m_cc_db.idxRank[i];
int idx = m_categories->Insert(wxGetTranslation(wxString(cc.name(), cc.name_len()), wxT("ZRCola-zrcdb")), i);
int idx = m_categories->Insert(wxGetTranslation(wxString(cc.name(), cc.name_len()), wxT("ZRCola-zrcdb")), (unsigned int)i);
m_categories->Check(idx);
m_ccOrder.insert(std::make_pair(cc.cat, idx));
}
@ -354,7 +355,7 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
// Select categories.
for (size_t i = 0, n = app->m_cc_db.idxRank.size(); i < n; i++) {
const auto &cc = app->m_cc_db.idxRank[i];
if (m_categories->IsChecked(i))
if (m_categories->IsChecked((unsigned int)i))
m_searchThread->m_cats.insert(cc.cat);
}
@ -401,7 +402,7 @@ void wxZRColaCharSelect::OnCategoriesAll(wxHyperlinkEvent& event)
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
for (size_t i = 0, n = app->m_cc_db.idxRank.size(); i < n; i++)
m_categories->Check(i, true);
m_categories->Check((unsigned int)i, true);
m_searchChanged = true;
}
@ -413,7 +414,7 @@ void wxZRColaCharSelect::OnCategoriesNone(wxHyperlinkEvent& event)
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
for (size_t i = 0, n = app->m_cc_db.idxRank.size(); i < n; i++)
m_categories->Check(i, false);
m_categories->Check((unsigned int)i, false);
m_searchChanged = true;
}
@ -425,7 +426,7 @@ void wxZRColaCharSelect::OnCategoriesInvert(wxHyperlinkEvent& event)
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
for (size_t i = 0, n = app->m_cc_db.idxRank.size(); i < n; i++)
m_categories->Check(i, !m_categories->IsChecked(i));
m_categories->Check((unsigned int)i, !m_categories->IsChecked((unsigned int)i));
m_searchChanged = true;
}
@ -835,7 +836,7 @@ void wxPersistentZRColaCharSelect::Save() const
const auto &cc = app->m_cc_db.idxRank[i];
wxString name(wxT("category"));
name.Append(cc.cat.data, _countof(cc.cat.data));
SaveValue(name, wnd->m_categories->IsChecked(i));
SaveValue(name, wnd->m_categories->IsChecked((unsigned int)i));
}
SaveValue(wxT("searchPanel"), wnd->m_search_panel->IsShown());
@ -872,7 +873,7 @@ bool wxPersistentZRColaCharSelect::Restore()
name.Append(cc.cat.data, _countof(cc.cat.data));
bool val;
if (RestoreValue(name, &val))
wnd->m_categories->Check(i, val);
wnd->m_categories->Check((unsigned int)i, val);
}
bool search_panel;

View File

@ -26,12 +26,19 @@ class wxPersistentZRColaCharSelect;
#pragma once
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include "zrcolagui.h"
#pragma warning(pop)
#include <zrcola/character.h>
#include <wxex/persist/toplevel.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/validate.h>
#include <wx/event.h>
#include <wx/thread.h>
#pragma warning(pop)
#include <list>
#include <map>
#include <string>

View File

@ -43,13 +43,13 @@ wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) :
file.Read(&n, sizeof(n));
if (!file.Error()) {
wxString source;
file.Read(wxStringBuffer(source, n), sizeof(wchar_t)*n);
file.Read(wxStringBuffer(source, (size_t)n), sizeof(wchar_t)*(size_t)n);
if (!file.Error()) {
// Load destination text.
file.Read(&n, sizeof(n));
if (!file.Error()) {
wxString destination;
file.Read(wxStringBuffer(destination, n), sizeof(wchar_t)*n);
file.Read(wxStringBuffer(destination, (size_t)n), sizeof(wchar_t)*(size_t)n);
if (!file.Error()) {
// Restore state.
m_source->SetValue(source);
@ -121,8 +121,8 @@ void wxZRColaComposerPanel::SynchronizePanels()
// Update destination text, and its HEX dump.
m_destination->SetValue(dst);
m_destination->SetSelection(
m_selDestination.first = MapToDestination(m_selSource.first ),
m_selDestination.second = MapToDestination(m_selSource.second));
m_selDestination.first = (long)MapToDestination(m_selSource.first ),
m_selDestination.second = (long)MapToDestination(m_selSource.second));
SetHexValue(m_destinationHex, m_selDestinationHex, m_mappingDestinationHex, dst.data(), dst.length(), m_selDestination.first, m_selDestination.second);
// Schedule state save after 3s.
@ -167,8 +167,8 @@ void wxZRColaComposerPanel::SynchronizePanels()
// Update source text, and its HEX dump.
m_source->SetValue(dst);
m_source->SetSelection(
m_selSource.first = MapToSource(m_selDestination.first ),
m_selSource.second = MapToSource(m_selDestination.second));
m_selSource.first = (long)MapToSource(m_selDestination.first ),
m_selSource.second = (long)MapToSource(m_selDestination.second));
SetHexValue(m_sourceHex, m_selSourceHex, m_mappingSourceHex, dst.data(), dst.length(), m_selSource.first, m_selSource.second);
// Schedule state save after 3s.
@ -194,16 +194,16 @@ void wxZRColaComposerPanel::OnSourcePaint(wxPaintEvent& event)
m_selSource.second = to;
m_sourceHex->SetSelection(
m_selSourceHex.first = m_mappingSourceHex.to_dst(from),
m_selSourceHex.second = m_mappingSourceHex.to_dst(to ));
m_selSourceHex.first = (long)m_mappingSourceHex.to_dst(from),
m_selSourceHex.second = (long)m_mappingSourceHex.to_dst(to ));
m_destination->SetSelection(
m_selDestination.first = MapToDestination(from),
m_selDestination.second = MapToDestination(to ));
m_selDestination.first = (long)MapToDestination(from),
m_selDestination.second = (long)MapToDestination(to ));
m_destinationHex->SetSelection(
m_selDestinationHex.first = m_mappingDestinationHex.to_dst(m_selDestination.first ),
m_selDestinationHex.second = m_mappingDestinationHex.to_dst(m_selDestination.second));
m_selDestinationHex.first = (long)m_mappingDestinationHex.to_dst(m_selDestination.first ),
m_selDestinationHex.second = (long)m_mappingDestinationHex.to_dst(m_selDestination.second));
}
}
@ -221,16 +221,16 @@ void wxZRColaComposerPanel::OnSourceHexPaint(wxPaintEvent& event)
m_selSourceHex.second = to;
m_source->SetSelection(
m_selSource.first = m_mappingSourceHex.to_src(from),
m_selSource.second = m_mappingSourceHex.to_src(to ));
m_selSource.first = (long)m_mappingSourceHex.to_src(from),
m_selSource.second = (long)m_mappingSourceHex.to_src(to ));
m_destination->SetSelection(
m_selDestination.first = MapToDestination(m_selSource.first ),
m_selDestination.second = MapToDestination(m_selSource.second));
m_selDestination.first = (long)MapToDestination(m_selSource.first ),
m_selDestination.second = (long)MapToDestination(m_selSource.second));
m_destinationHex->SetSelection(
m_selDestinationHex.first = m_mappingDestinationHex.to_dst(m_selDestination.first ),
m_selDestinationHex.second = m_mappingDestinationHex.to_dst(m_selDestination.second));
m_selDestinationHex.first = (long)m_mappingDestinationHex.to_dst(m_selDestination.first ),
m_selDestinationHex.second = (long)m_mappingDestinationHex.to_dst(m_selDestination.second));
}
}
@ -257,16 +257,16 @@ void wxZRColaComposerPanel::OnDestinationPaint(wxPaintEvent& event)
m_selDestination.second = to;
m_destinationHex->SetSelection(
m_selDestinationHex.first = m_mappingDestinationHex.to_dst(from),
m_selDestinationHex.second = m_mappingDestinationHex.to_dst(to ));
m_selDestinationHex.first = (long)m_mappingDestinationHex.to_dst(from),
m_selDestinationHex.second = (long)m_mappingDestinationHex.to_dst(to ));
m_source->SetSelection(
m_selSource.first = MapToSource(from),
m_selSource.second = MapToSource(to ));
m_selSource.first = (long)MapToSource(from),
m_selSource.second = (long)MapToSource(to ));
m_sourceHex->SetSelection(
m_selSourceHex.first = m_mappingSourceHex.to_dst(m_selSource.first ),
m_selSourceHex.second = m_mappingSourceHex.to_dst(m_selSource.second));
m_selSourceHex.first = (long)m_mappingSourceHex.to_dst(m_selSource.first ),
m_selSourceHex.second = (long)m_mappingSourceHex.to_dst(m_selSource.second));
}
}
@ -284,16 +284,16 @@ void wxZRColaComposerPanel::OnDestinationHexPaint(wxPaintEvent& event)
m_selDestinationHex.second = to;
m_destination->SetSelection(
m_selDestination.first = m_mappingDestinationHex.to_src(from),
m_selDestination.second = m_mappingDestinationHex.to_src(to ));
m_selDestination.first = (long)m_mappingDestinationHex.to_src(from),
m_selDestination.second = (long)m_mappingDestinationHex.to_src(to ));
m_source->SetSelection(
m_selSource.first = MapToSource(m_selDestination.first ),
m_selSource.second = MapToSource(m_selDestination.second));
m_selSource.first = (long)MapToSource(m_selDestination.first ),
m_selSource.second = (long)MapToSource(m_selDestination.second));
m_sourceHex->SetSelection(
m_selSourceHex.first = m_mappingSourceHex.to_dst(m_selSource.first ),
m_selSourceHex.second = m_mappingSourceHex.to_dst(m_selSource.second));
m_selSourceHex.first = (long)m_mappingSourceHex.to_dst(m_selSource.first ),
m_selSourceHex.second = (long)m_mappingSourceHex.to_dst(m_selSource.second));
}
}
@ -356,11 +356,11 @@ size_t wxZRColaComposerPanel::GetValue(wxTextCtrl *wnd, wxString &text)
size_t len = ::GetWindowTextLengthW(hWnd);
if (len < 0x100) {
WCHAR buf[0x100];
::GetWindowTextW(hWnd, buf, len + 1);
::GetWindowTextW(hWnd, buf, (int)(len + 1));
text.assign(buf, len);
} else {
LPWSTR buf = new WCHAR[len + 1];
::GetWindowTextW(hWnd, buf, len + 1);
::GetWindowTextW(hWnd, buf, (int)(len + 1));
text.assign(buf, len);
delete [] buf;
}
@ -393,8 +393,8 @@ void wxZRColaComposerPanel::SetHexValue(wxTextCtrl *wnd, std::pair<long, long> &
wnd->SetValue(hex);
wnd->SetSelection(
range.first = mapping.to_dst(from),
range.second = mapping.to_dst(to ));
range.first = (long)mapping.to_dst(from),
range.second = (long)mapping.to_dst(to ));
}

View File

@ -25,10 +25,17 @@ class wxZRColaComposerPanel;
#pragma once
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include "zrcolagui.h"
#pragma warning(pop)
#include "zrcolakeyhndlr.h"
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/persist/window.h>
#include <wx/timer.h>
#pragma warning(pop)
#include <utility>
#include <vector>

View File

@ -101,11 +101,11 @@ wxZRColaFrame::wxZRColaFrame() :
wxString
name(ts.name(), ts.name_len()),
name_tran(wxGetTranslation(name, wxT("ZRCola-zrcdb")));
m_menuTranslationSeq->AppendRadioItem(wxID_TRANSLATION_SEQ_START + i, name_tran);
m_menuTranslationSeq->AppendRadioItem((int)(wxID_TRANSLATION_SEQ_START + i), name_tran);
m_toolTranslationSeq->Append(name_tran, reinterpret_cast<void*>(ts.seq));
} else {
wxString name_tran(_("Custom Translation..."));
m_menuTranslationSeq->AppendRadioItem(wxID_TRANSLATION_SEQ_START + i, name_tran);
m_menuTranslationSeq->AppendRadioItem((int)(wxID_TRANSLATION_SEQ_START + i), name_tran);
m_toolTranslationSeq->Append(name_tran, reinterpret_cast<void*>(ZRCOLA_TRANSEQID_CUSTOM));
break;
}
@ -154,13 +154,14 @@ wxZRColaFrame::wxZRColaFrame() :
// Register notification sink for language detection.
m_ulRefCount = 1;
m_tfSource = NULL;
m_dwCookie = MAXDWORD;
ITfInputProcessorProfiles *pProfiles;
HRESULT hr = CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER, IID_ITfInputProcessorProfiles, (LPVOID*)&pProfiles);
if(SUCCEEDED(hr)) {
hr = pProfiles->QueryInterface(IID_ITfSource, (LPVOID*)&m_tfSource);
if(SUCCEEDED(hr)) {
hr = m_tfSource->AdviseSink(IID_ITfLanguageProfileNotifySink, (ITfLanguageProfileNotifySink*)this, &m_dwCookie);
if (FAILED(hr) || m_dwCookie == -1) {
if (FAILED(hr) || m_dwCookie == MAXDWORD) {
m_tfSource->Release();
m_tfSource = NULL;
}
@ -493,6 +494,7 @@ void wxZRColaFrame::OnHelpShortcuts(wxCommandEvent& event)
#ifdef __WXMSW__
// Search and try to launch installed PDF.
#pragma warning(suppress: 26812) // INSTALLSTATE is unscoped.
INSTALLSTATE pdf_is = ::MsiGetComponentPath(_T(PRODUCT_VERSION_GUID), _T("{68AC2C38-10E2-41A3-B92C-844C03FFDF6A}"), pdf_path);
if ((pdf_is == INSTALLSTATE_LOCAL || pdf_is == INSTALLSTATE_SOURCE) &&
wxFileExists(pdf_path) &&
@ -594,10 +596,10 @@ void wxZRColaFrame::DoSend(const wxString& str)
{
// Prepare the INPUT table.
wxString::size_type n = str.length();
auto i_str = str.begin();
wxString::const_iterator i_str = str.begin();
std::vector<INPUT> input;
input.reserve(n*2);
for (std::vector<INPUT>::size_type i = 0; i < n; i++, i_str++) {
for (std::vector<INPUT>::size_type i = 0; i < n; i++, ++i_str) {
wxString::char_type c = *i_str;
// Add key down event.
@ -616,7 +618,7 @@ void wxZRColaFrame::DoSend(const wxString& str)
::SetActiveWindow(m_hWndSource);
::SetForegroundWindow(m_hWndSource);
::Sleep(200);
::SendInput(input.size(), input.data(), sizeof(INPUT));
::SendInput((UINT)input.size(), input.data(), sizeof(INPUT));
m_hWndSource = NULL;
// Select all input in source and destination to prepare for the overwrite next time.
@ -760,7 +762,7 @@ bool wxPersistentZRColaFrame::Restore()
int num;
if (RestoreValue(wxT("transeqId"), &num))
wnd->m_transeq_id = num;
wnd->m_transeq_id = (ZRCola::transeqid_t)num;
bool b;
if (RestoreValue(wxT("composition"), &b))

View File

@ -26,7 +26,11 @@ class wxPersistentZRColaFrame;
#pragma once
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include "zrcolagui.h"
#pragma warning(pop)
#include "zrcolachrslct.h"
#include "zrcolachrreq.h"
#include "zrcolasettings.h"
@ -34,7 +38,10 @@ class wxPersistentZRColaFrame;
#include <zrcola/language.h>
#include <zrcola/translate.h>
#include <wxex/persist/toplevel.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/taskbar.h>
#pragma warning(pop)
#if defined(__WXMSW__)
#include <msctf.h>
#endif

View File

@ -47,7 +47,7 @@ bool wxZRColaKeyHandler::ProcessEvent(wxEvent& event)
if (!chr) {
int key = e.GetKeyCode();
if (WXK_NUMPAD0 <= key && key <= WXK_NUMPAD9)
chr = '0' + (key - WXK_NUMPAD0);
chr = '0' + (wxChar)(key - WXK_NUMPAD0);
}
wxFrame *pFrame = wxDynamicCast(dynamic_cast<ZRColaApp*>(wxTheApp)->m_mainWnd, wxFrame);
if (('0' <= chr && chr <= '9' || 'A' <= chr && chr <= 'F') && m_insert_seq.size() < 4) {
@ -81,14 +81,14 @@ bool wxZRColaKeyHandler::ProcessEvent(wxEvent& event)
{
// Parse key event and save it at the end of the key sequence.
ZRCola::keyseq_db::keyseq::key_t key;
key.key = e.GetRawKeyCode();
key.key = (wchar_t)e.GetRawKeyCode();
#if defined(__WXMSW__)
// Translate from local keyboard to scan code.
key.key = ::MapVirtualKey(key.key, MAPVK_VK_TO_VSC);
key.key = static_cast<wchar_t>(::MapVirtualKey(key.key, MAPVK_VK_TO_VSC) & 0xffff);
// Translate from scan code to U.S. Keyboard.
static const HKL s_hkl = ::LoadKeyboardLayout(_T("00000409"), 0);
key.key = ::MapVirtualKeyEx(key.key, MAPVK_VSC_TO_VK, s_hkl);
key.key = static_cast<wchar_t>(::MapVirtualKeyEx(key.key, MAPVK_VSC_TO_VK, s_hkl) & 0xffff);
#endif
key.modifiers =
(e.ShiftDown() ? ZRCola::keyseq_db::keyseq::SHIFT : 0) |
@ -147,7 +147,7 @@ bool wxZRColaKeyHandler::ProcessEvent(wxEvent& event)
if (count) {
// Zero terminate sequence and parse the Unicode value.
m_insert_seq.push_back(0);
wchar_t chr = strtoul(m_insert_seq.data(), NULL, 16);
wchar_t chr = (wchar_t)strtoul(m_insert_seq.data(), NULL, 16);
if (chr) {
wxObject *obj = event.GetEventObject();

View File

@ -27,7 +27,11 @@ class wxZRColaKeyHandler;
#include <zrcolaui/keyboard.h>
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/event.h>
#pragma warning(pop)
#include <vector>

View File

@ -36,7 +36,7 @@ wxZRColaSettings::wxZRColaSettings(wxWindow* parent) :
wxString
label(lang.name(), lang.name_len()),
label_tran(wxGetTranslation(label, wxT("ZRCola-zrcdb")));
m_languages->Insert(label_tran, i);
m_languages->Insert(label_tran, (unsigned int)i);
}
}
@ -59,7 +59,7 @@ void wxZRColaSettings::OnInitDialog(wxInitDialogEvent& event)
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
ZRCola::language_db::indexLang::size_type start;
m_languages->Select(app->m_lang_db.idxLang.find(ZRCola::language_db::language(m_lang), start) ? start : -1);
m_languages->Select(app->m_lang_db.idxLang.find(ZRCola::language_db::language(m_lang), start) ? (int)start : -1);
}

View File

@ -26,7 +26,11 @@ class wxPersistentZRColaSettings;
#pragma once
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include "zrcolagui.h"
#pragma warning(pop)
#include <wxex/persist/toplevel.h>
#include <vector>

View File

@ -240,7 +240,7 @@ bool wxPersistentZRColaTranslationSeq::Restore()
if (RestoreValue(wxT("transeq"), &str)) {
std::vector<ZRCola::transetid_t> transet;
for (wxStringTokenizer tok(str, wxT("|")); tok.HasMoreTokens(); ) {
unsigned long val = _tcstoul(tok.GetNextToken().c_str(), NULL, 10);
ZRCola::transetid_t val = (ZRCola::transetid_t)_tcstoul(tok.GetNextToken().c_str(), NULL, 10);
for (size_t i = 0, n = app->m_ts_db.idxTranSet.size(); i < n; i++) {
const ZRCola::transet_db::transet &cg = app->m_ts_db.idxTranSet[i];
if (cg.set == val) {

View File

@ -26,7 +26,11 @@ class wxPersistentZRColaTranslationSeq;
#pragma once
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include "zrcolagui.h"
#pragma warning(pop)
#include <zrcola/translate.h>
#include <wxex/persist/toplevel.h>
#include <vector>

View File

@ -80,7 +80,7 @@ wxZRColaUpdater::~wxZRColaUpdater()
void wxZRColaUpdater::OnIdle(wxIdleEvent& event)
{
if (!m_finished) {
m_buttonUpdate->Enable(m_updater->CheckForUpdate() == wxUpdCheckThread::wxUpdUpdateAvailable);
m_buttonUpdate->Enable(m_updater->CheckForUpdate() == wxUpdCheckThread::wxResult::UpdateAvailable);
m_finished = true;
}
}

View File

@ -25,11 +25,16 @@ class wxZRColaUpdater;
#pragma once
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include "zrcolagui.h"
#pragma warning(pop)
#include <Updater/chkthread.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/log.h>
#pragma warning(pop)
///

View File

@ -51,7 +51,7 @@ void ZRCola::DBSource::character_bank::build_related()
}
}
delete workers; // This line of code sounds horrible, I know.
delete [] workers; // This line of code sounds horrible, I know.
}
@ -134,7 +134,7 @@ unsigned int __stdcall ZRCola::DBSource::character_bank::build_related_worker::p
// ZRCola::DBSource::character_desc_idx
//////////////////////////////////////////////////////////////////////////
void ZRCola::DBSource::character_desc_idx::parse_keywords(const wchar_t *str, set<wstring> &terms)
void ZRCola::DBSource::character_desc_idx::parse_keywords(_In_ const wchar_t *str, _Inout_ set<wstring> &terms)
{
wxASSERT_MSG(str, wxT("string is NULL"));
@ -231,7 +231,8 @@ void ZRCola::DBSource::character_desc_idx::save(ZRCola::textindex<wchar_t, wchar
// ZRCola::DBSource
//////////////////////////////////////////////////////////////////////////
ZRCola::DBSource::DBSource()
ZRCola::DBSource::DBSource() :
m_locale(nullptr)
{
// Initialize ignore list.
m_terms_ignore.insert(L"letter");
@ -277,7 +278,10 @@ bool ZRCola::DBSource::Open(LPCTSTR filename)
cn += L"Dbq=";
cn += filename;
cn += L";Uid=;Pwd=;";
#pragma warning(push)
#pragma warning(disable: 6387) // Connection15::Open() declaration is wrong: it defaults username and password parameters to NULL, but annotates them as required non-NULL.
hr = m_db->Open(bstr(cn.c_str()));
#pragma warning(pop)
if (SUCCEEDED(hr)) {
// Database open and ready.
m_filename = filename;
@ -1009,18 +1013,18 @@ bool ZRCola::DBSource::GetKeySequence(const com_obj<ADORecordset>& rs, ZRCola::D
if (keycode1) {
// First key in the sequence is complete.
keyseq::keycode kc1 = {
keyseq::keycode::translate_slen(keycode1),
keyseq::keycode::translate_slen(static_cast<wchar_t>(keycode1 & 0xffff)),
(modifiers & 0x100) != 0,
(modifiers & 0x200) != 0,
(modifiers & 0x400) != 0 };
ks.seq.push_back(kc1);
keyseq::keycode kc2 = { keyseq::keycode::translate_slen(keycode), shift };
keyseq::keycode kc2 = { keyseq::keycode::translate_slen(static_cast<wchar_t>(keycode & 0xffff)), shift };
ks.seq.push_back(kc2);
} else {
// First key in the sequence is only modifier(s).
keyseq::keycode kc1 = {
keyseq::keycode::translate_slen(keycode),
keyseq::keycode::translate_slen(static_cast<wchar_t>(keycode & 0xffff)),
shift || (modifiers & 0x100) != 0,
(modifiers & 0x200) != 0,
(modifiers & 0x400) != 0 };

View File

@ -31,7 +31,11 @@
#include <WinStd/COM.h>
#include <WinStd/Win.h>
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/debug.h>
#pragma warning(pop)
#pragma warning(push)
#pragma warning(disable: 4091)
@ -60,7 +64,8 @@ namespace ZRCola {
int rank; ///< Sequence rank
std::wstring str; ///< Sequence string
inline charseq()
inline charseq() :
rank(0)
{
}
@ -126,6 +131,8 @@ namespace ZRCola {
charseq src; ///< Source sequence
std::string norm; ///< Normalization footprint
charseq dst; ///< Destination sequence
inline translation() : set(0) {}
};
@ -137,6 +144,8 @@ namespace ZRCola {
int set; ///< ID
std::wstring src; ///< Source name
std::wstring dst; ///< Destination name
inline transet() : set(0) {}
};
@ -149,6 +158,11 @@ namespace ZRCola {
int rank; ///< Rank
std::wstring name; ///< Name
std::vector<int> sets; ///< Sets
inline transeq() :
seq(0),
rank(0)
{}
};
@ -200,6 +214,8 @@ namespace ZRCola {
public:
ZRCola::langid_t lang; ///< Language ID
std::wstring name; ///< Name
inline language() : lang(ZRCola::langid_t::blank) {}
};
@ -210,6 +226,8 @@ namespace ZRCola {
public:
std::wstring chr; ///> Character
ZRCola::langid_t lang; ///< Language ID
inline langchar() : lang(ZRCola::langid_t::blank) {}
};
@ -223,6 +241,8 @@ namespace ZRCola {
std::wstring name; ///< Name
std::vector<wchar_t> chars; ///< Characters (zero-delimited)
std::vector<unsigned __int16> show; ///< Bit vector if particular character from \c chars is displayed initially
inline chrgrp() : grp(0), rank(0) {}
};
@ -325,7 +345,7 @@ namespace ZRCola {
class character_desc_idx : public std::map<std::wstring, std::vector<wchar_t>, character_desc_idx_less>
{
public:
static void parse_keywords(const wchar_t *str, std::set<std::wstring> &terms);
static void parse_keywords(_In_ const wchar_t *str, _Inout_ std::set<std::wstring> &terms);
void add_keywords(const std::set<std::wstring> &terms, const std::wstring &chr, size_t sub = 0);
inline void add_keywords(const wchar_t *str, const std::wstring &chr, size_t sub = 0)
{
@ -369,6 +389,8 @@ namespace ZRCola {
ZRCola::chrcatid_t cat; ///> Category ID
int rank; ///< Rank
std::wstring name; ///< Name
inline chrcat() : cat(ZRCola::chrcatid_t::blank), rank(0) {}
};
@ -379,6 +401,8 @@ namespace ZRCola {
public:
std::wstring chr; ///> Character
int tag; ///< Tag ID
inline chrtag() : tag(0) {}
};
@ -389,6 +413,8 @@ namespace ZRCola {
public:
int tag; ///< Tag ID
std::map<LCID, std::list<std::wstring> > names; ///< Names
inline tagname() : tag(0) {}
};

View File

@ -34,7 +34,9 @@ public:
int rank_dst; ///< Destination character rank
string norm; ///< Normalization footprint
inline com_translation()
inline com_translation() :
rank_src(0),
rank_dst(0)
{
}
@ -65,7 +67,7 @@ public:
{
}
inline com_translation(com_translation &&other) :
inline com_translation(com_translation &&other) noexcept :
rank_src( other.rank_src ),
rank_dst( other.rank_dst ),
norm (std::move(other.norm ))
@ -82,7 +84,7 @@ public:
return *this;
}
inline com_translation& operator=(com_translation &&other)
inline com_translation& operator=(com_translation &&other) noexcept
{
if (this != std::addressof(other)) {
rank_src = other.rank_src ;
@ -213,8 +215,8 @@ static inline set<ZRCola::DBSource::charseq> permutate_and_translate_inv(_In_ co
// Secondary permutation inverse translate.
auto res_perm = translate_inv(db_trans, db_np, str_perm.c_str(), path);
for (auto r = res_perm.begin(), r_end = res_perm.end(); r != r_end; ++r)
res.insert(ZRCola::DBSource::charseq(r->rank + 1, std::move(r->str)));
for (auto r = res_perm.cbegin(), r_end = res_perm.cend(); r != r_end; ++r)
res.insert(ZRCola::DBSource::charseq(r->rank + 1, r->str));
}
}
@ -371,14 +373,14 @@ int _tmain(int argc, _TCHAR *argv[])
assert(!res.empty());
// Add translation to temporary database.
for (auto r = res.begin(), r_end = res.end(); r != r_end; ++r) {
for (auto r = res.cbegin(), r_end = res.cend(); r != r_end; ++r) {
translation_db::mapped_type::mapped_type ct(d1->second.rank_src + r->rank, d1->second.rank_dst);
auto hit = t2->second.find(r->str);
if (hit != t2->second.end()) {
hit->second.rank_src = std::min<int>(hit->second.rank_src, ct.rank_src);
hit->second.rank_dst = std::max<int>(hit->second.rank_dst, ct.rank_dst);
} else
t2->second.insert(pair<translation_db::mapped_type::key_type, translation_db::mapped_type::mapped_type>(std::move(r->str), std::move(ct)));
t2->second.insert(pair<translation_db::mapped_type::key_type, translation_db::mapped_type::mapped_type>(r->str, std::move(ct)));
}
}
}
@ -393,11 +395,11 @@ int _tmain(int argc, _TCHAR *argv[])
trans.set = 0;
for (auto t = db_temp2.cbegin(), t_end = db_temp2.cend(); t != t_end; ++t) {
// Add translation to index and data.
trans.dst.str = std::move(t->first);
trans.dst.str = t->first;
for (auto d = t->second.cbegin(), d_end = t->second.cend(); d != d_end; ++d) {
trans.dst.rank = d->second.rank_dst;
trans.src.rank = d->second.rank_src;
trans.src.str = std::move(d->first);
trans.src.str = d->first;
db_trans << trans;
}
}

View File

@ -23,13 +23,16 @@
#include "dbsource.h"
#include "parse.h"
#include <wxex/common.h>
#include <wxex/comutils.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/app.h>
#include <wx/cmdline.h>
#include <wx/config.h>
#include <wx/intl.h>
#include <wxex/common.h>
#include <wxex/comutils.h>
#pragma warning(pop)
#include <stdex/idrec.h>

View File

@ -58,7 +58,7 @@ extern "C" void WinMainCRTStartup()
LPTSTR pszTempFolder;
DWORD dwLength;
if ((dwLength = GetEnvironmentVariable(TEXT("TEMP"), NULL, 0)) != 0 &&
(pszTempFolder = (LPTSTR)LocalAlloc(LMEM_FIXED, (dwLength + 1)*sizeof(TCHAR))) != NULL) // +1 is for trailing backslash when missing!
(pszTempFolder = (LPTSTR)LocalAlloc(LMEM_FIXED, (dwLength + 2)*sizeof(TCHAR))) != NULL) // +1 for trailing backslash when missing, +1 for zero terminator
{
dwLength = ::GetEnvironmentVariable(TEXT("TEMP"), pszTempFolder, dwLength);

View File

@ -31,6 +31,8 @@
<IncludePath>$(WXWIN)\include\msvc;$(WXWIN)\include;$(IncludePath)</IncludePath>
<SourcePath>$(WXWIN)\src\aui;$(WXWIN)\src\cocoa;$(WXWIN)\src\common;$(WXWIN)\src\dfb;$(WXWIN)\src\expat;$(WXWIN)\src\generic;$(WXWIN)\src\gtk;$(WXWIN)\src\gtk1;$(WXWIN)\src\html;$(WXWIN)\src\jpeg;$(WXWIN)\src\motif;$(WXWIN)\src\msdos;$(WXWIN)\src\msw;$(WXWIN)\src\os2;$(WXWIN)\src\osx;$(WXWIN)\src\png;$(WXWIN)\src\propgrid;$(WXWIN)\src\regex;$(WXWIN)\src\ribbon;$(WXWIN)\src\richtext;$(WXWIN)\src\stc;$(WXWIN)\src\tiff;$(WXWIN)\src\univ;$(WXWIN)\src\unix;$(WXWIN)\src\x11;$(WXWIN)\src\xml;$(WXWIN)\src\xrc;$(WXWIN)\src\zlib;$(SourcePath)</SourcePath>
<LinkIncremental>false</LinkIncremental>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
@ -42,6 +44,7 @@
<StringPooling>true</StringPooling>
<DisableSpecificWarnings>4100;4505</DisableSpecificWarnings>
<SupportJustMyCode>false</SupportJustMyCode>
<EnablePREfast>true</EnablePREfast>
</ClCompile>
<Link>
<OptimizeReferences>true</OptimizeReferences>

@ -1 +1 @@
Subproject commit 7d2062d3bf8e293d9a8585817e4e3f002d20bf62
Subproject commit 7c5f20d7563a6ab966164c0cdb48f8e1f64c4742

View File

@ -220,11 +220,11 @@ namespace ZRCola {
{
this->cat = cat;
this->chr_to = static_cast<unsigned __int16>(chr_len);
if (chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
this->desc_to = static_cast<unsigned __int16>(this->chr_to + desc_len);
if (desc_len) memcpy(this->data + this->chr_to, desc, sizeof(wchar_t)*desc_len);
if (desc && desc_len) memcpy(this->data + this->chr_to, desc, sizeof(wchar_t)*desc_len);
this->rel_to = static_cast<unsigned __int16>(this->desc_to + rel_len);
if (rel_len) memcpy(this->data + this->desc_to, rel, sizeof(wchar_t)*rel_len);
if (rel && rel_len) memcpy(this->data + this->desc_to, rel, sizeof(wchar_t)*rel_len);
}
inline const wchar_t* chr () const { return data; };
@ -378,7 +378,7 @@ namespace ZRCola {
this->cat = cat;
this->rank = rank;
this->name_to = static_cast<unsigned __int16>(name_len);
if (name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
}
inline const wchar_t* name () const { return data; };
@ -540,7 +540,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::charac
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
} else
db.data.clear();
@ -585,7 +585,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
return stream;
}
@ -624,7 +624,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
return stream;
}
@ -656,7 +656,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrcat
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
} else
db.data.clear();

View File

@ -462,7 +462,7 @@ namespace ZRCola {
/// - \c true if found
/// - \c false otherwise
///
bool find(_In_count_(key_len) const T_key *key, _In_ size_t key_len, _Out_ const T_val **val, _Out_ size_t *val_len) const
_Success_(return) bool find(_In_count_(key_len) const T_key *key, _In_ size_t key_len, _Out_ const T_val **val, _Out_ size_t *val_len) const
{
for (size_type start = 0, end = size(); start < end; ) {
size_type m = (start + end) / 2;
@ -510,7 +510,7 @@ namespace ZRCola {
size_t src; ///< Character index in source string
size_t dst; ///< Character index in destination string
inline mapping() {};
inline mapping() : src(0), dst(0) {};
inline mapping(_In_ size_t s, _In_ size_t d) : src(s), dst(d) {}
///
@ -588,7 +588,7 @@ namespace ZRCola {
/// \param[in] count Number of characters in string \p str
/// \param[in] sep Separator
///
inline std::string GetUnicodeDumpA(_In_ const wchar_t *str, _In_ size_t count, _In_opt_z_ const char *sep = "+")
inline std::string GetUnicodeDumpA(_In_ const wchar_t *str, _In_ size_t count, _In_z_ const char *sep = "+")
{
std::string out;
size_t dump_len_max = strlen(sep) + 4 + 1;
@ -611,7 +611,7 @@ namespace ZRCola {
/// \param[in] count Number of characters in string \p str
/// \param[in] sep Separator
///
inline std::wstring GetUnicodeDumpW(_In_ const wchar_t *str, _In_ size_t count, _In_opt_z_ const wchar_t *sep = L"+")
inline std::wstring GetUnicodeDumpW(_In_ const wchar_t *str, _In_ size_t count, _In_z_ const wchar_t *sep = L"+")
{
std::wstring out;
size_t dump_len_max = wcslen(sep) + 4 + 1;
@ -661,7 +661,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::i
// Write index data.
if (stream.fail()) return stream;
stream.write((const char*)idx.data(), sizeof(T_idx)*count);
stream.write((const char*)idx.data(), sizeof(T_idx)*static_cast<std::streamsize>(count));
return stream;
}
@ -682,12 +682,15 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::index<
// Read index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (!stream.good()) {
idx.clear();
return stream;
}
if (count) {
// Read index data.
idx.resize(count);
stream.read((char*)idx.data(), sizeof(T_idx)*count);
stream.read((char*)idx.data(), sizeof(T_idx)*static_cast<std::streamsize>(count));
} else
idx.clear();
@ -723,7 +726,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
// Write index data.
if (stream.fail()) return stream;
stream.write((const char*)idx.data(), sizeof(ZRCola::textindex<T_key, T_val, T_idx>::value_type)*count);
stream.write((const char*)idx.data(), sizeof(ZRCola::textindex<T_key, T_val, T_idx>::value_type)*static_cast<std::streamsize>(count));
// Write key count.
auto key_count = idx.keys.size();
@ -740,7 +743,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
// Write key data.
if (stream.fail()) return stream;
stream.write((const char*)idx.keys.data(), sizeof(std::vector<T_key>::value_type)*count);
stream.write((const char*)idx.keys.data(), sizeof(std::vector<T_key>::value_type)*static_cast<std::streamsize>(count));
// Write value count.
auto value_count = idx.values.size();
@ -757,7 +760,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
// Write value data.
if (stream.fail()) return stream;
stream.write((const char*)idx.values.data(), sizeof(std::vector<T_val>::value_type)*count);
stream.write((const char*)idx.values.data(), sizeof(std::vector<T_val>::value_type)*static_cast<std::streamsize>(count));
return stream;
}
@ -778,12 +781,15 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::textin
// Read text index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (!stream.good()) {
idx.clear();
return stream;
}
if (count) {
// Read text index.
idx.resize(count);
stream.read((char*)idx.data(), sizeof(ZRCola::textindex<T_key, T_val, T_idx>::value_type)*count);
stream.read((char*)idx.data(), sizeof(ZRCola::textindex<T_key, T_val, T_idx>::value_type)*static_cast<std::streamsize>(count));
if (!stream.good()) return stream;
} else
idx.clear();
@ -795,7 +801,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::textin
if (count) {
// Read keys.
idx.keys.resize(count);
stream.read((char*)idx.keys.data(), sizeof(std::vector<T_key>::value_type)*count);
stream.read((char*)idx.keys.data(), sizeof(std::vector<T_key>::value_type)*static_cast<std::streamsize>(count));
if (!stream.good()) return stream;
} else
idx.keys.clear();
@ -807,7 +813,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::textin
if (count) {
// Read values.
idx.values.resize(count);
stream.read((char*)idx.values.data(), sizeof(std::vector<T_val>::value_type)*count);
stream.read((char*)idx.values.data(), sizeof(std::vector<T_val>::value_type)*static_cast<std::streamsize>(count));
} else
idx.values.clear();

View File

@ -71,7 +71,7 @@ namespace ZRCola {
{
this->lang = lang;
this->chr_to = static_cast<unsigned __int16>(chr_len);
if (chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
}
inline const wchar_t* chr () const { return data; };
@ -235,7 +235,7 @@ namespace ZRCola {
{
this->lang = lang;
this->name_to = static_cast<unsigned __int16>(name_len);
if (name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
}
inline const wchar_t* name () const { return data; };
@ -341,7 +341,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::l
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
return stream;
}
@ -375,7 +375,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::langch
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
} else
db.data.clear();
@ -412,7 +412,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::l
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
return stream;
}
@ -440,7 +440,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::langua
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
} else
db.data.clear();

View File

@ -73,7 +73,7 @@ namespace ZRCola {
{
this->tag = tag;
this->chr_to = static_cast<unsigned __int16>(chr_len);
if (chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
}
inline const wchar_t* chr () const { return data; };
@ -271,7 +271,7 @@ namespace ZRCola {
this->tag = tag;
this->locale = locale;
this->name_to = static_cast<unsigned __int16>(name_len);
if (name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
}
inline const wchar_t* name () const { return data; };
@ -481,7 +481,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
return stream;
}
@ -513,7 +513,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrtag
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
} else
db.data.clear();
@ -554,7 +554,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
return stream;
}
@ -586,7 +586,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::tagnam
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
} else
db.data.clear();

View File

@ -106,9 +106,9 @@ namespace ZRCola {
this->dst_rank = dst_rank;
this->src_rank = src_rank;
this->dst_to = static_cast<unsigned __int16>(dst_len);
if (dst_len) memcpy(this->data, dst, sizeof(wchar_t)*dst_len);
if (dst && dst_len) memcpy(this->data, dst, sizeof(wchar_t)*dst_len);
this->src_to = static_cast<unsigned __int16>(this->dst_to + src_len);
if (src_len) memcpy(this->data + this->dst_to, src, sizeof(wchar_t)*src_len);
if (src && src_len) memcpy(this->data + this->dst_to, src, sizeof(wchar_t)*src_len);
}
inline const wchar_t* dst () const { return data; };
@ -369,9 +369,9 @@ namespace ZRCola {
{
this->set = set;
this->src_to = static_cast<unsigned __int16>(src_len);
if (src_len) memcpy(this->data, src, sizeof(wchar_t)*src_len);
if (src && src_len) memcpy(this->data, src, sizeof(wchar_t)*src_len);
this->dst_to = static_cast<unsigned __int16>(this->src_to + dst_len);
if (dst_len) memcpy(this->data + this->src_to, dst, sizeof(wchar_t)*dst_len);
if (dst && dst_len) memcpy(this->data + this->src_to, dst, sizeof(wchar_t)*dst_len);
}
inline const wchar_t* src () const { return data; };
@ -489,9 +489,9 @@ namespace ZRCola {
this->seq = seq;
this->rank = rank;
this->name_to = static_cast<unsigned __int16>(name_len);
if (name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
this->sets_to = static_cast<unsigned __int16>(this->name_to + sets_len);
if (sets_len) memcpy(this->data + this->name_to, sets, sizeof(transetid_t)*sets_len);
if (sets && sets_len) memcpy(this->data + this->name_to, sets, sizeof(transetid_t)*sets_len);
}
inline const wchar_t* name () const { return data; };
@ -663,7 +663,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
return stream;
}
@ -695,7 +695,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::transl
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
} else
db.data.clear();
@ -732,7 +732,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
return stream;
}
@ -760,7 +760,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::transe
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
} else
db.data.clear();
@ -801,7 +801,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
return stream;
}
@ -833,7 +833,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::transe
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
} else
db.data.clear();

View File

@ -98,7 +98,7 @@ void ZRCola::translation_db::Translate(_In_ transetid_t set, _In_z_count_(inputM
}
void ZRCola::translation_db::TranslateInv(_In_ transetid_t set, _In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_ const langchar_db *lc_db, _In_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map) const
void ZRCola::translation_db::TranslateInv(_In_ transetid_t set, _In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_opt_ const langchar_db *lc_db, _In_opt_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map) const
{
assert(input || inputMax == 0);

View File

@ -9,7 +9,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\stdex\include;..\..\libZRCola\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\stdex\include;..\..\wxExtend\include;..\..\libZRCola\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -86,9 +86,9 @@ namespace ZRCola {
this->grp = grp;
this->rank = rank;
this->name_to = static_cast<unsigned __int16>(name_len);
if (name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
this->chrlst_to = static_cast<unsigned __int16>(this->name_to + chrlst_len);
if (chrlst_len) {
if (chrlst && chrshow && chrlst_len) {
memcpy(this->data + this->name_to, chrlst, sizeof(wchar_t)*chrlst_len);
memcpy(this->data + this->chrlst_to, chrshow, (chrlst_len + sizeof(*data)*8 - 1)/8);
}
@ -220,7 +220,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
return stream;
}
@ -248,7 +248,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrgrp
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
} else
db.data.clear();

View File

@ -24,7 +24,11 @@
#include <stdex/idrec.h>
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/string.h>
#pragma warning(pop)
#include <istream>
#include <ostream>
@ -81,9 +85,9 @@ namespace ZRCola {
_In_opt_ size_t chr_len = 0)
{
this->chr_to = static_cast<unsigned __int16>(chr_len);
if (chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
this->seq_to = static_cast<unsigned __int16>(this->chr_to + seq_count * sizeof(key_t) / sizeof(*data));
if (seq_count) memcpy(this->data + this->chr_to, seq, sizeof(key_t)*seq_count);
if (seq && seq_count) memcpy(this->data + this->chr_to, seq, sizeof(key_t)*seq_count);
}
inline const wchar_t* chr () const { return data; };
@ -324,7 +328,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::k
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
return stream;
}
@ -356,7 +360,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::keyseq
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
} else
db.data.clear();

View File

@ -34,10 +34,10 @@ bool ZRCola::keyseq_db::GetSequenceAsText(_In_count_(seq_len) const keyseq::key_
#if defined(__WXMSW__)
// Translate from U.S. Keyboard to scan code.
static const HKL s_hkl = ::LoadKeyboardLayout(_T("00000409"), 0);
k = ::MapVirtualKeyEx(k, MAPVK_VK_TO_VSC, s_hkl);
k = static_cast<wchar_t>(::MapVirtualKeyEx(k, MAPVK_VK_TO_VSC, s_hkl) & 0xffff);
// Translate from scan code to local keyboard.
k = ::MapVirtualKey(k, MAPVK_VSC_TO_VK);
k = static_cast<wchar_t>(::MapVirtualKey(k, MAPVK_VSC_TO_VK) & 0xffff);
#endif
switch (k) {
case 0 : return false;
@ -88,7 +88,7 @@ bool ZRCola::keyseq_db::GetSequenceAsText(_In_count_(seq_len) const keyseq::key_
default:
#if defined(__WXMSW__)
k = ::MapVirtualKey(k, MAPVK_VK_TO_CHAR);
k = static_cast<wchar_t>(::MapVirtualKey(k, MAPVK_VK_TO_CHAR) & 0xffff);
#endif
str += k;
}

View File

@ -23,6 +23,10 @@
#include "../include/zrcolaui/chargroup.h"
#include "../include/zrcolaui/keyboard.h"
#include <wxex/common.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/translation.h>
#pragma warning(pop)
#include <assert.h>

@ -1 +1 @@
Subproject commit e6a06ee2d1ca316b44ac61ba13cd80fd7b4dd090
Subproject commit 325f9d6b0849207445f28a3eece7a8c1f4bdb278

@ -1 +1 @@
Subproject commit c22a5dd294be401b93b16d8551e8f0e7163ee331
Subproject commit 5fa66f625db9095e71b4bbe0fb03a389956700c7