diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/common_types.h | 2 | ||||
| -rw-r--r-- | src/common/console_listener.cpp | 10 | ||||
| -rw-r--r-- | src/common/extended_trace.cpp | 2 | ||||
| -rw-r--r-- | src/common/file_search.cpp | 6 | ||||
| -rw-r--r-- | src/common/file_util.cpp | 26 | ||||
| -rw-r--r-- | src/common/file_util.h | 2 | ||||
| -rw-r--r-- | src/common/log_manager.cpp | 2 | ||||
| -rw-r--r-- | src/common/mem_arena.cpp | 2 | ||||
| -rw-r--r-- | src/common/memory_util.cpp | 2 | ||||
| -rw-r--r-- | src/common/msg_handler.cpp | 2 | ||||
| -rw-r--r-- | src/common/string_util.cpp | 20 | ||||
| -rw-r--r-- | src/common/string_util.h | 8 |
12 files changed, 44 insertions, 40 deletions
diff --git a/src/common/common_types.h b/src/common/common_types.h index 9d41e5971..00fde828d 100644 --- a/src/common/common_types.h +++ b/src/common/common_types.h | |||
| @@ -100,7 +100,7 @@ union t128 { | |||
| 100 | __m128 a; ///< 128-bit floating point (__m128 maps to the XMM[0-7] registers) | 100 | __m128 a; ///< 128-bit floating point (__m128 maps to the XMM[0-7] registers) |
| 101 | }; | 101 | }; |
| 102 | 102 | ||
| 103 | namespace common { | 103 | namespace Common { |
| 104 | /// Rectangle data structure | 104 | /// Rectangle data structure |
| 105 | class Rect { | 105 | class Rect { |
| 106 | public: | 106 | public: |
diff --git a/src/common/console_listener.cpp b/src/common/console_listener.cpp index 6a89edd44..40122224c 100644 --- a/src/common/console_listener.cpp +++ b/src/common/console_listener.cpp | |||
| @@ -43,7 +43,7 @@ void ConsoleListener::Open(bool Hidden, int Width, int Height, const char *Title | |||
| 43 | // Save the window handle that AllocConsole() created | 43 | // Save the window handle that AllocConsole() created |
| 44 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); | 44 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 45 | // Set the console window title | 45 | // Set the console window title |
| 46 | SetConsoleTitle(UTF8ToTStr(Title).c_str()); | 46 | SetConsoleTitle(Common::UTF8ToTStr(Title).c_str()); |
| 47 | // Set letter space | 47 | // Set letter space |
| 48 | LetterSpace(80, 4000); | 48 | LetterSpace(80, 4000); |
| 49 | //MoveWindow(GetConsoleWindow(), 200,200, 800,800, true); | 49 | //MoveWindow(GetConsoleWindow(), 200,200, 800,800, true); |
| @@ -189,11 +189,11 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool | |||
| 189 | { | 189 | { |
| 190 | Str.resize(Str.size() + 1); | 190 | Str.resize(Str.size() + 1); |
| 191 | if (!ReadConsoleOutputCharacter(hConsole, Str.back().data(), ReadBufferSize, coordScreen, &cCharsRead)) | 191 | if (!ReadConsoleOutputCharacter(hConsole, Str.back().data(), ReadBufferSize, coordScreen, &cCharsRead)) |
| 192 | SLog += StringFromFormat("WriteConsoleOutputCharacter error"); | 192 | SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error"); |
| 193 | 193 | ||
| 194 | Attr.resize(Attr.size() + 1); | 194 | Attr.resize(Attr.size() + 1); |
| 195 | if (!ReadConsoleOutputAttribute(hConsole, Attr.back().data(), ReadBufferSize, coordScreen, &cAttrRead)) | 195 | if (!ReadConsoleOutputAttribute(hConsole, Attr.back().data(), ReadBufferSize, coordScreen, &cAttrRead)) |
| 196 | SLog += StringFromFormat("WriteConsoleOutputAttribute error"); | 196 | SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error"); |
| 197 | 197 | ||
| 198 | // Break on error | 198 | // Break on error |
| 199 | if (cAttrRead == 0) break; | 199 | if (cAttrRead == 0) break; |
| @@ -219,9 +219,9 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool | |||
| 219 | for (size_t i = 0; i < Attr.size(); i++) | 219 | for (size_t i = 0; i < Attr.size(); i++) |
| 220 | { | 220 | { |
| 221 | if (!WriteConsoleOutputCharacter(hConsole, Str[i].data(), ReadBufferSize, coordScreen, &cCharsWritten)) | 221 | if (!WriteConsoleOutputCharacter(hConsole, Str[i].data(), ReadBufferSize, coordScreen, &cCharsWritten)) |
| 222 | SLog += StringFromFormat("WriteConsoleOutputCharacter error"); | 222 | SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error"); |
| 223 | if (!WriteConsoleOutputAttribute(hConsole, Attr[i].data(), ReadBufferSize, coordScreen, &cAttrWritten)) | 223 | if (!WriteConsoleOutputAttribute(hConsole, Attr[i].data(), ReadBufferSize, coordScreen, &cAttrWritten)) |
| 224 | SLog += StringFromFormat("WriteConsoleOutputAttribute error"); | 224 | SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error"); |
| 225 | 225 | ||
| 226 | BytesWritten += cAttrWritten; | 226 | BytesWritten += cAttrWritten; |
| 227 | coordScreen = GetCoordinates(BytesWritten, LBufWidth); | 227 | coordScreen = GetCoordinates(BytesWritten, LBufWidth); |
diff --git a/src/common/extended_trace.cpp b/src/common/extended_trace.cpp index 66dae4935..9cd0398ed 100644 --- a/src/common/extended_trace.cpp +++ b/src/common/extended_trace.cpp | |||
| @@ -278,7 +278,7 @@ void PrintFunctionAndSourceInfo(FILE* file, const STACKFRAME& callstack) | |||
| 278 | 278 | ||
| 279 | GetFunctionInfoFromAddresses((ULONG)callstack.AddrPC.Offset, (ULONG)callstack.AddrFrame.Offset, symInfo); | 279 | GetFunctionInfoFromAddresses((ULONG)callstack.AddrPC.Offset, (ULONG)callstack.AddrFrame.Offset, symInfo); |
| 280 | GetSourceInfoFromAddress((ULONG)callstack.AddrPC.Offset, srcInfo); | 280 | GetSourceInfoFromAddress((ULONG)callstack.AddrPC.Offset, srcInfo); |
| 281 | etfprint(file, " " + TStrToUTF8(srcInfo) + " : " + TStrToUTF8(symInfo) + "\n"); | 281 | etfprint(file, " " + Common::TStrToUTF8(srcInfo) + " : " + Common::TStrToUTF8(symInfo) + "\n"); |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file ) | 284 | void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file ) |
diff --git a/src/common/file_search.cpp b/src/common/file_search.cpp index cd50ace75..63580f688 100644 --- a/src/common/file_search.cpp +++ b/src/common/file_search.cpp | |||
| @@ -33,10 +33,10 @@ CFileSearch::CFileSearch(const CFileSearch::XStringVector& _rSearchStrings, cons | |||
| 33 | void CFileSearch::FindFiles(const std::string& _searchString, const std::string& _strPath) | 33 | void CFileSearch::FindFiles(const std::string& _searchString, const std::string& _strPath) |
| 34 | { | 34 | { |
| 35 | std::string GCMSearchPath; | 35 | std::string GCMSearchPath; |
| 36 | BuildCompleteFilename(GCMSearchPath, _strPath, _searchString); | 36 | Common::BuildCompleteFilename(GCMSearchPath, _strPath, _searchString); |
| 37 | #ifdef _WIN32 | 37 | #ifdef _WIN32 |
| 38 | WIN32_FIND_DATA findData; | 38 | WIN32_FIND_DATA findData; |
| 39 | HANDLE FindFirst = FindFirstFile(UTF8ToTStr(GCMSearchPath).c_str(), &findData); | 39 | HANDLE FindFirst = FindFirstFile(Common::UTF8ToTStr(GCMSearchPath).c_str(), &findData); |
| 40 | 40 | ||
| 41 | if (FindFirst != INVALID_HANDLE_VALUE) | 41 | if (FindFirst != INVALID_HANDLE_VALUE) |
| 42 | { | 42 | { |
| @@ -47,7 +47,7 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string& | |||
| 47 | if (findData.cFileName[0] != '.') | 47 | if (findData.cFileName[0] != '.') |
| 48 | { | 48 | { |
| 49 | std::string strFilename; | 49 | std::string strFilename; |
| 50 | BuildCompleteFilename(strFilename, _strPath, TStrToUTF8(findData.cFileName)); | 50 | Common::BuildCompleteFilename(strFilename, _strPath, Common::TStrToUTF8(findData.cFileName)); |
| 51 | m_FileNames.push_back(strFilename); | 51 | m_FileNames.push_back(strFilename); |
| 52 | } | 52 | } |
| 53 | 53 | ||
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 04d222ca1..970041007 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -64,7 +64,7 @@ bool Exists(const std::string &filename) | |||
| 64 | StripTailDirSlashes(copy); | 64 | StripTailDirSlashes(copy); |
| 65 | 65 | ||
| 66 | #ifdef _WIN32 | 66 | #ifdef _WIN32 |
| 67 | int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info); | 67 | int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); |
| 68 | #else | 68 | #else |
| 69 | int result = stat64(copy.c_str(), &file_info); | 69 | int result = stat64(copy.c_str(), &file_info); |
| 70 | #endif | 70 | #endif |
| @@ -81,7 +81,7 @@ bool IsDirectory(const std::string &filename) | |||
| 81 | StripTailDirSlashes(copy); | 81 | StripTailDirSlashes(copy); |
| 82 | 82 | ||
| 83 | #ifdef _WIN32 | 83 | #ifdef _WIN32 |
| 84 | int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info); | 84 | int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); |
| 85 | #else | 85 | #else |
| 86 | int result = stat64(copy.c_str(), &file_info); | 86 | int result = stat64(copy.c_str(), &file_info); |
| 87 | #endif | 87 | #endif |
| @@ -117,7 +117,7 @@ bool Delete(const std::string &filename) | |||
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | #ifdef _WIN32 | 119 | #ifdef _WIN32 |
| 120 | if (!DeleteFile(UTF8ToTStr(filename).c_str())) | 120 | if (!DeleteFile(Common::UTF8ToTStr(filename).c_str())) |
| 121 | { | 121 | { |
| 122 | WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", | 122 | WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", |
| 123 | filename.c_str(), GetLastErrorMsg()); | 123 | filename.c_str(), GetLastErrorMsg()); |
| @@ -139,7 +139,7 @@ bool CreateDir(const std::string &path) | |||
| 139 | { | 139 | { |
| 140 | INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); | 140 | INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); |
| 141 | #ifdef _WIN32 | 141 | #ifdef _WIN32 |
| 142 | if (::CreateDirectory(UTF8ToTStr(path).c_str(), NULL)) | 142 | if (::CreateDirectory(Common::UTF8ToTStr(path).c_str(), NULL)) |
| 143 | return true; | 143 | return true; |
| 144 | DWORD error = GetLastError(); | 144 | DWORD error = GetLastError(); |
| 145 | if (error == ERROR_ALREADY_EXISTS) | 145 | if (error == ERROR_ALREADY_EXISTS) |
| @@ -218,7 +218,7 @@ bool DeleteDir(const std::string &filename) | |||
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | #ifdef _WIN32 | 220 | #ifdef _WIN32 |
| 221 | if (::RemoveDirectory(UTF8ToTStr(filename).c_str())) | 221 | if (::RemoveDirectory(Common::UTF8ToTStr(filename).c_str())) |
| 222 | return true; | 222 | return true; |
| 223 | #else | 223 | #else |
| 224 | if (rmdir(filename.c_str()) == 0) | 224 | if (rmdir(filename.c_str()) == 0) |
| @@ -247,7 +247,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename) | |||
| 247 | INFO_LOG(COMMON, "Copy: %s --> %s", | 247 | INFO_LOG(COMMON, "Copy: %s --> %s", |
| 248 | srcFilename.c_str(), destFilename.c_str()); | 248 | srcFilename.c_str(), destFilename.c_str()); |
| 249 | #ifdef _WIN32 | 249 | #ifdef _WIN32 |
| 250 | if (CopyFile(UTF8ToTStr(srcFilename).c_str(), UTF8ToTStr(destFilename).c_str(), FALSE)) | 250 | if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE)) |
| 251 | return true; | 251 | return true; |
| 252 | 252 | ||
| 253 | ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", | 253 | ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", |
| @@ -335,7 +335,7 @@ u64 GetSize(const std::string &filename) | |||
| 335 | 335 | ||
| 336 | struct stat64 buf; | 336 | struct stat64 buf; |
| 337 | #ifdef _WIN32 | 337 | #ifdef _WIN32 |
| 338 | if (_tstat64(UTF8ToTStr(filename).c_str(), &buf) == 0) | 338 | if (_tstat64(Common::UTF8ToTStr(filename).c_str(), &buf) == 0) |
| 339 | #else | 339 | #else |
| 340 | if (stat64(filename.c_str(), &buf) == 0) | 340 | if (stat64(filename.c_str(), &buf) == 0) |
| 341 | #endif | 341 | #endif |
| @@ -408,7 +408,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) | |||
| 408 | // Find the first file in the directory. | 408 | // Find the first file in the directory. |
| 409 | WIN32_FIND_DATA ffd; | 409 | WIN32_FIND_DATA ffd; |
| 410 | 410 | ||
| 411 | HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd); | 411 | HANDLE hFind = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); |
| 412 | if (hFind == INVALID_HANDLE_VALUE) | 412 | if (hFind == INVALID_HANDLE_VALUE) |
| 413 | { | 413 | { |
| 414 | FindClose(hFind); | 414 | FindClose(hFind); |
| @@ -418,7 +418,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) | |||
| 418 | do | 418 | do |
| 419 | { | 419 | { |
| 420 | FSTEntry entry; | 420 | FSTEntry entry; |
| 421 | const std::string virtualName(TStrToUTF8(ffd.cFileName)); | 421 | const std::string virtualName(Common::TStrToUTF8(ffd.cFileName)); |
| 422 | #else | 422 | #else |
| 423 | struct dirent dirent, *result = NULL; | 423 | struct dirent dirent, *result = NULL; |
| 424 | 424 | ||
| @@ -475,7 +475,7 @@ bool DeleteDirRecursively(const std::string &directory) | |||
| 475 | #ifdef _WIN32 | 475 | #ifdef _WIN32 |
| 476 | // Find the first file in the directory. | 476 | // Find the first file in the directory. |
| 477 | WIN32_FIND_DATA ffd; | 477 | WIN32_FIND_DATA ffd; |
| 478 | HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd); | 478 | HANDLE hFind = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); |
| 479 | 479 | ||
| 480 | if (hFind == INVALID_HANDLE_VALUE) | 480 | if (hFind == INVALID_HANDLE_VALUE) |
| 481 | { | 481 | { |
| @@ -486,7 +486,7 @@ bool DeleteDirRecursively(const std::string &directory) | |||
| 486 | // windows loop | 486 | // windows loop |
| 487 | do | 487 | do |
| 488 | { | 488 | { |
| 489 | const std::string virtualName(TStrToUTF8(ffd.cFileName)); | 489 | const std::string virtualName(Common::TStrToUTF8(ffd.cFileName)); |
| 490 | #else | 490 | #else |
| 491 | struct dirent dirent, *result = NULL; | 491 | struct dirent dirent, *result = NULL; |
| 492 | DIR *dirp = opendir(directory.c_str()); | 492 | DIR *dirp = opendir(directory.c_str()); |
| @@ -624,7 +624,7 @@ std::string& GetExeDirectory() | |||
| 624 | { | 624 | { |
| 625 | TCHAR Dolphin_exe_Path[2048]; | 625 | TCHAR Dolphin_exe_Path[2048]; |
| 626 | GetModuleFileName(NULL, Dolphin_exe_Path, 2048); | 626 | GetModuleFileName(NULL, Dolphin_exe_Path, 2048); |
| 627 | DolphinPath = TStrToUTF8(Dolphin_exe_Path); | 627 | DolphinPath = Common::TStrToUTF8(Dolphin_exe_Path); |
| 628 | DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\')); | 628 | DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\')); |
| 629 | } | 629 | } |
| 630 | return DolphinPath; | 630 | return DolphinPath; |
| @@ -819,7 +819,7 @@ bool IOFile::Open(const std::string& filename, const char openmode[]) | |||
| 819 | { | 819 | { |
| 820 | Close(); | 820 | Close(); |
| 821 | #ifdef _WIN32 | 821 | #ifdef _WIN32 |
| 822 | _tfopen_s(&m_file, UTF8ToTStr(filename).c_str(), UTF8ToTStr(openmode).c_str()); | 822 | _tfopen_s(&m_file, Common::UTF8ToTStr(filename).c_str(), Common::UTF8ToTStr(openmode).c_str()); |
| 823 | #else | 823 | #else |
| 824 | m_file = fopen(filename.c_str(), openmode); | 824 | m_file = fopen(filename.c_str(), openmode); |
| 825 | #endif | 825 | #endif |
diff --git a/src/common/file_util.h b/src/common/file_util.h index 0871734d4..fdae5c9c8 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h | |||
| @@ -213,7 +213,7 @@ template <typename T> | |||
| 213 | void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) | 213 | void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) |
| 214 | { | 214 | { |
| 215 | #ifdef _WIN32 | 215 | #ifdef _WIN32 |
| 216 | fstream.open(UTF8ToTStr(filename).c_str(), openmode); | 216 | fstream.open(Common::UTF8ToTStr(filename).c_str(), openmode); |
| 217 | #else | 217 | #else |
| 218 | fstream.open(filename.c_str(), openmode); | 218 | fstream.open(filename.c_str(), openmode); |
| 219 | #endif | 219 | #endif |
diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp index c2b5d0e2c..43346f279 100644 --- a/src/common/log_manager.cpp +++ b/src/common/log_manager.cpp | |||
| @@ -120,7 +120,7 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const | |||
| 120 | if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners()) | 120 | if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners()) |
| 121 | return; | 121 | return; |
| 122 | 122 | ||
| 123 | CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args); | 123 | Common::CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args); |
| 124 | 124 | ||
| 125 | static const char level_to_char[7] = "ONEWID"; | 125 | static const char level_to_char[7] = "ONEWID"; |
| 126 | sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line, | 126 | sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line, |
diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp index a456beb28..40d9c03a2 100644 --- a/src/common/mem_arena.cpp +++ b/src/common/mem_arena.cpp | |||
| @@ -139,7 +139,7 @@ void MemArena::GrabLowMemSpace(size_t size) | |||
| 139 | // a bit more. | 139 | // a bit more. |
| 140 | for (int i = 0; i < 10000; i++) | 140 | for (int i = 0; i < 10000; i++) |
| 141 | { | 141 | { |
| 142 | std::string file_name = StringFromFormat("/citramem.%d", i); | 142 | std::string file_name = Common::StringFromFormat("/citramem.%d", i); |
| 143 | fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); | 143 | fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); |
| 144 | if (fd != -1) | 144 | if (fd != -1) |
| 145 | { | 145 | { |
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index 45bf5a496..bab7d9f7a 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp | |||
| @@ -187,7 +187,7 @@ std::string MemUsage() | |||
| 187 | if (NULL == hProcess) return "MemUsage Error"; | 187 | if (NULL == hProcess) return "MemUsage Error"; |
| 188 | 188 | ||
| 189 | if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) | 189 | if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) |
| 190 | Ret = StringFromFormat("%s K", ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str()); | 190 | Ret = Common::StringFromFormat("%s K", Common::ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str()); |
| 191 | 191 | ||
| 192 | CloseHandle(hProcess); | 192 | CloseHandle(hProcess); |
| 193 | return Ret; | 193 | return Ret; |
diff --git a/src/common/msg_handler.cpp b/src/common/msg_handler.cpp index 3e02ec4d7..b3556aaa8 100644 --- a/src/common/msg_handler.cpp +++ b/src/common/msg_handler.cpp | |||
| @@ -72,7 +72,7 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...) | |||
| 72 | 72 | ||
| 73 | va_list args; | 73 | va_list args; |
| 74 | va_start(args, format); | 74 | va_start(args, format); |
| 75 | CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args); | 75 | Common::CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args); |
| 76 | va_end(args); | 76 | va_end(args); |
| 77 | 77 | ||
| 78 | ERROR_LOG(MASTER_LOG, "%s: %s", caption.c_str(), buffer); | 78 | ERROR_LOG(MASTER_LOG, "%s: %s", caption.c_str(), buffer); |
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index b0c65d47d..9199e30bc 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -13,20 +13,18 @@ | |||
| 13 | #include <iconv.h> | 13 | #include <iconv.h> |
| 14 | #endif | 14 | #endif |
| 15 | 15 | ||
| 16 | namespace Common { | ||
| 17 | |||
| 16 | /// Make a string lowercase | 18 | /// Make a string lowercase |
| 17 | void LowerStr(char* str) { | 19 | std::string ToLower(std::string str) { |
| 18 | for (int i = 0; str[i]; i++) { | 20 | std::transform(str.begin(), str.end(), str.begin(), ::tolower); |
| 19 | str[i] = tolower(str[ i ]); | 21 | return str; |
| 20 | } | ||
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | /// Make a string uppercase | 24 | /// Make a string uppercase |
| 24 | void UpperStr(char* str) { | 25 | std::string ToUpper(std::string str) { |
| 25 | for (int i=0; i < strlen(str); i++) { | 26 | std::transform(str.begin(), str.end(), str.begin(), ::toupper); |
| 26 | if(str[i] >= 'a' && str[i] <= 'z') { | 27 | return str; |
| 27 | str[i] &= 0xDF; | ||
| 28 | } | ||
| 29 | } | ||
| 30 | } | 28 | } |
| 31 | 29 | ||
| 32 | // faster than sscanf | 30 | // faster than sscanf |
| @@ -546,3 +544,5 @@ std::string UTF16ToUTF8(const std::wstring& input) | |||
| 546 | } | 544 | } |
| 547 | 545 | ||
| 548 | #endif | 546 | #endif |
| 547 | |||
| 548 | } | ||
diff --git a/src/common/string_util.h b/src/common/string_util.h index ba4cd363e..16ce39bc1 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h | |||
| @@ -12,11 +12,13 @@ | |||
| 12 | 12 | ||
| 13 | #include "common/common.h" | 13 | #include "common/common.h" |
| 14 | 14 | ||
| 15 | namespace Common { | ||
| 16 | |||
| 15 | /// Make a string lowercase | 17 | /// Make a string lowercase |
| 16 | void LowerStr(char* str); | 18 | std::string ToLower(std::string str); |
| 17 | 19 | ||
| 18 | /// Make a string uppercase | 20 | /// Make a string uppercase |
| 19 | void UpperStr(char* str); | 21 | std::string ToUpper(std::string str); |
| 20 | 22 | ||
| 21 | std::string StringFromFormat(const char* format, ...); | 23 | std::string StringFromFormat(const char* format, ...); |
| 22 | // Cheap! | 24 | // Cheap! |
| @@ -111,3 +113,5 @@ inline std::string UTF8ToTStr(const std::string& str) | |||
| 111 | #endif | 113 | #endif |
| 112 | 114 | ||
| 113 | #endif | 115 | #endif |
| 116 | |||
| 117 | } | ||