Skip to content

Commit daf05ac

Browse files
authored
Merge pull request #59 from deton/crvmerge331
Merge CorvusSKK 3.3.1
2 parents f650384 + 080dd33 commit daf05ac

69 files changed

Lines changed: 199 additions & 646 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LICENSE.TXT

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ CorvusSKK
3333

3434
The MIT License
3535

36-
Copyright (C) 2011-2024 SASAKI Nobuyuki
36+
Copyright (C) 2011-2025 SASAKI Nobuyuki
3737

3838
Permission is hereby granted, free of charge, to any person obtaining a copy
3939
of this software and associated documentation files (the "Software"), to deal
@@ -118,7 +118,7 @@ Lua
118118

119119
The MIT License
120120

121-
Copyright (C) 1994-2024 Lua.org, PUC-Rio.
121+
Copyright (C) 1994-2025 Lua.org, PUC-Rio.
122122

123123
Permission is hereby granted, free of charge, to any person obtaining a copy
124124
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# tsf-tutcode ver. 0.9.3
2+
# tsf-tutcode ver. 0.9.4
33

44
Windowsで動作する漢字直接入力用のIMEです。
55

@@ -889,7 +889,7 @@ ASCII、全英文字の組み合せを指定します。最大で128行です。
889889

890890
辞書管理プロセス (imtutmgr.exe) の各機能の拡張、プログラム実行変換もどき、数値変換をLuaスクリプトで実装しています。
891891

892-
現在使用しているLuaのバージョンは5.4.7です
892+
現在使用しているLuaのバージョンは5.4.8です
893893

894894
詳細はこちらを参照してください。https://www.lua.org/manual/5.4/manual.html
895895

@@ -1116,7 +1116,9 @@ tsf-tutcodeは未実装機能が多いため。
11161116

11171117
### 開発環境
11181118

1119-
Visual Studio Community 2022 17.10.5
1119+
Visual Studio Community 2022 17.14.15
1120+
1121+
* .NET desktop development
11201122

11211123
* Desktop development with C++
11221124

@@ -1125,15 +1127,12 @@ Visual Studio Community 2022 17.10.5
11251127
* MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
11261128
* SDKs, libraries, and frameworks
11271129
* C++ ATL for latest v143 build tools (x86 & x64)
1128-
* Windows 11 SDK (10.0.26100.0)
1129-
1130-
WiX Toolset v5.0.1
11311130

1132-
* 要 .NET SDK 6 以降
1131+
WiX Toolset v6.0.2
11331132

11341133
* ビルド用バッチファイル内の dotnet build コマンドによって暗黙的に復元
11351134

1136-
pandoc 3.3
1135+
pandoc 3.8
11371136

11381137
### ビルド手順
11391138

@@ -1252,12 +1251,12 @@ pandoc 3.3
12521251

12531252
---
12541253

1255-
Copyright (C) 2013-2024 KIHARA, Hideto
1254+
Copyright (C) 2013-2025 KIHARA, Hideto
12561255
https://github.com/deton/tsf-tutcode
12571256

12581257
以下CorvusSKKのCopyright:
12591258

1260-
Copyright (C) 2011-2024 SASAKI Nobuyuki
1259+
Copyright (C) 2011-2025 SASAKI Nobuyuki
12611260

12621261
nathancorvussolis@gmail.com
12631262

common/common.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,25 @@ BOOL StartProcess(HMODULE hCurrentModule, LPCWSTR lpFileName, LPCWSTR lpArgs)
374374

375375
return bRet;
376376
}
377+
378+
const std::wregex &RegExp(const std::wstring &pattern)
379+
{
380+
static std::mutex regex_cache_mutex;
381+
std::lock_guard<std::mutex> regex_cache_lock(regex_cache_mutex);
382+
383+
static std::unordered_map<std::wstring, std::wregex> regex_cache;
384+
auto it = regex_cache.find(pattern);
385+
if (it == regex_cache.end())
386+
{
387+
std::wregex re;
388+
try
389+
{
390+
re = std::wregex(pattern);
391+
}
392+
catch (const std::regex_error &)
393+
{
394+
}
395+
it = regex_cache.emplace(pattern, re).first;
396+
}
397+
return it->second;
398+
}

