| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifdef OS_MACOSX | 5 #ifdef OS_MACOSX |
| 6 #include <CoreFoundation/CoreFoundation.h> | 6 #include <CoreFoundation/CoreFoundation.h> |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include <float.h> | 9 #include <float.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| 11 | 11 |
| 12 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "chrome/browser/sync/notifier/base/string.h" | 14 #include "chrome/browser/sync/notifier/base/string.h" |
| 15 #include "talk/base/common.h" | 15 #include "talk/base/common.h" |
| 16 #include "talk/base/logging.h" | 16 #include "talk/base/logging.h" |
| 17 #include "talk/base/stringencode.h" | 17 #include "talk/base/stringencode.h" |
| 18 | 18 |
| 19 #ifdef OS_WIN |
| 19 using base::snprintf; | 20 using base::snprintf; |
| 21 #endif |
| 20 | 22 |
| 21 namespace notifier { | 23 namespace notifier { |
| 22 | 24 |
| 23 std::string HtmlEncode(const std::string& src) { | 25 std::string HtmlEncode(const std::string& src) { |
| 24 size_t max_length = src.length() * 6 + 1; | 26 size_t max_length = src.length() * 6 + 1; |
| 25 std::string dest; | 27 std::string dest; |
| 26 dest.resize(max_length); | 28 dest.resize(max_length); |
| 27 size_t new_size = talk_base::html_encode(&dest[0], max_length, | 29 size_t new_size = talk_base::html_encode(&dest[0], max_length, |
| 28 src.data(), src.length()); | 30 src.data(), src.length()); |
| 29 dest.resize(new_size); | 31 dest.resize(new_size); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 273 } |
| 272 | 274 |
| 273 std::string DoubleToString(double d) { | 275 std::string DoubleToString(double d) { |
| 274 char buf[160]; | 276 char buf[160]; |
| 275 snprintf(buf, sizeof(buf), "%.17g", d); | 277 snprintf(buf, sizeof(buf), "%.17g", d); |
| 276 return std::string(buf); | 278 return std::string(buf); |
| 277 } | 279 } |
| 278 | 280 |
| 279 std::string UIntToString(uint32 i) { | 281 std::string UIntToString(uint32 i) { |
| 280 char buf[80]; | 282 char buf[80]; |
| 283 #ifdef OS_LINUX |
| 284 snprintf(buf, sizeof(buf), "%u", i); |
| 285 #else |
| 281 snprintf(buf, sizeof(buf), "%lu", i); | 286 snprintf(buf, sizeof(buf), "%lu", i); |
| 287 #endif |
| 282 return std::string(buf); | 288 return std::string(buf); |
| 283 } | 289 } |
| 284 | 290 |
| 285 // Convert an int to a string | 291 // Convert an int to a string |
| 286 std::string IntToString(int i) { | 292 std::string IntToString(int i) { |
| 287 char buf[80]; | 293 char buf[80]; |
| 288 snprintf(buf, sizeof(buf), "%d", i); | 294 snprintf(buf, sizeof(buf), "%d", i); |
| 289 return std::string(buf); | 295 return std::string(buf); |
| 290 } | 296 } |
| 291 | 297 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 res.append(*s, start_pos, pos - start_pos); | 400 res.append(*s, start_pos, pos - start_pos); |
| 395 res.append(new_sub); | 401 res.append(new_sub); |
| 396 start_pos = pos + old_sub_size; // start searching again after the "old". | 402 start_pos = pos + old_sub_size; // start searching again after the "old". |
| 397 } while (replace_all); | 403 } while (replace_all); |
| 398 res.append(*s, start_pos, s->length() - start_pos); | 404 res.append(*s, start_pos, s->length() - start_pos); |
| 399 | 405 |
| 400 *s = res; | 406 *s = res; |
| 401 } | 407 } |
| 402 | 408 |
| 403 } // namespace notifier | 409 } // namespace notifier |
| OLD | NEW |