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

Side by Side Diff: net/base/dns_util.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/webm/webm_cluster_parser_unittest.cc ('k') | net/base/host_mapping_rules_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium 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 "net/base/dns_util.h" 5 #include "net/base/dns_util.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 namespace net { 9 namespace net {
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 *out = std::string(name, namelen); 55 *out = std::string(name, namelen);
56 return true; 56 return true;
57 } 57 }
58 58
59 std::string DNSDomainToString(const base::StringPiece& domain) { 59 std::string DNSDomainToString(const base::StringPiece& domain) {
60 std::string ret; 60 std::string ret;
61 61
62 for (unsigned i = 0; i < domain.size() && domain[i]; i += domain[i] + 1) { 62 for (unsigned i = 0; i < domain.size() && domain[i]; i += domain[i] + 1) {
63 #if CHAR_MIN < 0 63 #if CHAR_MIN < 0
64 if (domain[i] < 0) 64 if (domain[i] < 0)
65 return ""; 65 return std::string();
66 #endif 66 #endif
67 if (domain[i] > 63) 67 if (domain[i] > 63)
68 return ""; 68 return std::string();
69 69
70 if (i) 70 if (i)
71 ret += "."; 71 ret += ".";
72 72
73 if (static_cast<unsigned>(domain[i]) + i + 1 > domain.size()) 73 if (static_cast<unsigned>(domain[i]) + i + 1 > domain.size())
74 return ""; 74 return std::string();
75 75
76 domain.substr(i + 1, domain[i]).AppendToString(&ret); 76 domain.substr(i + 1, domain[i]).AppendToString(&ret);
77 } 77 }
78 return ret; 78 return ret;
79 } 79 }
80 80
81 bool IsSTD3ASCIIValidCharacter(char c) { 81 bool IsSTD3ASCIIValidCharacter(char c) {
82 if (c <= 0x2c) 82 if (c <= 0x2c)
83 return false; 83 return false;
84 if (c >= 0x7b) 84 if (c >= 0x7b)
(...skipping 10 matching lines...) Expand all
95 std::string TrimEndingDot(const base::StringPiece& host) { 95 std::string TrimEndingDot(const base::StringPiece& host) {
96 base::StringPiece host_trimmed = host; 96 base::StringPiece host_trimmed = host;
97 size_t len = host_trimmed.length(); 97 size_t len = host_trimmed.length();
98 if (len > 1 && host_trimmed[len - 1] == '.') { 98 if (len > 1 && host_trimmed[len - 1] == '.') {
99 host_trimmed.remove_suffix(1); 99 host_trimmed.remove_suffix(1);
100 } 100 }
101 return host_trimmed.as_string(); 101 return host_trimmed.as_string();
102 } 102 }
103 103
104 } // namespace net 104 } // namespace net
OLDNEW
« no previous file with comments | « media/webm/webm_cluster_parser_unittest.cc ('k') | net/base/host_mapping_rules_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698