[llvm-commits] [llvm] r52288 - in /llvm/trunk/lib/System: Path.cpp Unix/Path.inc Win32/Path.inc
Argiris Kirtzidis
akyrtzi at gmail.com
Sun Jun 15 08:15:19 PDT 2008
Author: akirtzidis
Date: Sun Jun 15 10:15:19 2008
New Revision: 52288
URL: http://llvm.org/viewvc/llvm-project?rev=52288&view=rev
Log:
Fix the sys::Path::getSuffix() implementation.
Modified:
llvm/trunk/lib/System/Path.cpp
llvm/trunk/lib/System/Unix/Path.inc
llvm/trunk/lib/System/Win32/Path.inc
Modified: llvm/trunk/lib/System/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Path.cpp?rev=52288&r1=52287&r2=52288&view=diff
==============================================================================
--- llvm/trunk/lib/System/Path.cpp (original)
+++ llvm/trunk/lib/System/Path.cpp Sun Jun 15 10:15:19 2008
@@ -185,11 +185,6 @@
return false;
}
-std::string
-Path::getSuffix() const {
- return path.substr(path.rfind('.') + 1);
-}
-
static void getPathList(const char*path, std::vector<Path>& Paths) {
const char* at = path;
const char* delim = strchr(at, PathSeparator);
Modified: llvm/trunk/lib/System/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=52288&r1=52287&r2=52288&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Path.inc (original)
+++ llvm/trunk/lib/System/Unix/Path.inc Sun Jun 15 10:15:19 2008
@@ -303,6 +303,22 @@
return path.substr(slash, dot - slash);
}
+std::string
+Path::getSuffix() const {
+ // Find the last slash
+ std::string::size_type slash = path.rfind('/');
+ if (slash == std::string::npos)
+ slash = 0;
+ else
+ slash++;
+
+ std::string::size_type dot = path.rfind('.');
+ if (dot == std::string::npos || dot < slash)
+ return std::string()
+ else
+ return path.substr(dot + 1);
+}
+
bool Path::getMagicNumber(std::string& Magic, unsigned len) const {
assert(len < 1024 && "Request for magic string too long");
char* buf = (char*) alloca(1 + len);
Modified: llvm/trunk/lib/System/Win32/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=52288&r1=52287&r2=52288&view=diff
==============================================================================
--- llvm/trunk/lib/System/Win32/Path.inc (original)
+++ llvm/trunk/lib/System/Win32/Path.inc Sun Jun 15 10:15:19 2008
@@ -259,6 +259,22 @@
return path.substr(slash, dot - slash);
}
+std::string
+Path::getSuffix() const {
+ // Find the last slash
+ size_t slash = path.rfind('/');
+ if (slash == std::string::npos)
+ slash = 0;
+ else
+ slash++;
+
+ size_t dot = path.rfind('.');
+ if (dot == std::string::npos || dot < slash)
+ return std::string();
+ else
+ return path.substr(dot + 1);
+}
+
bool
Path::exists() const {
DWORD attr = GetFileAttributes(path.c_str());
More information about the llvm-commits
mailing list