common/common.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ BOOL IsWindowsVersionOrLater(DWORD dwMajorVersion, DWORD dwMinorVersion, DWORD d
103103
#define C_USER_DEFAULT_SCREEN_DPI 96
104104
#define C_FONT_LOGICAL_HEIGHT_PPI 72
105105

106-
BOOL GetUserUUID(LPWSTR *ppszUUID);
107-
BOOL GetUserSid(LPWSTR *ppszUserSid);
108-
109-
BOOL StartProcess(HMODULE hCurrentModule, LPCWSTR lpFileName, LPCWSTR lpArgs = nullptr);
110-
111106
#define FORWARD_ITERATION_I(iterator, container) \
112107
for (auto (iterator) = (container).begin(); (iterator) != (container).end(); ++(iterator))
113108
#define FORWARD_ITERATION(iterator, container) \
@@ -116,3 +111,10 @@ BOOL StartProcess(HMODULE hCurrentModule, LPCWSTR lpFileName, LPCWSTR lpArgs = n
116111
for (auto (reverse_iterator) = (container).rbegin(); (reverse_iterator) != (container).rend(); ++(reverse_iterator))
117112
#define REVERSE_ITERATION(reverse_iterator, container) \
118113
for (auto (reverse_iterator) = (container).rbegin(); (reverse_iterator) != (container).rend(); )
114+
115+
BOOL GetUserUUID(LPWSTR *ppszUUID);
116+
BOOL GetUserSid(LPWSTR *ppszUserSid);
117+
118+
BOOL StartProcess(HMODULE hCurrentModule, LPCWSTR lpFileName, LPCWSTR lpArgs = nullptr);
119+
120+
const std::wregex &RegExp(const std::wstring &pattern);

common/parseskkdic.cpp

Lines changed: 25 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,15 @@ int ReadSKKDicLine(FILE *fp, SKKDICENCODING encoding, int &okuri, std::wstring &
9191

9292
std::wstring s = wstrbuf;
9393

94-
static const std::wregex rectrl(L"[\\x00-\\x19]");
95-
s = std::regex_replace(s, rectrl, L"");
94+
s = std::regex_replace(s, RegExp(L"[\\x00-\\x19]"), L"");
9695

9796
if (okuri == 1)
9897
{
9998
//送りありエントリのブロック
10099
ParseSKKDicOkuriBlock(s, o);
101100

102101
//送りありエントリのブロックを除去
103-
static const std::wregex reblock(L"\\[[^\\[\\]]+?/[^\\[\\]]+?/\\]/");
104-
s = std::regex_replace(s, reblock, L"");
102+
s = std::regex_replace(s, RegExp(L"\\[[^\\[\\]]+?/[^\\[\\]]+?/\\]/"), L"");
105103
}
106104

107105
size_t is = s.find(L"\x20/");
@@ -175,7 +173,7 @@ void ParseSKKDicOkuriBlock(const std::wstring &s, SKKDICOKURIBLOCKS &o)
175173

176174
so = s;
177175

178-
static const std::wregex reblock(L"\\[([^\\[\\]]+?)(/[^\\[\\]]+?/)\\]/");
176+
const std::wregex &reblock = RegExp(L"\\[([^\\[\\]]+?)(/[^\\[\\]]+?/)\\]/");
179177

180178
while (std::regex_search(so, m, reblock))
181179
{
@@ -200,44 +198,32 @@ std::wstring ParseConcat(const std::wstring &s)
200198
LPCWSTR bsrep = L"\uF05C";
201199

202200
// (concat "*")
203-
static const std::wregex reconcat(L"^\\(\\s*concat\\s+\"(.+)\"\\s*\\)$");
201+
const std::wregex &reconcat = RegExp(L"^\\(\\s*concat\\s+\"(.+)\"\\s*\\)$");
204202

205203
if (std::regex_search(ret, reconcat))
206204
{
207-
std::wstring fmt, numstr, numtmpstr;
208-
std::wregex re;
205+
std::wstring numstr, numtmpstr;
209206
std::wsmatch res;
210207

211-
fmt.assign(L"$1");
212-
ret = std::regex_replace(ret, reconcat, fmt);
208+
ret = std::regex_replace(ret, reconcat, L"$1");
213209

214-
re.assign(L"\"\\s+\"");
215-
fmt.assign(L"");
216-
ret = std::regex_replace(ret, re, fmt);
210+
//concat
211+
ret = std::regex_replace(ret, RegExp(L"\"\\s+\""), L"");
217212

218213
//バックスラッシュ
219-
re.assign(L"\\\\\\\\");
220-
fmt.assign(bsrep);
221-
ret = std::regex_replace(ret, re, fmt);
214+
ret = std::regex_replace(ret, RegExp(L"\\\\\\\\"), bsrep);
222215

223216
//二重引用符
224-
re.assign(L"\\\\\\\"");
225-
fmt.assign(L"\\\"");
226-
ret = std::regex_replace(ret, re, fmt);
217+
ret = std::regex_replace(ret, RegExp(L"\\\\\\\""), L"\\\"");
227218

228219
//空白文字
229-
re.assign(L"\\\\s");
230-
fmt.assign(L"\x20");
231-
ret = std::regex_replace(ret, re, fmt);
220+
ret = std::regex_replace(ret, RegExp(L"\\\\s"), L"\x20");
232221

233222
//制御文字など
234-
re.assign(L"\\\\[abtnvfred ]");
235-
fmt.assign(L"");
236-
ret = std::regex_replace(ret, re, fmt);
223+
ret = std::regex_replace(ret, RegExp(L"\\\\[abtnvfred ]"), L"");
237224

238225
//8進数表記の文字
239-
re.assign(L"\\\\[0-3][0-7]{2}");
240-
while (std::regex_search(ret, res, re))
226+
while (std::regex_search(ret, res, RegExp(L"\\\\[0-3][0-7]{2}")))
241227
{
242228
numstr += res.prefix();
243229
numtmpstr = res.str();
@@ -252,14 +238,10 @@ std::wstring ParseConcat(const std::wstring &s)
252238
ret = numstr + ret;
253239

254240
//意味なしエスケープ
255-
re.assign(L"\\\\");
256-
fmt.assign(L"");
257-
ret = std::regex_replace(ret, re, fmt);
241+
ret = std::regex_replace(ret, RegExp(L"\\\\"), L"");
258242

259243
//バックスラッシュ
260-
re.assign(bsrep);
261-
fmt.assign(L"\\");
262-
ret = std::regex_replace(ret, re, fmt);
244+
ret = std::regex_replace(ret, RegExp(bsrep), L"\\");
263245
}
264246

265247
return ret;
@@ -270,27 +252,16 @@ std::wstring MakeConcat(const std::wstring &s)
270252
std::wstring ret = s;
271253

272254
// '/' or ';'
273-
static const std::wregex respcch(L"[/;]");
274-
275-
if (std::regex_search(ret, respcch))
255+
if (std::regex_search(ret, RegExp(L"[/;]")))
276256
{
277-
std::wstring fmt;
278-
std::wregex re;
279-
280257
// '"' -> "\"", '\' -> "\\"
281-
re.assign(L"([\"\\\\])");
282-
fmt.assign(L"\\$1");
283-
ret = std::regex_replace(ret, re, fmt);
258+
ret = std::regex_replace(ret, RegExp(L"([\"\\\\])"), L"\\$1");
284259

285260
// '/' -> "\057"
286-
re.assign(L"/");
287-
fmt.assign(L"\\057");
288-
ret = std::regex_replace(ret, re, fmt);
261+
ret = std::regex_replace(ret, RegExp(L"/"), L"\\057");
289262

290263
// ';' -> "\073"
291-
re.assign(L";");
292-
fmt.assign(L"\\073");
293-
ret = std::regex_replace(ret, re, fmt);
264+
ret = std::regex_replace(ret, RegExp(L";"), L"\\073");
294265

295266
ret = L"(concat \"" + ret + L"\")";
296267
}
@@ -304,50 +275,35 @@ std::wstring EscapeGadgetString(const std::wstring &s)
304275
LPCWSTR bsrep = L"\uF05C";
305276

306277
//実行変換もどきの文字列パラメータをエスケープ
307-
static const std::wregex regadget(L"^\\(.+\\)$");
308-
309-
if (std::regex_match(s, regadget))
278+
if (std::regex_match(s, RegExp(L"^\\(.+\\)$")))
310279
{
311280
std::wstring esc, str;
312281
std::wstring tmp = s;
313282
std::wsmatch m;
314283

315-
std::wstring fmt;
316-
std::wregex re;
317-
318284
// "\\" -> '\uF05C'
319-
re.assign(L"\\\\\\\\");
320-
fmt.assign(bsrep);
321-
tmp = std::regex_replace(tmp, re, fmt);
285+
tmp = std::regex_replace(tmp, RegExp(L"\\\\\\\\"), bsrep);
322286

323287
// <SPC>"..." ignoring escaped quotation
324-
static const std::wregex restring(L" (\"\"|\".*?[^\\\\]\")");
325-
326-
while (std::regex_search(tmp, m, restring))
288+
while (std::regex_search(tmp, m, RegExp(L" (\"\"|\".*?[^\\\\]\")")))
327289
{
328290
esc += m.prefix().str();
329291
str = m.str();
330292
tmp = m.suffix().str();
331293

332294
// '/' -> "\057"
333-
re.assign(L"/");
334-
fmt.assign(L"\\057");
335-
str = std::regex_replace(str, re, fmt);
295+
str = std::regex_replace(str, RegExp(L"/"), L"\\057");
336296

337297
// ';' -> "\073"
338-
re.assign(L";");
339-
fmt.assign(L"\\073");
340-
str = std::regex_replace(str, re, fmt);
298+
str = std::regex_replace(str, RegExp(L";"), L"\\073");
341299

342300
esc += str;
343301
}
344302

345303
esc += tmp;
346304

347305
// '\uF05C' -> "\\"
348-
re.assign(bsrep);
349-
fmt.assign(L"\\\\");
350-
esc = std::regex_replace(esc, re, fmt);
306+
esc = std::regex_replace(esc, RegExp(bsrep), L"\\\\");
351307

352308
ret = esc;
353309
}

common/pch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <vector>
1111
#include <map>
1212
#include <regex>
13+
#include <unordered_map>
14+
#include <mutex>
1315

1416
#include <Windows.h>
1517
#include <sddl.h>

common/version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#define TEXTSERVICE_DESC TEXTSERVICE_NAME L"_DEBUG"
88
#endif
99
#define TEXTSERVICE_DIR L"IMTSFTUTCODE"
10-
#define TEXTSERVICE_VER L"0.9.3"
10+
#define TEXTSERVICE_VER L"0.9.4"
1111

1212
//for resource
1313
#define RC_AUTHOR "KIHARA Hideto"
1414
#define RC_PRODUCT "tsf-tutcode"
15-
#define RC_VERSION "0.9.3"
16-
#define RC_VERSION_D 0,9,3,0
15+
#define RC_VERSION "0.9.4"
16+
#define RC_VERSION_D 0,9,4,0

imcrvcnf/DlgDicAddUrl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ INT_PTR CALLBACK DlgProcSKKDicAddUrl(HWND hDlg, UINT message, WPARAM wParam, LPA
2424
GetDlgItemTextW(hDlg, IDC_EDIT_SKK_DIC_URL, urlskkdic, _countof(urlskkdic));
2525
{
2626
// trim
27-
static const std::wregex retrim(L"^\\s+|\\s+$");
28-
std::wstring strurl = std::regex_replace(std::wstring(urlskkdic), retrim, L"");
27+
std::wstring strurl = std::regex_replace(urlskkdic, RegExp(L"^\\s+|\\s+$"), L"");
2928
_snwprintf_s(urlskkdic, _TRUNCATE, L"%s", strurl.c_str());
3029

3130
if (urlskkdic[0] == L'\0')

imcrvmgr/SearchCharacter.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,17 @@ std::wstring SearchUnicode(const std::wstring &searchkey)
1818
UCSCHAR ucp = 0;
1919
WCHAR utf16[3] = {};
2020

21-
// U+XXXXXX (XXXXXX : 0000-FFFF,10000-10FFFF)
22-
static const std::wregex reU(L"U\\+([1-9A-F]|10)?[0-9A-F]{4}");
23-
24-
// uxxxxxx (xxxxxx : 0000-ffff,10000-10ffff)
25-
static const std::wregex reL(L"u([1-9a-f]|10)?[0-9a-f]{4}");
26-
27-
if (std::regex_match(searchkey, reU))
21+
if (std::regex_match(searchkey, RegExp(L"U\\+([1-9A-F]|10)?[0-9A-F]{4}")))
2822
{
23+
// U+XXXXXX (XXXXXX : 0000-FFFF,10000-10FFFF)
2924
if (swscanf_s(searchkey.c_str(), L"U+%X", &ucp) != 1)
3025
{
3126
return candidate;
3227
}
3328
}
34-
else if (std::regex_match(searchkey, reL))
29+
else if (std::regex_match(searchkey, RegExp(L"u([1-9a-f]|10)?[0-9a-f]{4}")))
3530
{
31+
// uxxxxxx (xxxxxx : 0000-ffff,10000-10ffff)
3632
if (swscanf_s(searchkey.c_str(), L"u%x", &ucp) != 1)
3733
{
3834
return candidate;
@@ -66,9 +62,7 @@ std::wstring SearchJISX0213(const std::wstring &searchkey)
6662
UCSCHAR ucp[2] = {};
6763
WCHAR sucp[32] = {};
6864

69-
static const std::wregex re(L"[12]-(0[1-9]|[1-8][0-9]|9[0-4])-(0[1-9]|[0-8][0-9]|9[0-4])");
70-
71-
if (!std::regex_match(searchkey, re))
65+
if (!std::regex_match(searchkey, RegExp(L"[12]-(0[1-9]|[1-8][0-9]|9[0-4])-(0[1-9]|[0-8][0-9]|9[0-4])")))
7266
{
7367
return candidate;
7468
}
@@ -127,9 +121,7 @@ std::wstring SearchJISX0208(const std::wstring &searchkey)
127121
//JIS X 0208 区点番号
128122
int ku, ten;
129123

130-
static const std::wregex re(L"(0[1-9]|[1-8][0-9]|9[0-4])-(0[1-9]|[0-8][0-9]|9[0-4])");
131-
132-
if (!std::regex_match(searchkey, re))
124+
if (!std::regex_match(searchkey, RegExp(L"(0[1-9]|[1-8][0-9]|9[0-4])-(0[1-9]|[0-8][0-9]|9[0-4])")))
133125
{
134126
return candidate;
135127
}

0 commit comments

Comments
 (0)