Skip to content

Commit eb53853

Browse files
committed
Tc567-4
add setting.charset make sure to use latest charset setting when reading setting file
1 parent 4dcf776 commit eb53853

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

aya5.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
2828
//
2929

3030
VS_VERSION_INFO VERSIONINFO
31-
FILEVERSION 5,67,3,0
31+
FILEVERSION 5,67,4,0
3232
PRODUCTVERSION 5,0,0,0
3333
FILEFLAGSMASK 0x3fL
3434
#ifdef _DEBUG
@@ -47,7 +47,7 @@ BEGIN
4747
VALUE "Comments", "YAYA\0"
4848
VALUE "CompanyName", "YAYA Development Team\0"
4949
VALUE "FileDescription", "yaya\0"
50-
VALUE "FileVersion", "5, 67, 3, 0\0"
50+
VALUE "FileVersion", "5, 67, 4, 0\0"
5151
VALUE "InternalName", "Yet Another AYA5\0"
5252
VALUE "LegalCopyright", " \0"
5353
VALUE "LegalTrademarks", " \0"

basis.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ CBasis::CBasis(CAyaVM &vmr) : vm(vmr)
7676
msglang_for_compat = MSGLANG_JAPANESE;
7777

7878
dic_charset = CHARSET_SJIS;
79+
setting_charset = CHARSET_SJIS;
7980
output_charset = CHARSET_UTF8;
8081
file_charset = CHARSET_SJIS;
8182
save_charset = CHARSET_UTF8;
@@ -375,7 +376,9 @@ void CBasis::LoadBaseConfigureFile(std::vector<CDic1> &dics)
375376

376377
// ファイルを開く
377378
yaya::string_t filename = load_path + modulename + config_file_name_trailer + L".txt";
378-
LoadBaseConfigureFile_Base(filename,dics,dic_charset);
379+
380+
// 読み込み当初は文字コードが定義されていないので、CHARSET_UNDEFにする
381+
LoadBaseConfigureFile_Base(filename,dics,CHARSET_UNDEF);
379382

380383
if ( yayamsg::IsEmpty() ) { //エラーメッセージテーブルが読めていない
381384
SetParameter(L"messagetxt",msglang_for_compat == MSGLANG_JAPANESE ? L"messagetxt/japanese.txt" : L"messagetxt/english.txt");
@@ -398,11 +401,21 @@ void CBasis::LoadBaseConfigureFile_Base(yaya::string_t filename,std::vector<CDic
398401
yaya::string_t cmd, param;
399402
size_t line=0;
400403

404+
char cset_real;
405+
401406
while ( true ) {
402407
line += 1;
403408

404409
// 1行読み込み
405-
if (yaya::ws_fgets(readline, fp, cset, 0, line) == yaya::WS_EOF) {
410+
cset_real = cset;
411+
412+
if ( cset == CHARSET_UNDEF ) {
413+
//後の設定で変更されている可能性があるので、毎回上書きすること
414+
//always overwrite cset_real because setting_charset may be modified in SetParameter function
415+
cset_real = setting_charset;
416+
}
417+
418+
if (yaya::ws_fgets(readline, fp, cset_real, 0, line) == yaya::WS_EOF) {
406419
// ファイルを閉じる
407420
fclose(fp);
408421

@@ -446,7 +459,7 @@ bool CBasis::SetParameter(const yaya::string_t &cmd, const yaya::string_t &param
446459

447460
yaya::string_t filename = load_path + param1;
448461

449-
char cset = dic_charset;
462+
char cset = setting_charset;
450463
if ( param2.size() ) {
451464
char cx = Ccct::CharsetTextToID(param2.c_str());
452465
if ( cx != CHARSET_DEFAULT ) {
@@ -463,7 +476,7 @@ bool CBasis::SetParameter(const yaya::string_t &cmd, const yaya::string_t &param
463476

464477
yaya::string_t filename = load_path + param1;
465478

466-
char cset = dic_charset;
479+
char cset = setting_charset;
467480
if ( param2.size() ) {
468481
char cx = Ccct::CharsetTextToID(param2.c_str());
469482
if ( cx != CHARSET_DEFAULT ) {
@@ -609,6 +622,7 @@ bool CBasis::SetParameter(const yaya::string_t &cmd, const yaya::string_t &param
609622
// charset
610623
else if ( cmd == L"charset" ) {
611624
dic_charset = Ccct::CharsetTextToID(param.c_str());
625+
setting_charset = dic_charset;
612626
output_charset = dic_charset;
613627
file_charset = dic_charset;
614628
save_charset = dic_charset;
@@ -621,6 +635,10 @@ bool CBasis::SetParameter(const yaya::string_t &cmd, const yaya::string_t &param
621635
dic_charset = Ccct::CharsetTextToID(param.c_str());
622636
return true;
623637
}
638+
else if ( cmd == L"charset.setting" ) {
639+
setting_charset = Ccct::CharsetTextToID(param.c_str());
640+
return true;
641+
}
624642
else if ( cmd == L"charset.output" ) {
625643
output_charset = Ccct::CharsetTextToID(param.c_str());
626644
return true;
@@ -744,6 +762,9 @@ CValue CBasis::GetParameter(const yaya::string_t &cmd)
744762
else if ( cmd == L"charset.dic" ) {
745763
return Ccct::CharsetIDToTextW(dic_charset);
746764
}
765+
else if ( cmd == L"charset.setting" ) {
766+
return Ccct::CharsetIDToTextW(setting_charset);
767+
}
747768
else if ( cmd == L"charset.output" ) {
748769
return Ccct::CharsetIDToTextW(output_charset);
749770
}

basis.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ class CBasis
6262
char msglang_for_compat;
6363

6464
char dic_charset; // 文字コードセット(Shift_JIS/UTF-8/OSデフォルト)
65+
char setting_charset;
6566
char output_charset;
6667
char file_charset;
6768
char save_charset;
6869
char save_old_charset;
6970
char extension_charset;
71+
7072
bool encode_savefile;
7173
bool auto_save;
7274

manifest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "manifest.h"
99

1010
const yaya::char_t *aya_name = L"YAYA";
11-
const yaya::char_t *aya_version = L"Tc567-3";
11+
const yaya::char_t *aya_version = L"Tc567-4";
1212
const yaya::char_t *aya_author = L"umeici/The Maintenance Shop";
1313

1414

manifest.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ extern const yaya::char_t *aya_author;
2929
#define CHARSET_GB2312 4
3030
#define CHARSET_EUCKR 5
3131
#define CHARSET_JIS 6
32-
#define CHARSET_BINARY 126 /* 変換しない(一部でのみ利用) */
33-
#define CHARSET_DEFAULT 127 /* OSデフォルトの言語を使用する */
32+
#define CHARSET_UNDEF 125 /* 未定義 */
33+
#define CHARSET_BINARY 126 /* 変換しない(一部でのみ利用) */
34+
#define CHARSET_DEFAULT 127 /* OSデフォルトの言語を使用する */
3435

3536
// 基底プレフィックス文字列
3637
#define PREFIX_BASE_LEN 2

0 commit comments

Comments
 (0)