[llvm-commits] [llvm] r73368 - in /llvm/trunk: include/llvm/System/Path.h lib/System/Unix/Path.inc lib/System/Win32/Path.inc
Chris Lattner
sabre at nondot.org
Sun Jun 14 21:17:07 PDT 2009
Author: lattner
Date: Sun Jun 14 23:17:07 2009
New Revision: 73368
URL: http://llvm.org/viewvc/llvm-project?rev=73368&view=rev
Log:
add a new static method to portably determine whether a patch is
absolute or not, based on a patch by Gregory Curfman!
Modified:
llvm/trunk/include/llvm/System/Path.h
llvm/trunk/lib/System/Unix/Path.inc
llvm/trunk/lib/System/Win32/Path.inc
Modified: llvm/trunk/include/llvm/System/Path.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Path.h?rev=73368&r1=73367&r2=73368&view=diff
==============================================================================
--- llvm/trunk/include/llvm/System/Path.h (original)
+++ llvm/trunk/include/llvm/System/Path.h Sun Jun 14 23:17:07 2009
@@ -309,6 +309,11 @@
/// @brief Determine if the path is absolute.
bool isAbsolute() const;
+ /// This function determines if the path name is absolute, as opposed to
+ /// relative.
+ /// @brief Determine if the path is absolute.
+ static bool isAbsolute(const char *NameStart, unsigned NameLen);
+
/// This function opens the file associated with the path name provided by
/// the Path object and reads its magic number. If the magic number at the
/// start of the file matches \p magic, true is returned. In all other
Modified: llvm/trunk/lib/System/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=73368&r1=73367&r2=73368&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Path.inc (original)
+++ llvm/trunk/lib/System/Unix/Path.inc Sun Jun 14 23:17:07 2009
@@ -104,6 +104,14 @@
}
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;
Modified: llvm/trunk/lib/System/Win32/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=73368&r1=73367&r2=73368&view=diff
==============================================================================
--- llvm/trunk/lib/System/Win32/Path.inc (original)
+++ llvm/trunk/lib/System/Win32/Path.inc Sun Jun 14 23:17:07 2009
@@ -125,6 +125,20 @@
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()) {
More information about the llvm-commits
mailing list