From 535bd8fa0ea49f3a071c98f25fe743459baa37c7 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 21 Jan 2023 21:28:23 +0100 Subject: [PATCH] Use wide char version's function directely (part3) ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/12613#discussion_r1045153278 --- PowerEditor/src/MISC/Common/Common.cpp | 2 +- PowerEditor/src/MISC/Common/Common.h | 5 --- .../MISC/PluginsManager/PluginsManager.cpp | 10 +++--- PowerEditor/src/Notepad_plus.cpp | 6 ++-- PowerEditor/src/NppBigSwitch.cpp | 4 +-- PowerEditor/src/Parameters.cpp | 16 ++++----- PowerEditor/src/ScintillaComponent/Buffer.cpp | 8 ++--- .../ScintillaComponent/ScintillaEditView.cpp | 8 ++--- .../ScintillaComponent/UserDefineDialog.cpp | 20 +++++------ PowerEditor/src/TinyXml/tinyXmlA/tinyxmlA.cpp | 4 +-- PowerEditor/src/TinyXml/tinyxml.cpp | 35 +++---------------- .../src/WinControls/AboutDlg/AboutDlg.cpp | 12 +++---- .../AnsiCharPanel/asciiListView.cpp | 12 +++---- .../FunctionList/functionListPanel.cpp | 8 ++--- PowerEditor/src/WinControls/Grid/BabyGrid.cpp | 4 +-- 15 files changed, 61 insertions(+), 93 deletions(-) diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 43a7700dd..06c8167d3 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -58,7 +58,7 @@ std::string getFileContent(const TCHAR *file2read) const size_t blockSize = 1024; char data[blockSize]; std::string wholeFileContent = ""; - FILE *fp = generic_fopen(file2read, TEXT("rb")); + FILE *fp = _wfopen(file2read, TEXT("rb")); size_t lenFile = 0; do diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index 6e13c2bfe..0a60bc062 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -43,11 +43,6 @@ const bool dirDown = false; #define WCSTOK wcstok_s #endif -#define generic_atoi _wtoi -#define generic_itoa _itow -#define generic_fprintf fwprintf -#define generic_sprintf swprintf -#define generic_fopen _wfopen #define NPP_INTERNAL_FUCTION_STR L"Notepad++::InternalFunction" diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 5eb05b3b8..7b64ae704 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -666,7 +666,7 @@ void PluginsManager::runPluginCommand(size_t i) { constexpr size_t bufSize = 128; TCHAR funcInfo[bufSize] = { '\0' }; - generic_sprintf(funcInfo, bufSize, TEXT("runPluginCommand(size_t i : %zd)"), i); + swprintf(funcInfo, bufSize, TEXT("runPluginCommand(size_t i : %zd)"), i); pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo); } } @@ -694,7 +694,7 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID) { constexpr size_t bufSize = 128; TCHAR funcInfo[bufSize] = { '\0' }; - generic_sprintf(funcInfo, bufSize, TEXT("runPluginCommand(const TCHAR *pluginName : %s, int commandID : %d)"), pluginName, commandID); + swprintf(funcInfo, bufSize, TEXT("runPluginCommand(const TCHAR *pluginName : %s, int commandID : %d)"), pluginName, commandID); pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo); } } @@ -725,7 +725,7 @@ void PluginsManager::notify(size_t indexPluginInfo, const SCNotification *notifi { constexpr size_t bufSize = 256; TCHAR funcInfo[bufSize] = { '\0' }; - generic_sprintf(funcInfo, bufSize, TEXT("notify(SCNotification *notification) : \r notification->nmhdr.code == %d\r notification->nmhdr.hwndFrom == %p\r notification->nmhdr.idFrom == %" PRIuPTR), \ + swprintf(funcInfo, bufSize, TEXT("notify(SCNotification *notification) : \r notification->nmhdr.code == %d\r notification->nmhdr.hwndFrom == %p\r notification->nmhdr.idFrom == %" PRIuPTR), \ scNotif.nmhdr.code, scNotif.nmhdr.hwndFrom, scNotif.nmhdr.idFrom); pluginCrashAlert(_pluginInfos[indexPluginInfo]->_moduleName.c_str(), funcInfo); } @@ -764,7 +764,7 @@ void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam { constexpr size_t bufSize = 128; TCHAR funcInfo[bufSize] = { '\0' }; - generic_sprintf(funcInfo, bufSize, TEXT("relayNppMessages(UINT Message : %u, WPARAM wParam : %" PRIuPTR ", LPARAM lParam : %" PRIiPTR ")"), Message, wParam, lParam); + swprintf(funcInfo, bufSize, TEXT("relayNppMessages(UINT Message : %u, WPARAM wParam : %" PRIuPTR ", LPARAM lParam : %" PRIiPTR ")"), Message, wParam, lParam); pluginCrashAlert(_pluginInfos[i]->_moduleName.c_str(), funcInfo); } } @@ -796,7 +796,7 @@ bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lPa { constexpr size_t bufSize = 128; TCHAR funcInfo[bufSize] = { '\0' }; - generic_sprintf(funcInfo, bufSize, TEXT("relayPluginMessages(UINT Message : %u, WPARAM wParam : %" PRIuPTR ", LPARAM lParam : %" PRIiPTR ")"), Message, wParam, lParam); + swprintf(funcInfo, bufSize, TEXT("relayPluginMessages(UINT Message : %u, WPARAM wParam : %" PRIuPTR ", LPARAM lParam : %" PRIiPTR ")"), Message, wParam, lParam); pluginCrashAlert(_pluginInfos[i]->_moduleName.c_str(), funcInfo); } return true; diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index a35a3f5e4..7b0d2304a 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -1089,7 +1089,7 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const return -1; // Get the beginning of file data - FILE *f = generic_fopen(fileName, TEXT("rb")); + FILE *f = _wfopen(fileName, TEXT("rb")); if (!f) return -1; const int blockSize = 1024; // To ensure that length is long enough to capture the encoding in html @@ -4497,7 +4497,7 @@ void Notepad_plus::docOpenInNewInstance(FileTransferMode mode, int x, int y) if (x) { TCHAR pX[10]; - generic_itoa(x, pX, 10); + _itow(x, pX, 10); command += TEXT(" -x"); command += pX; } @@ -4505,7 +4505,7 @@ void Notepad_plus::docOpenInNewInstance(FileTransferMode mode, int x, int y) if (y) { TCHAR pY[10]; - generic_itoa(y, pY, 10); + _itow(y, pY, 10); command += TEXT(" -y"); command += pY; } diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index d71e671d2..ec80b6853 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1391,10 +1391,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa int mainVer = 0, auxVer = 0; if (mainVerStr[0]) - mainVer = generic_atoi(mainVerStr); + mainVer = _wtoi(mainVerStr); if (auxVerStr[0]) - auxVer = generic_atoi(auxVerStr); + auxVer = _wtoi(auxVerStr); return MAKELONG(auxVer, mainVer); } diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 368f41413..dde6fcaf1 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2345,7 +2345,7 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session& s const TCHAR* intStrTabColour = (childNode->ToElement())->Attribute(TEXT("tabColourId")); if (intStrTabColour) { - sfi._individualTabColour = generic_atoi(intStrTabColour); + sfi._individualTabColour = _wtoi(intStrTabColour); } for (TiXmlNode *markNode = childNode->FirstChildElement(TEXT("Mark")); @@ -4852,7 +4852,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) const TCHAR* val = n->Value(); if (val) { - int const i = generic_atoi (val); + int const i = _wtoi (val); if ((i >= urlMin) && (i <= urlMax)) _nppGUI._styleURL = urlMode(i); } @@ -6847,7 +6847,7 @@ void NppParameters::createXmlTreeFromGUIParams() // 2 { TCHAR szStr [12] = TEXT("0"); - generic_itoa(_nppGUI._styleURL, szStr, 10); + _itow(_nppGUI._styleURL, szStr, 10); TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("URL")); GUIConfigElement->InsertEndChild(TiXmlText(szStr)); @@ -7860,9 +7860,9 @@ void NppParameters::insertUserLang2Tree(TiXmlNode *node, UserLangContainer *user TCHAR temp[32]; generic_string udlVersion; - udlVersion += generic_itoa(SCE_UDL_VERSION_MAJOR, temp, 10); + udlVersion += _itow(SCE_UDL_VERSION_MAJOR, temp, 10); udlVersion += TEXT("."); - udlVersion += generic_itoa(SCE_UDL_VERSION_MINOR, temp, 10); + udlVersion += _itow(SCE_UDL_VERSION_MINOR, temp, 10); rootElement->SetAttribute(TEXT("name"), userLang->_name); rootElement->SetAttribute(TEXT("ext"), userLang->_ext); @@ -8113,9 +8113,9 @@ Date::Date(const TCHAR *dateStr) generic_string mm(ds, 4, 2); generic_string dd(ds, 6, 2); - int y = generic_atoi(yyyy.c_str()); - int m = generic_atoi(mm.c_str()); - int d = generic_atoi(dd.c_str()); + int y = _wtoi(yyyy.c_str()); + int m = _wtoi(mm.c_str()); + int d = _wtoi(dd.c_str()); if ((y > 0 && y <= 9999) && (m > 0 && m <= 12) && (d > 0 && d <= 31)) { diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 82994ea84..6aee7bdec 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -682,7 +682,7 @@ BufferID FileManager::loadFile(const TCHAR* filename, Document doc, int encoding if (pPath) { - FILE* fp = generic_fopen(pPath, TEXT("rb")); + FILE* fp = _wfopen(pPath, TEXT("rb")); if (fp) { _fseeki64(fp, 0, SEEK_END); @@ -813,7 +813,7 @@ bool FileManager::reloadBuffer(BufferID id) //Get file size - FILE* fp = generic_fopen(buf->getFullPathName(), TEXT("rb")); + FILE* fp = _wfopen(buf->getFullPathName(), TEXT("rb")); if (!fp) return false; _fseeki64(fp, 0, SEEK_END); @@ -1271,7 +1271,7 @@ size_t FileManager::nextUntitledNewNumber() const { generic_string newTitle = ((NppParameters::getInstance()).getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR); TCHAR *numberStr = buf->_fileName + newTitle.length(); - int usedNumber = generic_atoi(numberStr); + int usedNumber = _wtoi(numberStr); usedNumbers.push_back(usedNumber); } } @@ -1456,7 +1456,7 @@ LangType FileManager::detectLanguageFromTextBegining(const unsigned char *data, bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * filename, char* data, Utf8_16_Read * unicodeConvertor, LoadedFileFormat& fileFormat) { - FILE *fp = generic_fopen(filename, TEXT("rb")); + FILE *fp = _wfopen(filename, TEXT("rb")); if (!fp) return false; diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index 3113ef626..a32a492eb 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -3201,8 +3201,8 @@ TCHAR * int2str(TCHAR *str, int strLen, int number, int base, int nbChiffre, boo { // use sprintf or swprintf instead of wsprintf // to make octal format work - generic_sprintf(f, bufSize, TEXT("%%%s"), fStr); - generic_sprintf(str, strLen, f, number); + swprintf(f, bufSize, TEXT("%%%s"), fStr); + swprintf(str, strLen, f, number); } int i = lstrlen(str); for ( ; i < nbChiffre ; ++i) @@ -3215,8 +3215,8 @@ TCHAR * int2str(TCHAR *str, int strLen, int number, int base, int nbChiffre, boo { // use sprintf or swprintf instead of wsprintf // to make octal format work - generic_sprintf(f, bufSize, TEXT("%%.%d%s"), nbChiffre, fStr); - generic_sprintf(str, strLen, f, number); + swprintf(f, bufSize, TEXT("%%.%d%s"), nbChiffre, fStr); + swprintf(str, strLen, f, number); } // else already done. } diff --git a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp index d141956f4..06994f46d 100644 --- a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp @@ -538,7 +538,7 @@ void CommentStyleDialog::setKeywords2List(int id) TCHAR intBuffer[10] = { '0', 0 }; for (int i = 0; static_cast(i) < sizeof(list) / sizeof(int); ++i) { - generic_itoa(i, intBuffer + 1, 10); + _itow(i, intBuffer + 1, 10); ::GetDlgItemText(_hSelf, list[i], buffer, max_char); convertTo(newList, max_char, buffer, intBuffer); } @@ -601,7 +601,7 @@ void CommentStyleDialog::updateDlg() TCHAR intBuffer[10] = { '0', 0 }; for (int i = 0; static_cast(i) < sizeof(list) / sizeof(int); ++i) { - generic_itoa(i, intBuffer + 1, 10); + _itow(i, intBuffer + 1, 10); retrieve(buffer, _pUserLang->_keywordLists[SCE_USER_KWLIST_COMMENTS], intBuffer); ::SendDlgItemMessage(_hSelf, list[i], WM_SETTEXT, 0, reinterpret_cast(buffer)); } @@ -662,9 +662,9 @@ void SymbolsStyleDialog::updateDlg() for (int i = 0; static_cast(i) < sizeof(list)/sizeof(int); ++i) { if (i < 10) - generic_itoa(i, intBuffer + 1, 10); + _itow(i, intBuffer + 1, 10); else - generic_itoa(i, intBuffer, 10); + _itow(i, intBuffer, 10); retrieve(buffer, _pUserLang->_keywordLists[SCE_USER_KWLIST_DELIMITERS], intBuffer); ::SendDlgItemMessage(_hSelf, list[i], WM_SETTEXT, 0, reinterpret_cast(buffer)); @@ -856,9 +856,9 @@ void SymbolsStyleDialog::setKeywords2List(int id) for (int i = 0; static_cast(i) < sizeof(list)/sizeof(int); ++i) { if (i < 10) - generic_itoa(i, intBuffer+1, 10); + _itow(i, intBuffer+1, 10); else - generic_itoa(i, intBuffer, 10); + _itow(i, intBuffer, 10); int dd = list[i]; ::GetDlgItemText(_hSelf, dd, buffer, max_char); @@ -1060,13 +1060,13 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA TCHAR temp[32]; generic_string udlVersion = TEXT("User Defined Language v."); - udlVersion += generic_itoa(SCE_UDL_VERSION_MAJOR, temp, 10); + udlVersion += _itow(SCE_UDL_VERSION_MAJOR, temp, 10); udlVersion += TEXT("."); - udlVersion += generic_itoa(SCE_UDL_VERSION_MINOR, temp, 10); + udlVersion += _itow(SCE_UDL_VERSION_MINOR, temp, 10); udlVersion += TEXT("."); - udlVersion += generic_itoa(SCE_UDL_VERSION_BUILD, temp, 10); + udlVersion += _itow(SCE_UDL_VERSION_BUILD, temp, 10); udlVersion += TEXT("."); - udlVersion += generic_itoa(SCE_UDL_VERSION_REVISION, temp, 10); + udlVersion += _itow(SCE_UDL_VERSION_REVISION, temp, 10); ::SetWindowText(_hSelf, udlVersion.c_str()); diff --git a/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlA.cpp b/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlA.cpp index a5637dd4e..865f6a2a9 100644 --- a/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlA.cpp +++ b/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlA.cpp @@ -771,7 +771,7 @@ bool TiXmlDocumentA::LoadUnicodeFilePath( const TCHAR* filename ) // See STL_STRING_BUG above. // Fixed with the StringToBuffer class. - FILE* file = generic_fopen(filename, TEXT("r")); + FILE* file = _wfopen(filename, TEXT("r")); if ( file ) { @@ -829,7 +829,7 @@ bool TiXmlDocumentA::SaveFile( const char * filename ) const bool TiXmlDocumentA::SaveUnicodeFilePath( const TCHAR* filename ) const { // The old c stuff lives on... - FILE* fp = generic_fopen( filename, TEXT("wc") ); + FILE* fp = _wfopen( filename, TEXT("wc") ); if ( fp ) { Print( fp, 0 ); diff --git a/PowerEditor/src/TinyXml/tinyxml.cpp b/PowerEditor/src/TinyXml/tinyxml.cpp index f778419b8..0fb856566 100644 --- a/PowerEditor/src/TinyXml/tinyxml.cpp +++ b/PowerEditor/src/TinyXml/tinyxml.cpp @@ -481,7 +481,7 @@ const TCHAR * TiXmlElement::Attribute( const TCHAR * name, int* i ) const if ( i ) { if ( s ) - *i = generic_atoi( s ); + *i = _wtoi( s ); else *i = 0; } @@ -558,20 +558,16 @@ void TiXmlElement::Print( std::string& outputStream, int depth ) const for ( i=0; iNext() ) { outputStream += " "; - //generic_fprintf(cfile, TEXT(" ")); - attrib->Print(outputStream, depth ); } @@ -583,45 +579,36 @@ void TiXmlElement::Print( std::string& outputStream, int depth ) const if ( !firstChild ) { outputStream += " />"; - //generic_fprintf( cfile, TEXT(" />") ); } else if ( firstChild == lastChild && firstChild->ToText() ) { outputStream += ">"; - //generic_fprintf( cfile, TEXT(">") ); - firstChild->Print(outputStream, depth + 1 ); std::string tagCloseWithValue = ""; outputStream += tagCloseWithValue; - //generic_fprintf( cfile, TEXT(""), value.c_str() ); } else { outputStream += ">"; - //generic_fprintf( cfile, TEXT(">") ); for ( node = firstChild; node; node=node->NextSibling() ) { if ( !node->ToText() ) { outputStream += "\r\n"; - //generic_fprintf( cfile, TEXT("\n") ); } node->Print(outputStream, depth+1 ); } outputStream += "\r\n"; - //generic_fprintf( cfile, TEXT("\n") ); for( i=0; i"; outputStream += tagCloseWithValue; - //generic_fprintf( cfile, TEXT(""), value.c_str() ); } } @@ -733,7 +720,7 @@ bool TiXmlDocument::LoadFile( const TCHAR* filename ) // Fixed with the StringToBuffer class. value = filename; - FILE* file = generic_fopen( value.c_str (), TEXT("r") ); + FILE* file = _wfopen( value.c_str (), TEXT("r") ); if ( file ) { @@ -779,7 +766,7 @@ bool TiXmlDocument::SaveFile( const TCHAR * filename ) const { /* // The old c stuff lives on... - FILE* fp = generic_fopen( filename, TEXT("wc") ); + FILE* fp = _wfopen( filename, TEXT("wc") ); if ( fp ) { Print( fp, 0 ); @@ -832,7 +819,6 @@ void TiXmlDocument::Print( std::string& outputStream, int depth ) const node->Print(outputStream, depth ); outputStream += "\r\n"; - //generic_fprintf( cfile, TEXT("\n") ); } } @@ -885,14 +871,12 @@ void TiXmlAttribute::Print( std::string& outputStream, int /*depth*/ ) const attrVsValue += "=\""; attrVsValue += wstring2string(v, CP_UTF8); attrVsValue += "\""; - //generic_fprintf(cfile, TEXT("%ls=\"%ls\""), n.c_str(), v.c_str()); } else { attrVsValue += "='"; attrVsValue += wstring2string(v, CP_UTF8); attrVsValue += "'"; - //generic_fprintf(cfile, TEXT("%ls='%ls'"), n.c_str(), v.c_str()); } outputStream += attrVsValue; } @@ -946,7 +930,7 @@ void TiXmlAttribute::SetDoubleValue( double _value ) const int TiXmlAttribute::IntValue() const { - return generic_atoi (value.c_str ()); + return _wtoi (value.c_str ()); } const double TiXmlAttribute::DoubleValue() const @@ -959,14 +943,12 @@ void TiXmlComment::Print( std::string& outputStream, int depth ) const for ( int i=0; i"), value.c_str() ); } void TiXmlComment::StreamOut( TIXML_OSTREAM * stream ) const @@ -994,7 +976,6 @@ void TiXmlText::Print( std::string& outputStream, int /*depth*/ ) const PutString( value, &buffer ); outputStream += wstring2string(buffer, CP_UTF8); - //generic_fprintf( cfile, TEXT("%ls"), buffer.c_str() ); } @@ -1030,14 +1011,12 @@ TiXmlDeclaration::TiXmlDeclaration( const TCHAR * _version, void TiXmlDeclaration::Print( std::string& outputStream, int /*depth*/ ) const { std::string xmlDcl = ""; - //generic_fprintf (cfile, TEXT("?>")); - outputStream += xmlDcl; } @@ -1105,10 +1080,8 @@ void TiXmlUnknown::Print( std::string& outputStream, int depth ) const { for ( int i=0; i(&dwUBR), &dataSize) == ERROR_SUCCESS) { - generic_sprintf(szUBR, bufSizeUBR, TEXT("%u"), dwUBR); + swprintf(szUBR, bufSizeUBR, TEXT("%u"), dwUBR); } RegCloseKey(hKey); @@ -250,19 +250,19 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM // Get alternative OS information if (szProductName[0] == '\0') { - generic_sprintf(szProductName, bufSize, TEXT("%s"), (NppParameters::getInstance()).getWinVersionStr().c_str()); + swprintf(szProductName, bufSize, TEXT("%s"), (NppParameters::getInstance()).getWinVersionStr().c_str()); } // Override ProductName if it's Windows 11 if (NppDarkMode::isWindows11()) - generic_sprintf(szProductName, bufSize, TEXT("%s"), TEXT("Windows 11")); + swprintf(szProductName, bufSize, TEXT("%s"), TEXT("Windows 11")); if (szCurrentBuildNumber[0] == '\0') { DWORD dwVersion = GetVersion(); if (dwVersion < 0x80000000) { - generic_sprintf(szCurrentBuildNumber, bufSizeBuildNumber, TEXT("%u"), HIWORD(dwVersion)); + swprintf(szCurrentBuildNumber, bufSizeBuildNumber, TEXT("%u"), HIWORD(dwVersion)); } } @@ -292,7 +292,7 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM { constexpr size_t bufSizeACP = 32; TCHAR szACP[bufSizeACP] = { '\0' }; - generic_sprintf(szACP, bufSizeACP, TEXT("%u"), ::GetACP()); + swprintf(szACP, bufSizeACP, TEXT("%u"), ::GetACP()); _debugInfoStr += TEXT("Current ANSI codepage : "); _debugInfoStr += szACP; _debugInfoStr += TEXT("\r\n"); @@ -310,7 +310,7 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM { constexpr size_t bufSizeWineVer = 32; TCHAR szWINEVersion[bufSizeWineVer] = { '\0' }; - generic_sprintf(szWINEVersion, bufSizeWineVer, TEXT("%hs"), pWGV()); + swprintf(szWINEVersion, bufSizeWineVer, TEXT("%hs"), pWGV()); _debugInfoStr += TEXT("WINE : "); _debugInfoStr += szWINEVersion; diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/asciiListView.cpp b/PowerEditor/src/WinControls/AnsiCharPanel/asciiListView.cpp index ab3207039..91fc43022 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/asciiListView.cpp +++ b/PowerEditor/src/WinControls/AnsiCharPanel/asciiListView.cpp @@ -394,26 +394,26 @@ void AsciiListView::setValues(int codepage) TCHAR hex[bufSize]; TCHAR htmlNumber[bufSize]; generic_string htmlName; - generic_sprintf(dec, bufSize, TEXT("%d"), i); - generic_sprintf(hex, bufSize, TEXT("%02X"), i); + swprintf(dec, bufSize, TEXT("%d"), i); + swprintf(hex, bufSize, TEXT("%02X"), i); generic_string s = getAscii(static_cast(i)); if (codepage == 0 || codepage == 1252) { if ((i >= 32 && i <= 126) || (i >= 160 && i <= 255)) { - generic_sprintf(htmlNumber, bufSize, TEXT("&#%d"), i); + swprintf(htmlNumber, bufSize, TEXT("&#%d"), i); } else { int n = getHtmlNumber(static_cast(i)); if (n > -1) { - generic_sprintf(htmlNumber, bufSize, TEXT("&#%d"), n); + swprintf(htmlNumber, bufSize, TEXT("&#%d"), n); } else { - generic_sprintf(htmlNumber, bufSize, TEXT("")); + swprintf(htmlNumber, bufSize, TEXT("")); } } @@ -421,7 +421,7 @@ void AsciiListView::setValues(int codepage) } else { - generic_sprintf(htmlNumber, bufSize, TEXT("")); + swprintf(htmlNumber, bufSize, TEXT("")); htmlName = TEXT(""); } diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp index 393d3ea05..19060e9f1 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp @@ -240,8 +240,8 @@ int CALLBACK FunctionListPanel::categorySortFunc(LPARAM lParam1, LPARAM lParam2, generic_string* posString1 = reinterpret_cast(lParam1); generic_string* posString2 = reinterpret_cast(lParam2); - size_t pos1 = generic_atoi(posString1->c_str()); - size_t pos2 = generic_atoi(posString2->c_str()); + size_t pos1 = _wtoi(posString1->c_str()); + size_t pos2 = _wtoi(posString2->c_str()); if (pos1 > pos2) return 1; else @@ -486,7 +486,7 @@ void FunctionListPanel::findMarkEntry(HTREEITEM htItem, LONG line) generic_string *posStr = reinterpret_cast(tvItem.lParam); if (posStr) { - int pos = generic_atoi(posStr->c_str()); + int pos = _wtoi(posStr->c_str()); if (pos != -1) { LONG sci_line = static_cast((*_ppEditView)->execute(SCI_LINEFROMPOSITION, pos)); @@ -570,7 +570,7 @@ bool FunctionListPanel::openSelection(const TreeView & treeView) if (!posStr) return false; - int pos = generic_atoi(posStr->c_str()); + int pos = _wtoi(posStr->c_str()); if (pos == -1) return false; diff --git a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp index 9001131f6..98a0c6ddf 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp +++ b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp @@ -635,7 +635,7 @@ void DisplayColumn(HWND hWnd,int SI,int c,int offset,HFONT hfont,HFONT hcolumnhe { WPARAM wParam; buffer[0]=0x20; - BGHS[SI].ownerdrawitem = generic_atoi(buffer); + BGHS[SI].ownerdrawitem = _wtoi(buffer); wParam=MAKEWPARAM(::GetMenu(hWnd),BGN_OWNERDRAW); SendMessage(GetParent(hWnd), WM_COMMAND, wParam, reinterpret_cast(&rect)); } @@ -1696,7 +1696,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return TRUE; SendMessage(BGHS[SelfIndex].hlist1, LB_GETTEXT, j - 1, reinterpret_cast(buffer)); buffer[5]=0x00; - j=generic_atoi(buffer); + j=_wtoi(buffer); if(j>SendMessage(hWnd,BGM_GETROWS,0,0)) { SendMessage(hWnd,BGM_SETGRIDDIM,j,BGHS[SelfIndex].cols);