mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-22 23:57:42 +00:00
chore(developer): changes in UnrechableRules::VerifyUnreachableRules() to run test_6440_unreachable_code..kmn
This commit is contained in:
parent
dcd8ef8526
commit
76d3534871
5 changed files with 28 additions and 9 deletions
|
|
@ -81,8 +81,8 @@ KMX_DWORD CheckFilenameConsistency(KMX_WCHAR const * Filename, bool ReportMissin
|
|||
}
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
// convert char16_t to wchar_t*
|
||||
// char16_t -> std::u16string
|
||||
// convert char16_t* -> std::u16string -> std::string -> std::wstring -> wchar_t*
|
||||
// char16_t* -> std::u16string
|
||||
std::u16string u16str(Name);
|
||||
// std::u16string -> std::string
|
||||
std::string stri = string_from_u16string(u16str);
|
||||
|
|
|
|||
|
|
@ -110,7 +110,8 @@ const struct CompilerError CompilerErrors[] = {
|
|||
{ CERR_DuplicateGroup , "A group with this name has already been defined."},
|
||||
{ CERR_DuplicateStore , "A store with this name has already been defined."},
|
||||
{ CERR_RepeatedBegin , "Begin has already been set"},
|
||||
{ CHINT_FilenameHasDifferingCase , "HINT: Casing differences may fail on some platforms."},
|
||||
{ CHINT_FilenameHasDifferingCase , "Casing differences may fail on some platforms."},
|
||||
{ CHINT_UnreachableRule , "This rule will never be matched as another rule takes precedence"},
|
||||
|
||||
{ 0, nullptr }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -66,12 +66,12 @@
|
|||
*/
|
||||
#include "pch.h"
|
||||
|
||||
#include <compfile.h>
|
||||
#include "compfile.h"
|
||||
#include <comperr.h>
|
||||
#include "../../../../common/windows/cpp/include/vkeys.h"
|
||||
#include <cuchar>
|
||||
#include <versioning.h>
|
||||
#include <kmcmpdll.h>
|
||||
#include "kmcmpdll.h"
|
||||
#include <DeprecationChecks.h>
|
||||
|
||||
#include "virtualcharkeys.h"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
#include "pch.h"
|
||||
|
||||
#include <compfile.h>
|
||||
#include "compfile.h"
|
||||
#include <comperr.h>
|
||||
#include "../../../../common/windows/cpp/include/vkeys.h"
|
||||
#include <kmcmpdll.h>
|
||||
#include "kmcmpdll.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
|
@ -12,7 +12,25 @@
|
|||
#include <sstream>
|
||||
|
||||
#include "UnreachableRules.h"
|
||||
|
||||
namespace kmcmp {
|
||||
|
||||
WCHAR conv_KMX_WCHAR__TO__WCHAR(KMX_WCHAR in) {
|
||||
// char16_t -> std::u16string -> std::string -> std::wstring -> wchar_t*
|
||||
std::u16string u16str(&in);
|
||||
std::string stri = string_from_u16string(u16str);
|
||||
std::wstring wstr = wstring_from_string(stri);
|
||||
return *wstring_from_string(stri).c_str();
|
||||
}
|
||||
|
||||
std::wstring MakeHashKeyFromFileKey16(PFILE_KEY kp) {
|
||||
std::wstringstream key16;
|
||||
const WCHAR* ctxt = u16fmt((PKMX_WCHAR) kp->dpContext).c_str();
|
||||
key16 << conv_KMX_WCHAR__TO__WCHAR(kp->Key) << "," << (DWORD) kp->ShiftFlags << ",";
|
||||
if (ctxt) key16 << ctxt;
|
||||
return key16.str();
|
||||
};
|
||||
|
||||
std::wstring MakeHashKeyFromFileKey(PFILE_KEY kp) {
|
||||
std::wstringstream key;
|
||||
key << kp->Key << "," << kp->ShiftFlags << ",";
|
||||
|
|
@ -31,7 +49,7 @@ KMX_DWORD VerifyUnreachableRules(PFILE_GROUP gp) {
|
|||
std::unordered_set<int> reportedLines;
|
||||
|
||||
for (i = 0; i < gp->cxKeyArray; i++, kp++) {
|
||||
std::wstring key = kmcmp::MakeHashKeyFromFileKey(kp);
|
||||
std::wstring key = kmcmp::MakeHashKeyFromFileKey16(kp);
|
||||
if (map.count(key) > 0) {
|
||||
FILE_KEY const & k1 = map.at(key);
|
||||
if (kp->Line != k1.Line && reportedLines.count(kp->Line) == 0) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <compfile.h>
|
||||
#include "compfile.h"
|
||||
|
||||
namespace kmcmp {
|
||||
KMX_BOOL AddCompileWarning(LPSTR buf);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue