From 11b624062f5c1b063b562ec1f6be5b78bda49f6a Mon Sep 17 00:00:00 2001 From: donho Date: Thu, 11 Sep 2008 17:38:51 +0000 Subject: [PATCH] [BUG_FIXED] Fix UDL name load bug. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@318 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Parameters.cpp | 2 +- PowerEditor/src/Parameters.h | 36 ++++++++----------- .../ScitillaComponent/UserDefineDialog.cpp | 6 ++-- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index e9a90a602..400959e66 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -1820,7 +1820,7 @@ int NppParameters::addUserLangToEnd(const UserLangContainer & userLang, const TC return -1; _userLangArray[_nbUserLang] = new UserLangContainer(); *(_userLangArray[_nbUserLang]) = userLang; - lstrcpy(_userLangArray[_nbUserLang]->_name, newName); + _userLangArray[_nbUserLang]->_name = newName; _nbUserLang++; return _nbUserLang-1; } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index cb430242e..335f26713 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -708,25 +708,15 @@ friend class UserDefineDialog; public : UserLangContainer(){ - lstrcpy(_name, TEXT("new user define")); - _ext[0] = '\0'; + _name = TEXT("new user define"); + _ext = TEXT(""); // Keywords list of Delimiters (index 0) lstrcpy(_keywordLists[0], TEXT("000000")); for (int i = 1 ; i < nbKeywodList ; i++) *_keywordLists[i] = '\0'; }; - UserLangContainer(const TCHAR *name, const TCHAR *ext){ - //si le nom est trop long, on le tranche! - //int minSize = ((sizeof(_name) - 1) < lstrlen(name))?(sizeof(_name) - 1):lstrlen(name); - int minSize = min(langNameLenMax-1, lstrlen(_name)); - int i = 0; - for ( ; i < minSize ; i++) - _name[i] = name[i]; - _name[i] = '\0'; - - lstrcpy(_ext, ext); - + UserLangContainer(const TCHAR *name, const TCHAR *ext) : _name(name), _ext(ext) { // Keywords list of Delimiters (index 0) lstrcpy(_keywordLists[0], TEXT("000000")); for (int j = 1 ; j < nbKeywodList ; j++) @@ -736,8 +726,8 @@ public : UserLangContainer & operator=(const UserLangContainer & ulc) { if (this != &ulc) { - lstrcpy(this->_name, ulc._name); - lstrcpy(this->_ext, ulc._ext); + this->_name = ulc._name; + this->_ext = ulc._ext; this->_isCaseIgnored = ulc._isCaseIgnored; this->_styleArray = ulc._styleArray; int nbStyler = this->_styleArray.getNbStyler(); @@ -756,11 +746,13 @@ public : }; int getNbKeywordList() {return nbKeywodList;}; - TCHAR * getName() {return _name;}; + const TCHAR * getName() {return _name.c_str();}; private: - TCHAR _name[langNameLenMax]; - TCHAR _ext[extsLenMax]; + //TCHAR _name[langNameLenMax]; + //TCHAR _ext[extsLenMax]; + generic_string _name; + generic_string _ext; StyleArray _styleArray; TCHAR _keywordLists[nbKeywodList][max_char]; @@ -913,7 +905,7 @@ public: UserLangContainer & getULCFromIndex(int i) {return *_userLangArray[i];}; UserLangContainer * getULCFromName(const TCHAR *userLangName) { for (int i = 0 ; i < _nbUserLang ; i++) - if (!lstrcmp(userLangName, _userLangArray[i]->_name)) + if (!lstrcmp(userLangName, _userLangArray[i]->_name.c_str())) return _userLangArray[i]; //qui doit etre jamais passer return NULL; @@ -946,7 +938,7 @@ public: for (int i = 0 ; i < _nbUserLang ; i++) { - if (!lstrcmp(_userLangArray[i]->_name, newName)) + if (!lstrcmp(_userLangArray[i]->_name.c_str(), newName)) return true; } return false; @@ -959,10 +951,10 @@ public: for (int i = 0 ; i < _nbUserLang ; i++) { vector extVect; - cutString(_userLangArray[i]->_ext, extVect); + cutString(_userLangArray[i]->_ext.c_str(), extVect); for (size_t j = 0 ; j < extVect.size() ; j++) if (!generic_stricmp(extVect[j].c_str(), ext)) - return _userLangArray[i]->_name; + return _userLangArray[i]->_name.c_str(); } return NULL; }; diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp index 745d87468..7b48877e7 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp @@ -1179,7 +1179,7 @@ void UserDefineDialog::enableLangAndControlsBy(int index) { _pUserLang = (index == 0)?_pCurrentUserLang:&((NppParameters::getInstance())->getULCFromIndex(index - 1)); if (index != 0) - ::SetWindowText(::GetDlgItem(_hSelf, IDC_EXT_EDIT), _pUserLang->_ext); + ::SetWindowText(::GetDlgItem(_hSelf, IDC_EXT_EDIT), _pUserLang->_ext.c_str()); ::ShowWindow(::GetDlgItem(_hSelf, IDC_EXT_STATIC), (index == 0)?SW_HIDE:SW_SHOW); ::ShowWindow(::GetDlgItem(_hSelf, IDC_EXT_EDIT), (index == 0)?SW_HIDE:SW_SHOW); @@ -1322,7 +1322,7 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM { if (HIWORD(wParam) == EN_CHANGE) { - ::SendDlgItemMessage(_hSelf, IDC_EXT_EDIT, WM_GETTEXT, extsLenMax, (LPARAM)(_pUserLang->_ext)); + ::SendDlgItemMessage(_hSelf, IDC_EXT_EDIT, WM_GETTEXT, extsLenMax, (LPARAM)(_pUserLang->_ext.c_str())); return TRUE; } else if (HIWORD(wParam) == CBN_SELCHANGE) @@ -1429,7 +1429,7 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM //rename current language name in userLangArray UserLangContainer & userLangContainer = pNppParam->getULCFromIndex(i-1); - lstrcpy(userLangContainer._name, newName); + userLangContainer._name = newName; //rename current language name in langMenu HWND hNpp = ::GetParent(_hSelf);