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

Side by Side Diff: third_party/libaddressinput/chromium/cpp/src/util/string_split.cc

Issue 211443003: Revert of Determine language code and type of format for address. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // The original source code is from:
6 // http://src.chromium.org/viewvc/chrome/trunk/src/base/strings/string_split.cc? revision=216633
7
8 #include "string_split.h"
9
10 #include <cassert>
11 #include <cstddef>
12 #include <string>
13 #include <vector>
14
15 namespace i18n {
16 namespace addressinput {
17
18 void SplitString(const std::string& str, char s, std::vector<std::string>* r) {
19 assert(r != NULL);
20 r->clear();
21 size_t last = 0;
22 size_t c = str.size();
23 for (size_t i = 0; i <= c; ++i) {
24 if (i == c || str[i] == s) {
25 std::string tmp(str, last, i - last);
26 // Avoid converting an empty or all-whitespace source string into a vector
27 // of one empty string.
28 if (i != c || !r->empty() || !tmp.empty()) {
29 r->push_back(tmp);
30 }
31 last = i + 1;
32 }
33 }
34 }
35
36 } // namespace addressinput
37 } // namespace i18n
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698