From d8a620aff08e4282959049f2782496f42cc9cc5a Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Tue, 1 Oct 2024 09:48:07 +0200 Subject: [PATCH 1/2] Fix libdnf5::utils::patterns: Include missing headers --- include/libdnf5/utils/patterns.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/libdnf5/utils/patterns.hpp b/include/libdnf5/utils/patterns.hpp index d64da8b4e..db3ac816d 100644 --- a/include/libdnf5/utils/patterns.hpp +++ b/include/libdnf5/utils/patterns.hpp @@ -20,6 +20,9 @@ along with libdnf. If not, see . #ifndef LIBDNF5_UTILS_PATTERNS_HPP #define LIBDNF5_UTILS_PATTERNS_HPP +#include +#include + namespace libdnf5::utils { /// @brief Check if a given pattern is a GLOB. From df5a98017f143401b257f307bfda00b6303ada58 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Tue, 1 Oct 2024 10:09:57 +0200 Subject: [PATCH 2/2] libdnf5::utils::patterns: No inline API functions, mark noexcept --- include/libdnf5/utils/patterns.hpp | 13 ++++-------- libdnf5/utils/patterns.cpp | 34 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 libdnf5/utils/patterns.cpp diff --git a/include/libdnf5/utils/patterns.hpp b/include/libdnf5/utils/patterns.hpp index db3ac816d..cbeeb20f2 100644 --- a/include/libdnf5/utils/patterns.hpp +++ b/include/libdnf5/utils/patterns.hpp @@ -20,7 +20,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_UTILS_PATTERNS_HPP #define LIBDNF5_UTILS_PATTERNS_HPP -#include +#include "libdnf5/defs.h" + #include namespace libdnf5::utils { @@ -29,19 +30,13 @@ namespace libdnf5::utils { /// /// @param pattern Text pattern to be test /// @return True if a given pattern is a GLOB -inline bool is_glob_pattern(const char * pattern) { - return strpbrk(pattern, "*[?") != nullptr; -} - -/// Return true if given pattern is a file path +LIBDNF_API bool is_glob_pattern(const char * pattern) noexcept; /// @brief Check if a given pattern is a file path. /// /// @param pattern Text pattern to be test /// @return True if a given pattern is a file path -inline bool is_file_pattern(const std::string & pattern) { - return pattern[0] == '/' || (pattern[0] == '*' && pattern[1] == '/'); -} +LIBDNF_API bool is_file_pattern(const std::string & pattern) noexcept; } // namespace libdnf5::utils diff --git a/libdnf5/utils/patterns.cpp b/libdnf5/utils/patterns.cpp new file mode 100644 index 000000000..0ad551dcb --- /dev/null +++ b/libdnf5/utils/patterns.cpp @@ -0,0 +1,34 @@ +/* +Copyright Contributors to the libdnf project. + +This file is part of libdnf: https://github.com/rpm-software-management/libdnf/ + +Libdnf is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +Libdnf is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with libdnf. If not, see . +*/ + +#include "libdnf5/utils/patterns.hpp" + +#include + +namespace libdnf5::utils { + +bool is_glob_pattern(const char * pattern) noexcept { + return strpbrk(pattern, "*[?") != nullptr; +} + +bool is_file_pattern(const std::string & pattern) noexcept { + return pattern[0] == '/' || (pattern[0] == '*' && pattern[1] == '/'); +} + +} // namespace libdnf5::utils