@@ -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 }
0 commit comments