diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C index d888ccfcb891d595f36006f67f58438484d47222..55fa68cbe93dabd1a000a42088132eaa12055fce 100644 --- a/src/OSspecific/POSIX/POSIX.C +++ b/src/OSspecific/POSIX/POSIX.C @@ -99,16 +99,24 @@ static inline Foam::fileName fileNameConcat if (b.size()) { // Two non-empty strings: can concatenate - return Foam::fileName((a + '/' + b), false); + + if (a.back() == '/' || b.front() == '/') + { + return Foam::fileName(a + b, false); + } + else + { + return Foam::fileName(a + '/' + b, false); + } } + // The second string was empty return Foam::fileName(a, false); } - // Or, if the first string is empty - if (b.size()) { + // The first string is empty return Foam::fileName(b, false); } @@ -1586,21 +1594,22 @@ int Foam::system(const Foam::UList<Foam::string>& command, const bool bg) } -void* Foam::dlOpen(const fileName& lib, const bool check) +void* Foam::dlOpen(const fileName& libName, const bool check) { if (POSIX::debug) { - std::cout<< "dlOpen(const fileName&)" - << " : dlopen of " << lib << std::endl; + std::cout + << "dlOpen(const fileName&)" + << " : dlopen of " << libName << std::endl; } - void* handle = ::dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL); + void* handle = ::dlopen(libName.c_str(), RTLD_LAZY|RTLD_GLOBAL); #ifdef darwin // Re-try "libXX.so" as "libXX.dylib" - if (!handle && lib.hasExt("so")) + if (!handle && libName.hasExt("so")) { - const fileName dylib(lib.lessExt().ext("dylib")); - handle = ::dlopen(dylib.c_str(), RTLD_LAZY|RTLD_GLOBAL); + const fileName dylibName(libName.lessExt().ext("dylib")); + handle = ::dlopen(dylibName.c_str(), RTLD_LAZY|RTLD_GLOBAL); } #endif @@ -1615,7 +1624,7 @@ void* Foam::dlOpen(const fileName& lib, const bool check) { std::cout << "dlOpen(const fileName&)" - << " : dlopen of " << lib + << " : dlopen of " << libName << " handle " << handle << std::endl; } diff --git a/src/OSspecific/POSIX/POSIX.H b/src/OSspecific/POSIX/POSIX.H index 1963c5546ac2a5a3500c1d47b415b1996e03143c..855ccffc01678476f70130ac7bb0b8cee708ee3b 100644 --- a/src/OSspecific/POSIX/POSIX.H +++ b/src/OSspecific/POSIX/POSIX.H @@ -48,7 +48,7 @@ namespace Foam namespace POSIX { - //- Declare name of the class and its debug switch + //- Declare namespace and its debug switch NamespaceName("POSIX"); const label pathLengthChunk = 256; diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.C b/src/OpenFOAM/primitives/strings/fileName/fileName.C index e0ec203ae6ba0538d9f8e1f51b8796d29df13f61..7002ebd7a24363f93a97f1b5f376c42a21e8a12c 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.C +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.C @@ -495,7 +495,8 @@ Foam::fileName Foam::operator/(const string& a, const string& b) } } - return a; // The second string was empty + // The second string was empty + return a; } if (b.size())