diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/Traits.cxx | 10 | ||||
-rw-r--r-- | src/fs/Traits.hxx | 6 | ||||
-rw-r--r-- | src/storage/plugins/CurlStorage.cxx | 2 | ||||
-rw-r--r-- | src/storage/plugins/LocalStorage.cxx | 2 | ||||
-rw-r--r-- | src/storage/plugins/NfsStorage.cxx | 2 | ||||
-rw-r--r-- | src/storage/plugins/SmbclientStorage.cxx | 2 | ||||
-rw-r--r-- | src/storage/plugins/UdisksStorage.cxx | 2 |
7 files changed, 11 insertions, 15 deletions
diff --git a/src/fs/Traits.cxx b/src/fs/Traits.cxx index f31bcf7c1..fbd87bdce 100644 --- a/src/fs/Traits.cxx +++ b/src/fs/Traits.cxx @@ -86,10 +86,9 @@ GetParentPathImpl(typename Traits::const_pointer p) noexcept template<typename Traits> typename Traits::const_pointer -RelativePathImpl(typename Traits::const_pointer base, +RelativePathImpl(typename Traits::string_view base, typename Traits::const_pointer other) noexcept { - assert(base != nullptr); assert(other != nullptr); other = StringAfterPrefix(other, base); @@ -99,7 +98,7 @@ RelativePathImpl(typename Traits::const_pointer base, if (*other != 0) { if (!Traits::IsSeparator(*other)) { - if (*base != 0 && Traits::IsSeparator(other[-1])) + if (!base.empty() && Traits::IsSeparator(other[-1])) /* "other" has no more slash, but the matching base ended with a slash: enough to detect a match */ @@ -137,7 +136,7 @@ PathTraitsFS::GetParent(PathTraitsFS::const_pointer p) noexcept } PathTraitsFS::const_pointer -PathTraitsFS::Relative(const_pointer base, const_pointer other) noexcept +PathTraitsFS::Relative(string_view base, const_pointer other) noexcept { return RelativePathImpl<PathTraitsFS>(base, other); } @@ -175,8 +174,7 @@ PathTraitsUTF8::GetParent(const_pointer p) noexcept } PathTraitsUTF8::const_pointer -PathTraitsUTF8::Relative(const_pointer base, - const_pointer other) noexcept +PathTraitsUTF8::Relative(string_view base, const_pointer other) noexcept { return RelativePathImpl<PathTraitsUTF8>(base, other); } diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx index 4e8f105a1..d2e5f83b0 100644 --- a/src/fs/Traits.hxx +++ b/src/fs/Traits.hxx @@ -147,8 +147,7 @@ struct PathTraitsFS { * nullptr on mismatch. */ gcc_pure gcc_nonnull_all - static const_pointer Relative(const_pointer base, - const_pointer other) noexcept; + static const_pointer Relative(string_view base, const_pointer other) noexcept; /** * Constructs the path from the given components. @@ -256,8 +255,7 @@ struct PathTraitsUTF8 { * nullptr on mismatch. */ gcc_pure gcc_nonnull_all - static const_pointer Relative(const_pointer base, - const_pointer other) noexcept; + static const_pointer Relative(string_view base, const_pointer other) noexcept; /** * Constructs the path from the given components. diff --git a/src/storage/plugins/CurlStorage.cxx b/src/storage/plugins/CurlStorage.cxx index edb3b8f6b..9dca427d2 100644 --- a/src/storage/plugins/CurlStorage.cxx +++ b/src/storage/plugins/CurlStorage.cxx @@ -81,7 +81,7 @@ CurlStorage::MapUTF8(const char *uri_utf8) const noexcept const char * CurlStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept { - return PathTraitsUTF8::Relative(base.c_str(), + return PathTraitsUTF8::Relative(base, CurlUnescape(uri_utf8).c_str()); } diff --git a/src/storage/plugins/LocalStorage.cxx b/src/storage/plugins/LocalStorage.cxx index 336161043..a53e19a39 100644 --- a/src/storage/plugins/LocalStorage.cxx +++ b/src/storage/plugins/LocalStorage.cxx @@ -129,7 +129,7 @@ LocalStorage::MapFS(const char *uri_utf8) const noexcept const char * LocalStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept { - return PathTraitsUTF8::Relative(base_utf8.c_str(), uri_utf8); + return PathTraitsUTF8::Relative(base_utf8, uri_utf8); } StorageFileInfo diff --git a/src/storage/plugins/NfsStorage.cxx b/src/storage/plugins/NfsStorage.cxx index a116d5591..0d73c0235 100644 --- a/src/storage/plugins/NfsStorage.cxx +++ b/src/storage/plugins/NfsStorage.cxx @@ -246,7 +246,7 @@ NfsStorage::MapUTF8(const char *uri_utf8) const noexcept const char * NfsStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept { - return PathTraitsUTF8::Relative(base.c_str(), uri_utf8); + return PathTraitsUTF8::Relative(base, uri_utf8); } static void diff --git a/src/storage/plugins/SmbclientStorage.cxx b/src/storage/plugins/SmbclientStorage.cxx index ad08c9eb3..6302555e1 100644 --- a/src/storage/plugins/SmbclientStorage.cxx +++ b/src/storage/plugins/SmbclientStorage.cxx @@ -87,7 +87,7 @@ SmbclientStorage::MapUTF8(const char *uri_utf8) const noexcept const char * SmbclientStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept { - return PathTraitsUTF8::Relative(base.c_str(), uri_utf8); + return PathTraitsUTF8::Relative(base, uri_utf8); } static StorageFileInfo diff --git a/src/storage/plugins/UdisksStorage.cxx b/src/storage/plugins/UdisksStorage.cxx index 2c280e0af..c888662bb 100644 --- a/src/storage/plugins/UdisksStorage.cxx +++ b/src/storage/plugins/UdisksStorage.cxx @@ -347,7 +347,7 @@ UdisksStorage::MapUTF8(const char *uri_utf8) const noexcept const char * UdisksStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept { - return PathTraitsUTF8::Relative(base_uri.c_str(), uri_utf8); + return PathTraitsUTF8::Relative(base_uri, uri_utf8); } static std::unique_ptr<Storage> |