Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: base/string_util_win.h

Issue 9702002: Enable positional parameters for base::vsnprintf and base::vswprintf on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NULL terminate the beginning of the buffer in case of a failure + a unit test. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/stringprintf_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_STRING_UTIL_WIN_H_ 5 #ifndef BASE_STRING_UTIL_WIN_H_
6 #define BASE_STRING_UTIL_WIN_H_ 6 #define BASE_STRING_UTIL_WIN_H_
7 #pragma once 7 #pragma once
8 8
9 #include <stdarg.h> 9 #include <stdarg.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 17 matching lines...) Expand all
28 inline int strncasecmp(const char* s1, const char* s2, size_t count) { 28 inline int strncasecmp(const char* s1, const char* s2, size_t count) {
29 return _strnicmp(s1, s2, count); 29 return _strnicmp(s1, s2, count);
30 } 30 }
31 31
32 inline int strncmp16(const char16* s1, const char16* s2, size_t count) { 32 inline int strncmp16(const char16* s1, const char16* s2, size_t count) {
33 return ::wcsncmp(s1, s2, count); 33 return ::wcsncmp(s1, s2, count);
34 } 34 }
35 35
36 inline int vsnprintf(char* buffer, size_t size, 36 inline int vsnprintf(char* buffer, size_t size,
37 const char* format, va_list arguments) { 37 const char* format, va_list arguments) {
38 int length = vsnprintf_s(buffer, size, size - 1, format, arguments); 38 int length = _vsprintf_p(buffer, size, format, arguments);
39 if (length < 0) 39 if (length < 0) {
40 return _vscprintf(format, arguments); 40 if (size > 0)
41 buffer[0] = 0;
42 return _vscprintf_p(format, arguments);
43 }
41 return length; 44 return length;
42 } 45 }
43 46
44 inline int vswprintf(wchar_t* buffer, size_t size, 47 inline int vswprintf(wchar_t* buffer, size_t size,
45 const wchar_t* format, va_list arguments) { 48 const wchar_t* format, va_list arguments) {
46 DCHECK(IsWprintfFormatPortable(format)); 49 DCHECK(IsWprintfFormatPortable(format));
47 50
48 int length = _vsnwprintf_s(buffer, size, size - 1, format, arguments); 51 int length = _vswprintf_p(buffer, size, format, arguments);
49 if (length < 0) 52 if (length < 0) {
50 return _vscwprintf(format, arguments); 53 if (size > 0)
54 buffer[0] = 0;
55 return _vscwprintf_p(format, arguments);
56 }
51 return length; 57 return length;
52 } 58 }
53 59
54 } // namespace base 60 } // namespace base
55 61
56 #endif // BASE_STRING_UTIL_WIN_H_ 62 #endif // BASE_STRING_UTIL_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | base/stringprintf_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698