| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 // backslashes are standard. Let's avoid confusion and use only forward | 263 // backslashes are standard. Let's avoid confusion and use only forward |
| 264 // slashes. | 264 // slashes. |
| 265 if (HasPrefixString(path, "\\\\")) { | 265 if (HasPrefixString(path, "\\\\")) { |
| 266 // Avoid converting two leading backslashes. | 266 // Avoid converting two leading backslashes. |
| 267 path = "\\\\" + StringReplace(path.substr(2), "\\", "/", true); | 267 path = "\\\\" + StringReplace(path.substr(2), "\\", "/", true); |
| 268 } else { | 268 } else { |
| 269 path = StringReplace(path, "\\", "/", true); | 269 path = StringReplace(path, "\\", "/", true); |
| 270 } | 270 } |
| 271 #endif | 271 #endif |
| 272 | 272 |
| 273 std::vector<string> canonical_parts; | 273 vector<string> canonical_parts; |
| 274 std::vector<string> parts = Split( | 274 vector<string> parts = Split( |
| 275 path, "/", true); // Note: Removes empty parts. | 275 path, "/", true); // Note: Removes empty parts. |
| 276 for (int i = 0; i < parts.size(); i++) { | 276 for (int i = 0; i < parts.size(); i++) { |
| 277 if (parts[i] == ".") { | 277 if (parts[i] == ".") { |
| 278 // Ignore. | 278 // Ignore. |
| 279 } else { | 279 } else { |
| 280 canonical_parts.push_back(parts[i]); | 280 canonical_parts.push_back(parts[i]); |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 string result = Join(canonical_parts, "/"); | 283 string result = Join(canonical_parts, "/"); |
| 284 if (!path.empty() && path[0] == '/') { | 284 if (!path.empty() && path[0] == '/') { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 result->SetCloseOnDelete(true); | 487 result->SetCloseOnDelete(true); |
| 488 return result; | 488 return result; |
| 489 } else { | 489 } else { |
| 490 return NULL; | 490 return NULL; |
| 491 } | 491 } |
| 492 } | 492 } |
| 493 | 493 |
| 494 } // namespace compiler | 494 } // namespace compiler |
| 495 } // namespace protobuf | 495 } // namespace protobuf |
| 496 } // namespace google | 496 } // namespace google |
| OLD | NEW |