diff options
author | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
commit | b2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch) | |
tree | 3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/llcommon/llstring.cpp | |
parent | Second Life viewer sources 1.14.0.1 (diff) | |
download | meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2 meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz |
Second Life viewer sources 1.15.0.2
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llcommon/llstring.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llstring.cpp b/linden/indra/llcommon/llstring.cpp index c9f684f..22d7b47 100644 --- a/linden/indra/llcommon/llstring.cpp +++ b/linden/indra/llcommon/llstring.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | 5 | * Copyright (c) 2001-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * Second Life Viewer Source Code | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 8 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 9 | * to you under the terms of the GNU General Public License, version 2.0 |
9 | * ("GPL"), unless you have obtained a separate licensing agreement | 10 | * ("GPL"), unless you have obtained a separate licensing agreement |
@@ -673,6 +674,33 @@ std::string mbcsstring_makeASCII(const std::string& wstr) | |||
673 | return out_str; | 674 | return out_str; |
674 | } | 675 | } |
675 | 676 | ||
677 | #if LL_WINDOWS | ||
678 | /* If the size of the passed in buffer is not large enough to hold the string, | ||
679 | * two bad things happen: | ||
680 | * 1. resulting formatted string is NOT null terminated | ||
681 | * 2. Depending on the platform, the return value could be a) the required | ||
682 | * size of the buffer to copy the entire formatted string or b) -1. | ||
683 | * On Windows with VS.Net 2003, it returns -1 e.g. | ||
684 | * | ||
685 | * safe_snprintf always adds a NULL terminator so that the caller does not | ||
686 | * need to check for return value or need to add the NULL terminator. | ||
687 | * It does not, however change the return value - to let the caller know | ||
688 | * that the passed in buffer size was not large enough to hold the formatted string. | ||
689 | * | ||
690 | */ | ||
691 | int safe_snprintf(char *str, size_t size, const char *format, ...) | ||
692 | { | ||
693 | va_list args; | ||
694 | va_start(args, format); | ||
695 | |||
696 | int num_written = _vsnprintf(str, size, format, args); /* Flawfinder: ignore */ | ||
697 | va_end(args); | ||
698 | |||
699 | str[size-1] = '\0'; // always null terminate | ||
700 | return num_written; | ||
701 | } | ||
702 | #endif // LL_WINDOWS | ||
703 | |||
676 | S32 LLStringOps::collate(const llwchar* a, const llwchar* b) | 704 | S32 LLStringOps::collate(const llwchar* a, const llwchar* b) |
677 | { | 705 | { |
678 | #if LL_WINDOWS | 706 | #if LL_WINDOWS |