| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 <chromeos/string.h> | 5 #include <chromeos/string.h> |
| 6 | 6 |
| 7 #include <cstring> |
| 8 |
| 7 #include <pcrecpp.h> | 9 #include <pcrecpp.h> |
| 8 | |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 | 11 |
| 11 namespace chromeos { | 12 namespace chromeos { |
| 12 | 13 |
| 13 void SplitString(const std::string& str, std::vector<std::string>* parts) { | 14 void SplitString(const std::string& str, std::vector<std::string>* parts) { |
| 14 CHECK(parts); | 15 CHECK(parts); |
| 15 parts->clear(); | 16 parts->clear(); |
| 16 static pcrecpp::RE re("\\s*(\\S+)"); | 17 static pcrecpp::RE re("\\s*(\\S+)"); |
| 17 pcrecpp::StringPiece input(str); | 18 pcrecpp::StringPiece input(str); |
| 18 | 19 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 38 if (delim_pos == std::string::npos) { | 39 if (delim_pos == std::string::npos) { |
| 39 delim_pos = str.size(); | 40 delim_pos = str.size(); |
| 40 } | 41 } |
| 41 if (delim_pos > start) { | 42 if (delim_pos > start) { |
| 42 parts->push_back(str.substr(start, delim_pos - start)); | 43 parts->push_back(str.substr(start, delim_pos - start)); |
| 43 } | 44 } |
| 44 start = delim_pos + delim.size(); | 45 start = delim_pos + delim.size(); |
| 45 } | 46 } |
| 46 } | 47 } |
| 47 | 48 |
| 49 char* NewStringCopy(const char* x) { |
| 50 char* result = static_cast<char*>(::operator new(std::strlen(x) + 1)); |
| 51 std::strcpy(result, x); // NOLINT |
| 52 return result; |
| 53 } |
| 54 |
| 48 } // namespace chromeos | 55 } // namespace chromeos |
| 49 | 56 |
| OLD | NEW |