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

Side by Side Diff: base/sys_string_conversions_posix.cc

Issue 9854040: Fix some grammatical errors in base/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove the incorrect fix I made (three out of four ain't bad?) Created 8 years, 8 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 | « base/process_util_linux.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "base/sys_string_conversions.h" 5 #include "base/sys_string_conversions.h"
6 6
7 #include <wchar.h> 7 #include <wchar.h>
8 8
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return std::string(); 72 return std::string();
73 73
74 std::string out; 74 std::string out;
75 out.resize(num_out_chars); 75 out.resize(num_out_chars);
76 76
77 // We walk the input string again, with |i| tracking the index of the 77 // We walk the input string again, with |i| tracking the index of the
78 // wide input, and |j| tracking the multi-byte output. 78 // wide input, and |j| tracking the multi-byte output.
79 memset(&ps, 0, sizeof(ps)); 79 memset(&ps, 0, sizeof(ps));
80 for (size_t i = 0, j = 0; i < wide.size(); ++i) { 80 for (size_t i = 0, j = 0; i < wide.size(); ++i) {
81 const wchar_t src = wide[i]; 81 const wchar_t src = wide[i];
82 // We don't want wcrtomb to do it's funkiness for embedded NULLs. 82 // We don't want wcrtomb to do its funkiness for embedded NULLs.
83 size_t res = src ? wcrtomb(&out[j], src, &ps) : 0; 83 size_t res = src ? wcrtomb(&out[j], src, &ps) : 0;
84 switch (res) { 84 switch (res) {
85 // Handle any errors and return an empty string. 85 // Handle any errors and return an empty string.
86 case static_cast<size_t>(-1): 86 case static_cast<size_t>(-1):
87 return std::string(); 87 return std::string();
88 break; 88 break;
89 case 0: 89 case 0:
90 // We hit an embedded null byte, keep going. 90 // We hit an embedded null byte, keep going.
91 ++j; // Output is already zeroed. 91 ++j; // Output is already zeroed.
92 break; 92 break;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 break; 152 break;
153 } 153 }
154 } 154 }
155 155
156 return out; 156 return out;
157 } 157 }
158 158
159 #endif // OS_CHROMEOS 159 #endif // OS_CHROMEOS
160 160
161 } // namespace base 161 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698