[llvm-commits] CVS: llvm/lib/System/Unix/Path.inc

Jeff Cohen jeffc at jolt-lang.org
Sat Jul 9 11:42:13 PDT 2005



Changes in directory llvm/lib/System/Unix:

Path.inc updated: 1.42 -> 1.43
---
Log message:

1. Fix bug in getBaseName where it mishandles suffixes
2. Fix bug in eraseSuffix where it allows /path/.suffix to become /path/


---
Diffs of the changes:  (+6 -2)

 Path.inc |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)


Index: llvm/lib/System/Unix/Path.inc
diff -u llvm/lib/System/Unix/Path.inc:1.42 llvm/lib/System/Unix/Path.inc:1.43
--- llvm/lib/System/Unix/Path.inc:1.42	Fri Jul  8 12:46:10 2005
+++ llvm/lib/System/Unix/Path.inc	Sat Jul  9 13:42:02 2005
@@ -271,7 +271,11 @@
   else
     slash++;
 
-  return path.substr(slash, path.rfind('.'));
+  size_t dot = path.rfind('.');
+  if (dot == std::string::npos || dot < slash)
+    return path.substr(slash);
+  else
+    return path.substr(slash, dot - slash);
 }
 
 bool Path::hasMagicNumber(const std::string &Magic) const {
@@ -521,7 +525,7 @@
   size_t dotpos = path.rfind('.',path.size());
   size_t slashpos = path.rfind('/',path.size());
   if (dotpos != std::string::npos) {
-    if (slashpos == std::string::npos || dotpos > slashpos) {
+    if (slashpos == std::string::npos || dotpos > slashpos+1) {
       path.erase(dotpos, path.size()-dotpos);
       return true;
     }






More information about the llvm-commits mailing list