Fix a bug where directory names of length one or less where not set
authorAlkis Evlogimenos <alkis@evlogimenos.com>
Mon, 13 Dec 2004 07:41:35 +0000 (07:41 +0000)
committerAlkis Evlogimenos <alkis@evlogimenos.com>
Mon, 13 Dec 2004 07:41:35 +0000 (07:41 +0000)
properly (examples: "", ".", "a").

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18883 91177308-0d34-0410-b5e6-96231b3b80d8

lib/System/Unix/Path.cpp
lib/System/Unix/Path.inc

index e655ef40cdf9d8d99af5ad0622389a207c93e526..4b5ccb934483d620935c4b80a75666cf2b11443a 100644 (file)
@@ -290,7 +290,7 @@ Path::setDirectory(const std::string& a_path) {
   Path save(*this);
   path = a_path;
   size_t last = a_path.size() -1;
-  if (last != 0 && a_path[last] != '/')
+  if (a_path.size() == 0 || a_path[last] != '/')
     path += '/';
   if (!isValid()) {
     path = save.path;
index e655ef40cdf9d8d99af5ad0622389a207c93e526..4b5ccb934483d620935c4b80a75666cf2b11443a 100644 (file)
@@ -290,7 +290,7 @@ Path::setDirectory(const std::string& a_path) {
   Path save(*this);
   path = a_path;
   size_t last = a_path.size() -1;
-  if (last != 0 && a_path[last] != '/')
+  if (a_path.size() == 0 || a_path[last] != '/')
     path += '/';
   if (!isValid()) {
     path = save.path;