OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "url/url_canon_internal.h" | 5 #include "url/url_canon_internal.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 #include <cstdio> | 10 #include <cstdio> |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 242 |
243 void AppendStringOfType(const base::char16* source, int length, | 243 void AppendStringOfType(const base::char16* source, int length, |
244 SharedCharTypes type, | 244 SharedCharTypes type, |
245 CanonOutput* output) { | 245 CanonOutput* output) { |
246 DoAppendStringOfType<base::char16, base::char16>( | 246 DoAppendStringOfType<base::char16, base::char16>( |
247 source, length, type, output); | 247 source, length, type, output); |
248 } | 248 } |
249 | 249 |
250 bool ReadUTFChar(const char* str, int* begin, int length, | 250 bool ReadUTFChar(const char* str, int* begin, int length, |
251 unsigned* code_point_out) { | 251 unsigned* code_point_out) { |
252 // This depends on ints and int32s being the same thing. If they're not, it | 252 // This depends on ints and int32s being the same thing. If they're not, it |
253 // will fail to compile. | 253 // will fail to compile. |
254 // TODO(mmenke): This should probably be fixed. | 254 // TODO(mmenke): This should probably be fixed. |
255 if (!base::ReadUnicodeCharacter(str, length, begin, code_point_out) || | 255 if (!base::ReadUnicodeCharacter(str, length, begin, code_point_out) || |
256 !base::IsValidCharacter(*code_point_out)) { | 256 !base::IsValidCharacter(*code_point_out)) { |
257 *code_point_out = kUnicodeReplacementCharacter; | 257 *code_point_out = kUnicodeReplacementCharacter; |
258 return false; | 258 return false; |
259 } | 259 } |
260 return true; | 260 return true; |
261 } | 261 } |
262 | 262 |
263 bool ReadUTFChar(const base::char16* str, int* begin, int length, | 263 bool ReadUTFChar(const base::char16* str, int* begin, int length, |
264 unsigned* code_point_out) { | 264 unsigned* code_point_out) { |
265 // This depends on ints and int32s being the same thing. If they're not, it | 265 // This depends on ints and int32s being the same thing. If they're not, it |
266 // will fail to compile. | 266 // will fail to compile. |
267 // TODO(mmenke): This should probably be fixed. | 267 // TODO(mmenke): This should probably be fixed. |
268 if (!base::ReadUnicodeCharacter(str, length, begin, code_point_out) || | 268 if (!base::ReadUnicodeCharacter(str, length, begin, code_point_out) || |
269 !base::IsValidCharacter(*code_point_out)) { | 269 !base::IsValidCharacter(*code_point_out)) { |
270 *code_point_out = kUnicodeReplacementCharacter; | 270 *code_point_out = kUnicodeReplacementCharacter; |
271 return false; | 271 return false; |
272 } | 272 } |
273 return true; | 273 return true; |
274 } | 274 } |
275 | 275 |
276 void AppendInvalidNarrowString(const char* spec, int begin, int end, | 276 void AppendInvalidNarrowString(const char* spec, int begin, int end, |
277 CanonOutput* output) { | 277 CanonOutput* output) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 for (int i = 0; i < written; ++i) { | 423 for (int i = 0; i < written; ++i) { |
424 buffer[i] = static_cast<base::char16>(temp[i]); | 424 buffer[i] = static_cast<base::char16>(temp[i]); |
425 } | 425 } |
426 buffer[written] = '\0'; | 426 buffer[written] = '\0'; |
427 return 0; | 427 return 0; |
428 } | 428 } |
429 | 429 |
430 #endif // !WIN32 | 430 #endif // !WIN32 |
431 | 431 |
432 } // namespace url | 432 } // namespace url |
OLD | NEW |