Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: src/IceRangeSpec.cpp

Issue 1903553004: Subzero: Allow overriding command-line args from the browser. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceRangeSpec.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceRangeSpec.cpp
diff --git a/src/IceRangeSpec.cpp b/src/IceRangeSpec.cpp
index e12ce6d84cd4f0758f3dc61ec7a45b3f95502aa9..6a7d32943b7eb26e1e77dc2916668d473d5c9485 100644
--- a/src/IceRangeSpec.cpp
+++ b/src/IceRangeSpec.cpp
@@ -36,24 +36,6 @@ bool RangeSpec::HasNames = false;
namespace {
-/// Helper function to tokenize a string into a vector of string tokens, given a
-/// single delimiter character. An empty string produces an empty token vector.
-/// Zero-length tokens are allowed, e.g. ",a,,,b," may tokenize to
-/// {"","a","","","b",""}.
-std::vector<std::string> tokenize(const std::string &Spec, char Delimiter) {
- std::vector<std::string> Tokens;
- if (!Spec.empty()) {
- std::string::size_type StartPos = 0;
- std::string::size_type DelimPos = 0;
- while (DelimPos != std::string::npos) {
- DelimPos = Spec.find(Delimiter, StartPos);
- Tokens.emplace_back(Spec.substr(StartPos, DelimPos - StartPos));
- StartPos = DelimPos + 1;
- }
- }
- return Tokens;
-}
-
/// Helper function to parse "X" or "X:Y" into First and Last.
/// - "X" is treated as "X:X+1".
/// - ":Y" is treated as "0:Y".
@@ -66,7 +48,7 @@ std::vector<std::string> tokenize(const std::string &Spec, char Delimiter) {
/// report_fatal_error is called.
void getRange(const std::string &Token, uint32_t *First, uint32_t *Last) {
bool Error = false;
- auto Tokens = tokenize(Token, RangeSpec::DELIM_RANGE);
+ auto Tokens = RangeSpec::tokenize(Token, RangeSpec::DELIM_RANGE);
if (Tokens.size() == 1) {
*First = std::stoul(Tokens[0]);
*Last = *First + 1;
@@ -112,6 +94,21 @@ void record(const std::string &Token, RangeSpec::Desc *D) {
} // end of anonymous namespace
+std::vector<std::string> RangeSpec::tokenize(const std::string &Spec,
+ char Delimiter) {
+ std::vector<std::string> Tokens;
+ if (!Spec.empty()) {
+ std::string::size_type StartPos = 0;
+ std::string::size_type DelimPos = 0;
+ while (DelimPos != std::string::npos) {
+ DelimPos = Spec.find(Delimiter, StartPos);
+ Tokens.emplace_back(Spec.substr(StartPos, DelimPos - StartPos));
+ StartPos = DelimPos + 1;
+ }
+ }
+ return Tokens;
+}
+
/// Initialize the RangeSpec with the given string. Calling init multiple times
/// (e.g. init("A");init("B");) is equivalent to init("A,B"); .
void RangeSpec::init(const std::string &Spec) {
« no previous file with comments | « src/IceRangeSpec.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698