[BUG_FIXED] Fix UDL name load bug.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@318 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-09-11 17:38:51 +00:00
parent 0f77948833
commit 11b624062f
3 changed files with 18 additions and 26 deletions

View File

@ -1820,7 +1820,7 @@ int NppParameters::addUserLangToEnd(const UserLangContainer & userLang, const TC
return -1; return -1;
_userLangArray[_nbUserLang] = new UserLangContainer(); _userLangArray[_nbUserLang] = new UserLangContainer();
*(_userLangArray[_nbUserLang]) = userLang; *(_userLangArray[_nbUserLang]) = userLang;
lstrcpy(_userLangArray[_nbUserLang]->_name, newName); _userLangArray[_nbUserLang]->_name = newName;
_nbUserLang++; _nbUserLang++;
return _nbUserLang-1; return _nbUserLang-1;
} }

View File

@ -708,25 +708,15 @@ friend class UserDefineDialog;
public : public :
UserLangContainer(){ UserLangContainer(){
lstrcpy(_name, TEXT("new user define")); _name = TEXT("new user define");
_ext[0] = '\0'; _ext = TEXT("");
// Keywords list of Delimiters (index 0) // Keywords list of Delimiters (index 0)
lstrcpy(_keywordLists[0], TEXT("000000")); lstrcpy(_keywordLists[0], TEXT("000000"));
for (int i = 1 ; i < nbKeywodList ; i++) for (int i = 1 ; i < nbKeywodList ; i++)
*_keywordLists[i] = '\0'; *_keywordLists[i] = '\0';
}; };
UserLangContainer(const TCHAR *name, const TCHAR *ext){ UserLangContainer(const TCHAR *name, const TCHAR *ext) : _name(name), _ext(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);
// Keywords list of Delimiters (index 0) // Keywords list of Delimiters (index 0)
lstrcpy(_keywordLists[0], TEXT("000000")); lstrcpy(_keywordLists[0], TEXT("000000"));
for (int j = 1 ; j < nbKeywodList ; j++) for (int j = 1 ; j < nbKeywodList ; j++)
@ -736,8 +726,8 @@ public :
UserLangContainer & operator=(const UserLangContainer & ulc) { UserLangContainer & operator=(const UserLangContainer & ulc) {
if (this != &ulc) if (this != &ulc)
{ {
lstrcpy(this->_name, ulc._name); this->_name = ulc._name;
lstrcpy(this->_ext, ulc._ext); this->_ext = ulc._ext;
this->_isCaseIgnored = ulc._isCaseIgnored; this->_isCaseIgnored = ulc._isCaseIgnored;
this->_styleArray = ulc._styleArray; this->_styleArray = ulc._styleArray;
int nbStyler = this->_styleArray.getNbStyler(); int nbStyler = this->_styleArray.getNbStyler();
@ -756,11 +746,13 @@ public :
}; };
int getNbKeywordList() {return nbKeywodList;}; int getNbKeywordList() {return nbKeywodList;};
TCHAR * getName() {return _name;}; const TCHAR * getName() {return _name.c_str();};
private: private:
TCHAR _name[langNameLenMax]; //TCHAR _name[langNameLenMax];
TCHAR _ext[extsLenMax]; //TCHAR _ext[extsLenMax];
generic_string _name;
generic_string _ext;
StyleArray _styleArray; StyleArray _styleArray;
TCHAR _keywordLists[nbKeywodList][max_char]; TCHAR _keywordLists[nbKeywodList][max_char];
@ -913,7 +905,7 @@ public:
UserLangContainer & getULCFromIndex(int i) {return *_userLangArray[i];}; UserLangContainer & getULCFromIndex(int i) {return *_userLangArray[i];};
UserLangContainer * getULCFromName(const TCHAR *userLangName) { UserLangContainer * getULCFromName(const TCHAR *userLangName) {
for (int i = 0 ; i < _nbUserLang ; i++) for (int i = 0 ; i < _nbUserLang ; i++)
if (!lstrcmp(userLangName, _userLangArray[i]->_name)) if (!lstrcmp(userLangName, _userLangArray[i]->_name.c_str()))
return _userLangArray[i]; return _userLangArray[i];
//qui doit etre jamais passer //qui doit etre jamais passer
return NULL; return NULL;
@ -946,7 +938,7 @@ public:
for (int i = 0 ; i < _nbUserLang ; i++) for (int i = 0 ; i < _nbUserLang ; i++)
{ {
if (!lstrcmp(_userLangArray[i]->_name, newName)) if (!lstrcmp(_userLangArray[i]->_name.c_str(), newName))
return true; return true;
} }
return false; return false;
@ -959,10 +951,10 @@ public:
for (int i = 0 ; i < _nbUserLang ; i++) for (int i = 0 ; i < _nbUserLang ; i++)
{ {
vector<generic_string> extVect; vector<generic_string> extVect;
cutString(_userLangArray[i]->_ext, extVect); cutString(_userLangArray[i]->_ext.c_str(), extVect);
for (size_t j = 0 ; j < extVect.size() ; j++) for (size_t j = 0 ; j < extVect.size() ; j++)
if (!generic_stricmp(extVect[j].c_str(), ext)) if (!generic_stricmp(extVect[j].c_str(), ext))
return _userLangArray[i]->_name; return _userLangArray[i]->_name.c_str();
} }
return NULL; return NULL;
}; };

View File

@ -1179,7 +1179,7 @@ void UserDefineDialog::enableLangAndControlsBy(int index)
{ {
_pUserLang = (index == 0)?_pCurrentUserLang:&((NppParameters::getInstance())->getULCFromIndex(index - 1)); _pUserLang = (index == 0)?_pCurrentUserLang:&((NppParameters::getInstance())->getULCFromIndex(index - 1));
if (index != 0) 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_STATIC), (index == 0)?SW_HIDE:SW_SHOW);
::ShowWindow(::GetDlgItem(_hSelf, IDC_EXT_EDIT), (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) 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; return TRUE;
} }
else if (HIWORD(wParam) == CBN_SELCHANGE) 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 //rename current language name in userLangArray
UserLangContainer & userLangContainer = pNppParam->getULCFromIndex(i-1); UserLangContainer & userLangContainer = pNppParam->getULCFromIndex(i-1);
lstrcpy(userLangContainer._name, newName); userLangContainer._name = newName;
//rename current language name in langMenu //rename current language name in langMenu
HWND hNpp = ::GetParent(_hSelf); HWND hNpp = ::GetParent(_hSelf);