diff options
author | Chris Lattner <sabre@nondot.org> | 2009-06-15 04:17:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-06-15 04:17:07 +0000 |
commit | 88d7e403d02ad9ef72972b22c0fd2975d5a38bfd (patch) | |
tree | d5366ad1caad8d15bb8d2d844f4ec074ed33b6d2 /lib/System | |
parent | e4935150c71170ee0aa174e08282a6913148c04c (diff) | |
download | external_llvm-88d7e403d02ad9ef72972b22c0fd2975d5a38bfd.zip external_llvm-88d7e403d02ad9ef72972b22c0fd2975d5a38bfd.tar.gz external_llvm-88d7e403d02ad9ef72972b22c0fd2975d5a38bfd.tar.bz2 |
add a new static method to portably determine whether a patch is
absolute or not, based on a patch by Gregory Curfman!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73368 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System')
-rw-r--r-- | lib/System/Unix/Path.inc | 8 | ||||
-rw-r--r-- | lib/System/Win32/Path.inc | 14 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index d5edee1..1f73571 100644 --- a/lib/System/Unix/Path.inc +++ b/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/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc index fbf8f66..62da3a3 100644 --- a/lib/System/Win32/Path.inc +++ b/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()) { |