OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "nacl_io/path.h" | 5 #include "nacl_io/path.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <string> | 10 #include <string> |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 if (slashes == start) | 163 if (slashes == start) |
164 pstart = p + 1; | 164 pstart = p + 1; |
165 | 165 |
166 if (slashes == end) { | 166 if (slashes == end) { |
167 pend = p; | 167 pend = p; |
168 break; | 168 break; |
169 } | 169 } |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 if (pstart > pend) | 173 if (slashes < start || pstart > pend) |
174 return std::string(); | 174 return std::string(); |
175 | 175 |
176 return std::string(pstart, pend - pstart); | 176 return std::string(pstart, pend - pstart); |
177 } | 177 } |
178 | 178 |
179 void Path::Normalize() { | 179 void Path::Normalize() { |
180 char* outp = &path_[0]; | 180 char* outp = &path_[0]; |
181 const char* start = outp; | 181 const char* start = outp; |
182 const char* part_start = start; | 182 const char* part_start = start; |
183 const char* next_slash; | 183 const char* next_slash; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 263 |
264 bool Path::operator==(const Path& other) { | 264 bool Path::operator==(const Path& other) { |
265 return len_ == other.len_ && strncmp(path_, other.path_, len_) == 0; | 265 return len_ == other.len_ && strncmp(path_, other.path_, len_) == 0; |
266 } | 266 } |
267 | 267 |
268 bool Path::operator!=(const Path& other) { | 268 bool Path::operator!=(const Path& other) { |
269 return !operator==(other); | 269 return !operator==(other); |
270 } | 270 } |
271 | 271 |
272 } // namespace nacl_io | 272 } // namespace nacl_io |
OLD | NEW |