| OLD | NEW |
| 1 // Copyright 2007, Google Inc. | 1 // Copyright 2007, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 if (repl_source.path) source->path = utf8_buffer->data(); | 379 if (repl_source.path) source->path = utf8_buffer->data(); |
| 380 if (repl_source.query) source->query = utf8_buffer->data(); | 380 if (repl_source.query) source->query = utf8_buffer->data(); |
| 381 if (repl_source.ref) source->ref = utf8_buffer->data(); | 381 if (repl_source.ref) source->ref = utf8_buffer->data(); |
| 382 | 382 |
| 383 return success; | 383 return success; |
| 384 } | 384 } |
| 385 | 385 |
| 386 #ifndef WIN32 | 386 #ifndef WIN32 |
| 387 | 387 |
| 388 int _itoa_s(int value, char* buffer, size_t size_in_chars, int radix) { | 388 int _itoa_s(int value, char* buffer, size_t size_in_chars, int radix) { |
| 389 if (radix != 10) | 389 const char* format_str; |
| 390 if (radix == 10) |
| 391 format_str = "%d"; |
| 392 else if (radix == 16) |
| 393 format_str = "%x"; |
| 394 else |
| 390 return EINVAL; | 395 return EINVAL; |
| 391 | 396 |
| 392 int written = snprintf(buffer, size_in_chars, "%d", value); | 397 int written = snprintf(buffer, size_in_chars, format_str, value); |
| 393 if (static_cast<size_t>(written) >= size_in_chars) { | 398 if (static_cast<size_t>(written) >= size_in_chars) { |
| 394 // Output was truncated, or written was negative. | 399 // Output was truncated, or written was negative. |
| 395 return EINVAL; | 400 return EINVAL; |
| 396 } | 401 } |
| 397 return 0; | 402 return 0; |
| 398 } | 403 } |
| 399 | 404 |
| 400 int _itow_s(int value, char16* buffer, size_t size_in_chars, int radix) { | 405 int _itow_s(int value, char16* buffer, size_t size_in_chars, int radix) { |
| 401 if (radix != 10) | 406 if (radix != 10) |
| 402 return EINVAL; | 407 return EINVAL; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 413 for (int i = 0; i < written; ++i) { | 418 for (int i = 0; i < written; ++i) { |
| 414 buffer[i] = static_cast<char16>(temp[i]); | 419 buffer[i] = static_cast<char16>(temp[i]); |
| 415 } | 420 } |
| 416 buffer[written] = '\0'; | 421 buffer[written] = '\0'; |
| 417 return 0; | 422 return 0; |
| 418 } | 423 } |
| 419 | 424 |
| 420 #endif // !WIN32 | 425 #endif // !WIN32 |
| 421 | 426 |
| 422 } // namespace url_canon | 427 } // namespace url_canon |
| OLD | NEW |