[llvm-commits] [llvm] r121110 - /llvm/trunk/lib/Support/PathV2.cpp
Michael J. Spencer
bigcheesegs at gmail.com
Mon Dec 6 19:57:48 PST 2010
Author: mspencer
Date: Mon Dec 6 21:57:48 2010
New Revision: 121110
URL: http://llvm.org/viewvc/llvm-project?rev=121110&view=rev
Log:
Support/PathV2: Cleanup separator handling.
Modified:
llvm/trunk/lib/Support/PathV2.cpp
Modified: llvm/trunk/lib/Support/PathV2.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=121110&r1=121109&r2=121110&view=diff
==============================================================================
--- llvm/trunk/lib/Support/PathV2.cpp (original)
+++ llvm/trunk/lib/Support/PathV2.cpp Mon Dec 6 21:57:48 2010
@@ -31,7 +31,7 @@
#ifdef LLVM_ON_WIN32
const StringRef separators = "\\/";
- const char prefered_separator = '\\';
+ const char prefered_separator = '\\';
#else
const StringRef separators = "/";
const char prefered_separator = '/';
@@ -50,16 +50,19 @@
if (path.empty())
return path;
+#ifdef LLVM_ON_WIN32
// C:
if (path.size() >= 2 && std::isalpha(path[0]) && path[1] == ':')
return StringRef(path.begin(), 2);
+#endif
// //net
if ((path.size() > 2) &&
- (path.startswith("\\\\") || path.startswith("//")) &&
- (path[2] != '\\' && path[2] != '/')) {
+ is_separator(path[0]) &&
+ path[0] == path[1] &&
+ !is_separator(path[2])) {
// Find the next directory separator.
- size_t end = path.find_first_of("\\/", 2);
+ size_t end = path.find_first_of(separators, 2);
if (end == StringRef::npos)
return path;
else
@@ -67,7 +70,7 @@
}
// {/,\}
- if (path[0] == '\\' || path[0] == '/')
+ if (is_separator(path[0]))
return StringRef(path.begin(), 1);
if (path.startswith(".."))
@@ -77,7 +80,7 @@
return StringRef(path.begin(), 1);
// * {file,directory}name
- size_t end = path.find_first_of("\\/", 2);
+ size_t end = path.find_first_of(separators, 2);
if (end == StringRef::npos)
return path;
else
@@ -89,7 +92,7 @@
size_t filename_pos(const StringRef &str) {
if (str.size() == 2 &&
is_separator(str[0]) &&
- is_separator(str[1]))
+ str[0] == str[1])
return 0;
if (str.size() > 0 && is_separator(str[str.size() - 1]))
More information about the llvm-commits
mailing list