move string helpers to libcros
The only project using these funcs is libcros, so move them to that
project to avoid having to create a small shared library for it.
BUG=chromium-os:29973
TEST=`cbuildbot {x86,amd64,arm}-generic-full` worked
Change-Id: I55c296408a014c919d2cd58b157e6ccbab98666f
Reviewed-on: https://gerrit.chromium.org/gerrit/25043
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/SConstruct b/SConstruct
index e5234fb..ee96e61 100644
--- a/SConstruct
+++ b/SConstruct
@@ -63,14 +63,6 @@
'libs' : '',
'pc_libs' : 'openssl ' + common_pc_libs,
},
- {
- 'name' : 'pcre',
- 'sources' : """
- chromeos/string.cc
- """,
- 'libs' : '',
- 'pc_libs' : 'libpcrecpp ' + common_pc_libs,
- },
]
env = common_env()
diff --git a/chromeos/string.cc b/chromeos/string.cc
deleted file mode 100644
index c70e065..0000000
--- a/chromeos/string.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <chromeos/string.h>
-
-#include <cstring>
-
-#include <pcrecpp.h>
-#include "base/logging.h"
-
-namespace chromeos {
-
-void SplitString(const std::string& str, std::vector<std::string>* parts) {
- CHECK(parts);
- parts->clear();
- static pcrecpp::RE re("\\s*(\\S+)");
- pcrecpp::StringPiece input(str);
-
- // TODO (seanparent) : This code copies each substring into the vector.
- // look at the gcc implementation of string (is it copy-on-write?). Likely
- // it would be better to insert and empty string then swap the part into
- // place.
-
- std::string part;
- while (re.Consume(&input, &part))
- parts->push_back(part);
-}
-
-void SplitStringUsing(const std::string& str,
- const std::string& delim,
- std::vector<std::string>* parts) {
- CHECK(parts);
- CHECK(!delim.empty());
- parts->clear();
- size_t start = 0;
- while (start < str.size()) {
- size_t delim_pos = str.find(delim, start);
- if (delim_pos == std::string::npos) {
- delim_pos = str.size();
- }
- if (delim_pos > start) {
- parts->push_back(str.substr(start, delim_pos - start));
- }
- start = delim_pos + delim.size();
- }
-}
-
-char* NewStringCopy(const char* x) {
- char* result = static_cast<char*>(::operator new(std::strlen(x) + 1));
- std::strcpy(result, x); // NOLINT
- return result;
-}
-
-} // namespace chromeos
-
diff --git a/chromeos/string.h b/chromeos/string.h
deleted file mode 100644
index be330d2..0000000
--- a/chromeos/string.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROMEOS_STRING_H_
-#define CHROMEOS_STRING_H_
-
-#include <string>
-#include <vector>
-
-namespace chromeos {
-
-void SplitString(const std::string& str, std::vector<std::string>* parts);
-
-void SplitStringUsing(const std::string& str,
- const std::string& delim,
- std::vector<std::string>* parts);
-
-// Copies the string. Use delete (not delete [] or free) to release the returned
-// string.
-char* NewStringCopy(const char* x);
-
-} // namespace chromeos
-
-#endif /* CHROMEOS_STRING_H_ */
-