From 99990d1f2211e2451e0e8d43809fe5ee686045c7 Mon Sep 17 00:00:00 2001 From: Ianos Gnatiuc Date: Tue, 27 Dec 2005 13:40:47 +0000 Subject: [PATCH] Added new config file token XlatCharSetAlias that defines charset aliases for import tables --- cfgs/config/advanced.cfg | 4 ++++ cfgs/config/advanced.rus | 6 ++++++ docs/notework.txt | 3 +++ golded3/gccfgg.h | 1 + golded3/gccfgg0.cpp | 1 + golded3/gccfgg8.cpp | 21 +++++++++++++++++++++ golded3/gcprot.h | 1 + golded3/gecfgg.h | 1 + golded3/gedoss.cpp | 1 + golded3/geline.cpp | 22 ++++++++++++++++++++-- 10 files changed, 59 insertions(+), 2 deletions(-) diff --git a/cfgs/config/advanced.cfg b/cfgs/config/advanced.cfg index 8cbe6e9..eff3539 100644 --- a/cfgs/config/advanced.cfg +++ b/cfgs/config/advanced.cfg @@ -1411,6 +1411,10 @@ XLATCHARSET CP1251 +7_FIDO win_866.chs ;XLATCHARSET CP850 ASCII 850_ASC.CHS ;XLATCHARSET CP850 MNEMONIC 850_MNE.CHS +// This defines charset aliases for import tables. +;XLATCHARSETALIAS "charset" "alias1" "alias2"... +;XLATCHARSETALIAS ISO-11 ISO-8859-11 ISO8859-11 + // The character set that incoming messages are assumed to have. XLATIMPORT IBMPC ; Default ;XLATIMPORT LATIN-1 diff --git a/cfgs/config/advanced.rus b/cfgs/config/advanced.rus index c8dc724..7b3e8e4 100644 --- a/cfgs/config/advanced.rus +++ b/cfgs/config/advanced.rus @@ -1654,6 +1654,12 @@ XlatCharSet CP866 COMPOSED 866_CMP.chs XlatCharSet CP866 VT100 866_VT1.chs XlatCharSet CP850 ASCII 850_ASC.chs +// Этим можно определить алиасы для названий кодировок. +// Работает только для таблиц импорта. +;XLATCHARSETALIAS "charset" "alias1" "alias2"... +;XLATCHARSETALIAS KOI8-R KOI8R +;XLATCHARSETALIAS ISO ISO-8859-5 ISO8859-5 + // Определение входящей кодировки по умолчанию. Если приходящее // сообщение не имеет клуджа ^CHRS, то будет считаться, что оно // соответствует этому набору символов. diff --git a/docs/notework.txt b/docs/notework.txt index 6e36f26..a94c70e 100644 --- a/docs/notework.txt +++ b/docs/notework.txt @@ -10,6 +10,9 @@ ______________________________________________________________________ Notes for GoldED+ 1.1.5, /snapshot/ ______________________________________________________________________ ++ Added new config file token: XlatCharSetAlias "charset" "alias1" "alias2"... + that defines charset aliases for import tables. + - Fixed destination address selection for commented replays in echo areas. + Now golded+ can draw box lines. Use keyboard configuration keyword diff --git a/golded3/gccfgg.h b/golded3/gccfgg.h index 2ef3f60..d052c94 100644 --- a/golded3/gccfgg.h +++ b/golded3/gccfgg.h @@ -404,6 +404,7 @@ const word CRC_WILDCATUSERNO = 0xC2FE; const word CRC_WRITEHEADER = 0x2589; const word CRC_WRITETEMPLATE = 0xF4CB; const word CRC_XLATCHARSET = 0xA860; +const word CRC_XLATCHARSETALIAS = 0x8B19; const word CRC_XLATESCSET = 0x4BA7; const word CRC_XLATEXPORT = 0x29CB; const word CRC_XLATIMPORT = 0xCE6A; diff --git a/golded3/gccfgg0.cpp b/golded3/gccfgg0.cpp index 909a055..14534ee 100644 --- a/golded3/gccfgg0.cpp +++ b/golded3/gccfgg0.cpp @@ -619,6 +619,7 @@ SwitchW: SwitchX: switch(crc) { case CRC_XLATCHARSET : CfgXlatcharset (); break; + case CRC_XLATCHARSETALIAS : CfgXlatcharsetalias (); break; case CRC_XLATESCSET : CfgXlatescset (); break; case CRC_XLATEXPORT : CfgXlatexport (); break; case CRC_XLATIMPORT : CfgXlatimport (); break; diff --git a/golded3/gccfgg8.cpp b/golded3/gccfgg8.cpp index 7fc7623..4496922 100644 --- a/golded3/gccfgg8.cpp +++ b/golded3/gccfgg8.cpp @@ -586,6 +586,27 @@ void CfgXlatcharset() { // ------------------------------------------------------------------ +void CfgXlatcharsetalias() +{ + char* key; + getkeyval(&key, &val); + if (key[0] == 0) return; + + std::pair aliases; + aliases.first = key; + + do + { + aliases.second.push_back(std::string(key)); + getkeyval(&key, &val); + } + while (key[0] != 0); + + CFG->xlatcharsetalias.push_back(aliases); +} + +// ------------------------------------------------------------------ + void CfgXlatescset() { Map xlt; diff --git a/golded3/gcprot.h b/golded3/gcprot.h index a81da83..60560d9 100644 --- a/golded3/gcprot.h +++ b/golded3/gcprot.h @@ -385,6 +385,7 @@ void CfgWildcatuserno (); void CfgWriteheader (); void CfgWritetemplate (); void CfgXlatcharset (); +void CfgXlatcharsetalias (); void CfgXlatescset (); void CfgXlatexport (); void CfgXlatimport (); diff --git a/golded3/gecfgg.h b/golded3/gecfgg.h index 23d82e4..c44afb1 100644 --- a/golded3/gecfgg.h +++ b/golded3/gecfgg.h @@ -383,6 +383,7 @@ public: std::string wtpl; std::vector xlatcharset; std::vector xlatescset; + std::vector< std::pair > xlatcharsetalias; char xlatexport[17]; // exportcharset[17]; char xlatimport[17]; // localcharset[17]; char xlatlocalset[17]; diff --git a/golded3/gedoss.cpp b/golded3/gedoss.cpp index a495110..3b093f1 100644 --- a/golded3/gedoss.cpp +++ b/golded3/gedoss.cpp @@ -126,6 +126,7 @@ void Cleanup(void) { CFG->username.clear(); CFG->xlatcharset.clear(); CFG->xlatescset.clear(); + CFG->xlatcharsetalias.clear(); CFG->cmdkey.clear(); CFG->macro.clear(); CFG->unpacker.clear(); diff --git a/golded3/geline.cpp b/golded3/geline.cpp index 955735e..f783fa5 100644 --- a/golded3/geline.cpp +++ b/golded3/geline.cpp @@ -2890,8 +2890,26 @@ int LoadCharset(const char* imp, const char* exp, int query) { // Find and load charset table std::vector::iterator xlt; - for(n = 0, xlt = CFG->xlatcharset.begin(); xlt != CFG->xlatcharset.end(); xlt++, n++) { - if(striinc(xlt->imp, imp) and striinc(xlt->exp, exp)) { + for(n = 0, xlt = CFG->xlatcharset.begin(); xlt != CFG->xlatcharset.end(); xlt++, n++) + { + if (!striinc(xlt->exp, exp)) continue; + + bool imp_found = make_bool(striinc(xlt->imp, imp)); + + std::vector< std::pair >::iterator als; + for (als = CFG->xlatcharsetalias.begin(); + !imp_found && (als != CFG->xlatcharsetalias.end()); als++) + { + if (strieql(xlt->imp, als->first.c_str())) + { + for (gstrarray::iterator it = als->second.begin(); !imp_found && (it != als->second.end()); it++) + if (striinc(it->c_str(), imp)) + imp_found = true; + } + } + + if (imp_found) + { // Already loaded? if(CharTable and CharTable->level!=0 and n==current_table) return CharTable->level;