mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-14 01:47:30 +00:00
Fixes #4423. Using a named character constant with a store name that included characters outside ascii could cause kmcmpdll to crash with an assertion failure. This fix allows store names defined in the .kmn file to use characters outside ascii. Note that more work needs to be done on which characters are acceptable to use, as this is somewhat implementation-specific according to the C++ specification for `iswalpha`. Added a test case to verify various named code constant examples. Also removes dead code for `IsCJKUnifiedIdeograph` as this was never used and somewhat pointless in any case. NamedCodeConstants.cpp could stand to be rewritten using `std::map` or equivalent. Current implementation is pretty icky.
36 lines
832 B
C++
36 lines
832 B
C++
|
|
#ifndef _NAMEDCODECONSTANTS_H
|
|
#define _NAMEDCODECONSTANTS_H
|
|
|
|
#define MAX_ENAME 128
|
|
#define ALLOC_SIZE 256
|
|
|
|
struct NCCENTRY
|
|
{
|
|
wchar_t name[MAX_ENAME+1];
|
|
int code;
|
|
DWORD storeIndex;
|
|
};
|
|
|
|
class NamedCodeConstants
|
|
{
|
|
private:
|
|
NCCENTRY *entries; // entries from &includecodes
|
|
NCCENTRY *entries_file; // entries from store(myconst) x
|
|
int nEntries, nEntries_file;
|
|
int chrindexes[128]; // A-Z, 0-9, -, _; simple index
|
|
|
|
int GetCode_IncludedCodes(const wchar_t *codename);
|
|
void AddCode_IncludedCodes(int n, const wchar_t *p);
|
|
BOOL IntLoadFile(const char *filename);
|
|
public:
|
|
NamedCodeConstants();
|
|
~NamedCodeConstants();
|
|
|
|
void reindex();
|
|
void AddCode(int n, const wchar_t *p, DWORD storeIndex);
|
|
BOOL LoadFile(const char *filename);
|
|
int GetCode(const wchar_t *codename, DWORD *storeIndex);
|
|
};
|
|
|
|
#endif //_NAMEDCODECONSTANTS_H
|