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

Unified Diff: webrtc/base/stringencode.cc

Issue 1344143002: Catching more errors when parsing ICE server URLs. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing tests that didn't expect PC creation to fail due to ICE parse errors. Created 5 years, 3 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
Index: webrtc/base/stringencode.cc
diff --git a/webrtc/base/stringencode.cc b/webrtc/base/stringencode.cc
index c48c52634c98e1a427b42640810fd4f46f2b6864..7bf05bc0dba55f360fac2ffddb2c10374f9ceba0 100644
--- a/webrtc/base/stringencode.cc
+++ b/webrtc/base/stringencode.cc
@@ -573,6 +573,22 @@ size_t tokenize(const std::string& source, char delimiter,
return fields->size();
}
+size_t tokenize_with_empty_tokens(const std::string& source,
+ char delimiter,
+ std::vector<std::string>* fields) {
+ DCHECK(fields);
tommi 2015/09/16 21:51:01 since fields is deferenced anyway, this isn't need
Taylor Brandstetter 2015/09/24 00:25:05 Done.
+ fields->clear();
tommi 2015/09/16 21:51:01 I'd prefer DCHECK(fields->empty()) instead. |fiel
Taylor Brandstetter 2015/09/24 00:25:05 There's a function specifically called "tokenize_a
+ size_t last = 0;
+ for (size_t i = 0; i < source.length(); ++i) {
+ if (source[i] == delimiter) {
+ fields->push_back(source.substr(last, i - last));
+ last = i + 1;
+ }
+ }
+ fields->push_back(source.substr(last, source.length() - last));
+ return fields->size();
tommi 2015/09/16 21:51:01 if source is empty, won't fields->size() return 1?
Taylor Brandstetter 2015/09/24 00:25:05 This is actually the behavior I wanted, in this si
+}
+
size_t tokenize_append(const std::string& source, char delimiter,
std::vector<std::string>* fields) {
if (!fields) return 0;

Powered by Google App Engine
This is Rietveld 408576698