From 97f7132b822d0b36cbd47690fa4558480d4a7755 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sat, 10 Jul 2021 13:19:47 +0430 Subject: [PATCH] expr: Use Basic Posix regular expressions Dr.POSIX requires expr to use BREs, so let's use BREs. Fixes #8506. --- Userland/Utilities/expr.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Userland/Utilities/expr.cpp b/Userland/Utilities/expr.cpp index d8371d5318..253adce1c9 100644 --- a/Userland/Utilities/expr.cpp +++ b/Userland/Utilities/expr.cpp @@ -441,14 +441,17 @@ private: void ensure_regex() const { - if (!m_compiled_regex) - m_compiled_regex = make>(m_pos_or_chars->string()); + if (!m_compiled_regex) { + m_compiled_regex = make>(m_pos_or_chars->string()); + if (m_compiled_regex->parser_result.error != regex::Error::NoError) + fail("Regex error: {}", regex::get_error_string(m_compiled_regex->parser_result.error)); + } } StringOperation m_op { StringOperation::Substring }; NonnullOwnPtr m_str; OwnPtr m_pos_or_chars, m_length; - mutable OwnPtr> m_compiled_regex; + mutable OwnPtr> m_compiled_regex; }; NonnullOwnPtr Expression::parse(Queue& args, Precedence prec)