From ef4c2ce0317ae583e837722b6a41ea44cd83da71 Mon Sep 17 00:00:00 2001 From: frosch Date: Wed, 23 Apr 2014 20:44:42 +0000 Subject: (svn r26485) -Codechange: Replace ttd_strlcpy and ttd_strlcat with strecpy and strecat. --- src/os/macosx/macos.mm | 8 ++++---- src/os/os2/os2.cpp | 4 ++-- src/os/unix/unix.cpp | 2 +- src/os/windows/win32.cpp | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/os') diff --git a/src/os/macosx/macos.mm b/src/os/macosx/macos.mm index 1b1a1d5a7..8d34cda58 100644 --- a/src/os/macosx/macos.mm +++ b/src/os/macosx/macos.mm @@ -155,11 +155,11 @@ const char *GetCurrentLocale(const char *) /** * Return the contents of the clipboard (COCOA). * - * @param buffer Clipboard content.. - * @param buff_len Length of the clipboard content.. + * @param buffer Clipboard content. + * @param last The pointer to the last element of the destination buffer * @return Whether clipboard is empty or not. */ -bool GetClipboardContents(char *buffer, size_t buff_len) +bool GetClipboardContents(char *buffer, const char *last) { NSPasteboard *pb = [ NSPasteboard generalPasteboard ]; NSArray *types = [ NSArray arrayWithObject:NSStringPboardType ]; @@ -171,7 +171,7 @@ bool GetClipboardContents(char *buffer, size_t buff_len) NSString *string = [ pb stringForType:NSStringPboardType ]; if (string == nil || [ string length ] == 0) return false; - ttd_strlcpy(buffer, [ string UTF8String ], buff_len); + strecpy(buffer, [ string UTF8String ], last); return true; } diff --git a/src/os/os2/os2.cpp b/src/os/os2/os2.cpp index 283104d08..e62b96850 100644 --- a/src/os/os2/os2.cpp +++ b/src/os/os2/os2.cpp @@ -177,7 +177,7 @@ int CDECL main(int argc, char *argv[]) return openttd_main(argc, argv); } -bool GetClipboardContents(char *buffer, size_t buff_len) +bool GetClipboardContents(char *buffer, const char *last) { /* XXX -- Currently no clipboard support implemented with GCC */ #ifndef __INNOTEK_LIBC__ @@ -189,7 +189,7 @@ bool GetClipboardContents(char *buffer, size_t buff_len) if (text != NULL) { - ttd_strlcpy(buffer, text, buff_len); + strecpy(buffer, text, last); WinCloseClipbrd(hab); return true; } diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp index accfffc06..ddbf0fe36 100644 --- a/src/os/unix/unix.cpp +++ b/src/os/unix/unix.cpp @@ -284,7 +284,7 @@ int CDECL main(int argc, char *argv[]) } #ifndef WITH_COCOA -bool GetClipboardContents(char *buffer, size_t buff_len) +bool GetClipboardContents(char *buffer, const char *last) { return false; } diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index 30d964df7..66d7207df 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -496,7 +496,7 @@ void DetermineBasePaths(const char *exe) if (SUCCEEDED(OTTDSHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path))) { strecpy(tmp, FS2OTTD(path), lastof(tmp)); AppendPathSeparator(tmp, MAX_PATH); - ttd_strlcat(tmp, PERSONAL_DIR, MAX_PATH); + strecat(tmp, PERSONAL_DIR, lastof(tmp)); AppendPathSeparator(tmp, MAX_PATH); _searchpaths[SP_PERSONAL_DIR] = strdup(tmp); } else { @@ -506,7 +506,7 @@ void DetermineBasePaths(const char *exe) if (SUCCEEDED(OTTDSHGetFolderPath(NULL, CSIDL_COMMON_DOCUMENTS, NULL, SHGFP_TYPE_CURRENT, path))) { strecpy(tmp, FS2OTTD(path), lastof(tmp)); AppendPathSeparator(tmp, MAX_PATH); - ttd_strlcat(tmp, PERSONAL_DIR, MAX_PATH); + strecat(tmp, PERSONAL_DIR, lastof(tmp)); AppendPathSeparator(tmp, MAX_PATH); _searchpaths[SP_SHARED_DIR] = strdup(tmp); } else { @@ -544,7 +544,7 @@ void DetermineBasePaths(const char *exe) } -bool GetClipboardContents(char *buffer, size_t buff_len) +bool GetClipboardContents(char *buffer, const char *last) { HGLOBAL cbuf; const char *ptr; @@ -554,7 +554,7 @@ bool GetClipboardContents(char *buffer, size_t buff_len) cbuf = GetClipboardData(CF_UNICODETEXT); ptr = (const char*)GlobalLock(cbuf); - int out_len = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)ptr, -1, buffer, (int)buff_len, NULL, NULL); + int out_len = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)ptr, -1, buffer, (last - buffer) + 1, NULL, NULL); GlobalUnlock(cbuf); CloseClipboard(); @@ -565,7 +565,7 @@ bool GetClipboardContents(char *buffer, size_t buff_len) cbuf = GetClipboardData(CF_TEXT); ptr = (const char*)GlobalLock(cbuf); - ttd_strlcpy(buffer, FS2OTTD(ptr), buff_len); + strecpy(buffer, FS2OTTD(ptr), last); GlobalUnlock(cbuf); CloseClipboard(); -- cgit v1.2.3-54-g00ecf