From 98415533ea2d9a8e7dd9cb16ae4bccc15224b29d Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Wed, 24 Jul 2024 02:10:57 -0400 Subject: [PATCH] Apply suggestions from code review Co-authored-by: davidlion --- components/core/src/clp/regex_utils/constants.hpp | 11 ++++++----- .../src/clp/regex_utils/regex_translation_utils.cpp | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/core/src/clp/regex_utils/constants.hpp b/components/core/src/clp/regex_utils/constants.hpp index 83ba3fabd..9833543fc 100644 --- a/components/core/src/clp/regex_utils/constants.hpp +++ b/components/core/src/clp/regex_utils/constants.hpp @@ -38,11 +38,12 @@ constexpr char cEscapeChar{'\\'}; constexpr char cCharsetNegate{'^'}; // Character bitmaps -// The set of characters that can be preceded with an escape backslash. When escaped, these -// characters are used as literals. -constexpr auto cRegexEscapeSeqMetaCharsLUT = create_char_bit_array("*+?|^$.{}[]()<>-_/=!\\"); -// The set of metacharacters that need to be escaped in the wildcard syntax. -constexpr auto cWildcardMetaCharsLUT = create_char_bit_array("?*\\"); +// The set of regex metacharacters that can be preceded with an escape backslash to be treated as a +// literal. +constexpr auto cRegexEscapeSeqMetaCharsLut = create_char_bit_array("*+?|^$.{}[]()<>-_/=!\\"); +// The set of wildcard metacharacters that must remain escaped in the translated string to be +// treated as a literal. +constexpr auto cWildcardMetaCharsLut = create_char_bit_array("?*\\"); } // namespace clp::regex_utils #endif // CLP_REGEX_UTILS_CONSTANTS_HPP diff --git a/components/core/src/clp/regex_utils/regex_translation_utils.cpp b/components/core/src/clp/regex_utils/regex_translation_utils.cpp index 9f153aae0..61f8481f2 100644 --- a/components/core/src/clp/regex_utils/regex_translation_utils.cpp +++ b/components/core/src/clp/regex_utils/regex_translation_utils.cpp @@ -179,10 +179,10 @@ auto escaped_state_transition( [[maybe_unused]] RegexToWildcardTranslatorConfig const& config ) -> error_code { auto const ch{*it}; - if (false == cRegexEscapeSeqMetaCharsLUT.at(ch)) { + if (false == cRegexEscapeSeqMetaCharsLut.at(ch)) { return ErrorCode::IllegalEscapeSequence; } - if (cWildcardMetaCharsLUT.at(ch)) { + if (cWildcardMetaCharsLut.at(ch)) { wildcard_str = wildcard_str + cEscapeChar + ch; } else { wildcard_str += ch;