[Libreoffice-commits] core.git: 2 commits - sal/osl
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Thu Sep 5 14:40:26 UTC 2019
sal/osl/unx/file_path_helper.cxx | 33 ++++++++++++++++-----------------
sal/osl/unx/file_path_helper.hxx | 7 +++----
2 files changed, 19 insertions(+), 21 deletions(-)
New commits:
commit 4e9714d2870ce02abe552a41e6278678265b9df9
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Sep 5 12:17:07 2019 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Sep 5 16:39:21 2019 +0200
Fix osl_systemPathEnsureSeparator precondition
Change-Id: I0165a14f159a6c2c7bce84d1ca646435146d1da0
Reviewed-on: https://gerrit.libreoffice.org/78643
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sal/osl/unx/file_path_helper.cxx b/sal/osl/unx/file_path_helper.cxx
index 2f70c3687eda..b75070c304ca 100644
--- a/sal/osl/unx/file_path_helper.cxx
+++ b/sal/osl/unx/file_path_helper.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cassert>
+
#include "file_path_helper.hxx"
#include "uunxapi.hxx"
@@ -56,21 +60,18 @@ void osl_systemPathRemoveSeparator(rtl_uString* pustrPath)
void osl_systemPathEnsureSeparator(OUString* ppustrPath)
{
- OSL_PRECOND(nullptr != ppustrPath, "osl_systemPathEnsureSeparator: Invalid parameter");
- if (ppustrPath != nullptr)
- {
- sal_Int32 lp = ppustrPath->getLength();
- sal_Int32 i = ppustrPath->lastIndexOf(FPH_CHAR_PATH_SEPARATOR);
+ assert(nullptr != ppustrPath);
+ sal_Int32 lp = ppustrPath->getLength();
+ sal_Int32 i = ppustrPath->lastIndexOf(FPH_CHAR_PATH_SEPARATOR);
- if ((lp > 1 && i != (lp - 1)) || ((lp < 2) && i < 0))
- {
- *ppustrPath += FPH_PATH_SEPARATOR;
- }
-
- SAL_WARN_IF( !ppustrPath->endsWith(FPH_PATH_SEPARATOR),
- "sal.osl",
- "osl_systemPathEnsureSeparator: Post condition failed");
+ if ((lp > 1 && i != (lp - 1)) || ((lp < 2) && i < 0))
+ {
+ *ppustrPath += FPH_PATH_SEPARATOR;
}
+
+ SAL_WARN_IF( !ppustrPath->endsWith(FPH_PATH_SEPARATOR),
+ "sal.osl",
+ "osl_systemPathEnsureSeparator: Post condition failed");
}
bool osl_systemPathIsRelativePath(const rtl_uString* pustrPath)
commit 078d5c629ed9ad48b8e6bc4bd73e077a024fdef1
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Sep 5 12:14:33 2019 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Sep 5 16:39:10 2019 +0200
Let osl_systemPathEnsureSeparator directly take an OUString
Change-Id: Ia9505298fe92d62d716e2c28ac0a5098c4b61121
Reviewed-on: https://gerrit.libreoffice.org/78642
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sal/osl/unx/file_path_helper.cxx b/sal/osl/unx/file_path_helper.cxx
index a89e00bf76ed..2f70c3687eda 100644
--- a/sal/osl/unx/file_path_helper.cxx
+++ b/sal/osl/unx/file_path_helper.cxx
@@ -54,22 +54,20 @@ void osl_systemPathRemoveSeparator(rtl_uString* pustrPath)
}
}
-void osl_systemPathEnsureSeparator(rtl_uString** ppustrPath)
+void osl_systemPathEnsureSeparator(OUString* ppustrPath)
{
- OSL_PRECOND((nullptr != ppustrPath) && (nullptr != *ppustrPath), "osl_systemPathEnsureSeparator: Invalid parameter");
- if ((ppustrPath != nullptr) && (*ppustrPath != nullptr))
+ OSL_PRECOND(nullptr != ppustrPath, "osl_systemPathEnsureSeparator: Invalid parameter");
+ if (ppustrPath != nullptr)
{
- OUString path(*ppustrPath);
- sal_Int32 lp = path.getLength();
- sal_Int32 i = path.lastIndexOf(FPH_CHAR_PATH_SEPARATOR);
+ sal_Int32 lp = ppustrPath->getLength();
+ sal_Int32 i = ppustrPath->lastIndexOf(FPH_CHAR_PATH_SEPARATOR);
if ((lp > 1 && i != (lp - 1)) || ((lp < 2) && i < 0))
{
- path += FPH_PATH_SEPARATOR;
- rtl_uString_assign(ppustrPath, path.pData);
+ *ppustrPath += FPH_PATH_SEPARATOR;
}
- SAL_WARN_IF( !path.endsWith(FPH_PATH_SEPARATOR),
+ SAL_WARN_IF( !ppustrPath->endsWith(FPH_PATH_SEPARATOR),
"sal.osl",
"osl_systemPathEnsureSeparator: Post condition failed");
}
@@ -90,7 +88,7 @@ void osl_systemPathMakeAbsolutePath(
OUString rel(const_cast<rtl_uString*>(pustrRelPath));
if (!base.isEmpty())
- osl_systemPathEnsureSeparator(&base.pData);
+ osl_systemPathEnsureSeparator(&base);
base += rel;
diff --git a/sal/osl/unx/file_path_helper.hxx b/sal/osl/unx/file_path_helper.hxx
index 18af761cb310..0f09ccac2025 100644
--- a/sal/osl/unx/file_path_helper.hxx
+++ b/sal/osl/unx/file_path_helper.hxx
@@ -44,13 +44,12 @@ void osl_systemPathRemoveSeparator(rtl_uString* pustrPath);
@param pustrPath [inout] a system path if the path is not the root path
'/' and has no trailing separator a separator
- will be added ppustrPath must not be NULL and
- must point to a valid rtl_uString
+ will be added ppustrPath must not be NULL
@returns nothing
*/
-void osl_systemPathEnsureSeparator(rtl_uString** ppustrPath);
+void osl_systemPathEnsureSeparator(OUString* ppustrPath);
/**
Returns true if the given path is a relative path and so starts not with '/'
@@ -208,7 +207,7 @@ namespace osl
inline void systemPathEnsureSeparator(/*inout*/ OUString& Path)
{
- osl_systemPathEnsureSeparator(&Path.pData);
+ osl_systemPathEnsureSeparator(&Path);
}
/*******************************************
More information about the Libreoffice-commits
mailing list