summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-06-15 04:17:07 +0000
committerChris Lattner <sabre@nondot.org>2009-06-15 04:17:07 +0000
commit3f556daa6e5af0b0cff7bb6446ccf4836ce8e14e (patch)
tree6495b5735a50f30e39770cf6c4eea02e951fee49 /llvm/lib/System
parenta5e67757dce04509a201d0a2330ac8e8132681d3 (diff)
downloadbcm5719-llvm-3f556daa6e5af0b0cff7bb6446ccf4836ce8e14e.tar.gz
bcm5719-llvm-3f556daa6e5af0b0cff7bb6446ccf4836ce8e14e.zip
add a new static method to portably determine whether a patch is
absolute or not, based on a patch by Gregory Curfman! llvm-svn: 73368
Diffstat (limited to 'llvm/lib/System')
-rw-r--r--llvm/lib/System/Unix/Path.inc8
-rw-r--r--llvm/lib/System/Win32/Path.inc14
2 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc
index d5edee1b03b..1f73571cf14 100644
--- a/llvm/lib/System/Unix/Path.inc
+++ b/llvm/lib/System/Unix/Path.inc
@@ -104,6 +104,14 @@ Path::isValid() const {
}
bool
+Path::isAbsolute(const char *NameStart, unsigned NameLen) {
+ assert(NameStart);
+ if (NameLen == 0)
+ return false;
+ return NameStart[0] == '/';
+}
+
+bool
Path::isAbsolute() const {
if (path.empty())
return false;
diff --git a/llvm/lib/System/Win32/Path.inc b/llvm/lib/System/Win32/Path.inc
index fbf8f6688a5..62da3a34c45 100644
--- a/llvm/lib/System/Win32/Path.inc
+++ b/llvm/lib/System/Win32/Path.inc
@@ -125,6 +125,20 @@ Path::isValid() const {
return true;
}
+bool
+Path::isAbsolute(const char *NameStart, unsigned NameLen) {
+ assert(NameStart);
+ switch (NameLen) {
+ case 0:
+ return false;
+ case 1:
+ case 2:
+ return NameStart[0] == '/';
+ default:
+ return NameStart[0] == '/' || (NameStart[1] == ':' && NameStart[2] == '/');
+ }
+}
+
bool
Path::isAbsolute() const {
switch (path.length()) {
OpenPOWER on IntegriCloud