From 9123176b341b6f2658cff5132482b8237c1416c8 Mon Sep 17 00:00:00 2001 From: Ruslan Kovalev <ruslan.a.kovalev@gmail.com> Date: Thu, 10 Feb 2022 16:46:45 +0300 Subject: Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 2 of 2. --- library/cpp/regex/pire/regexp.h | 28 +++++++-------- library/cpp/regex/pire/ut/regexp_ut.cpp | 62 ++++++++++++++++----------------- 2 files changed, 45 insertions(+), 45 deletions(-) (limited to 'library/cpp/regex/pire') diff --git a/library/cpp/regex/pire/regexp.h b/library/cpp/regex/pire/regexp.h index 7e4e3bd9ca..94bba4064b 100644 --- a/library/cpp/regex/pire/regexp.h +++ b/library/cpp/regex/pire/regexp.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "pire.h" @@ -35,16 +35,16 @@ namespace NRegExp { return *this; } - inline TOptions& SetAndNotSupport(bool andNotSupport) noexcept { - AndNotSupport = andNotSupport; - return *this; - } - - bool CaseInsensitive = false; - bool Surround = false; + inline TOptions& SetAndNotSupport(bool andNotSupport) noexcept { + AndNotSupport = andNotSupport; + return *this; + } + + bool CaseInsensitive = false; + bool Surround = false; TMaybe<size_t> CapturePos; - ECharset Charset = CODES_UNKNOWN; - bool AndNotSupport = false; + ECharset Charset = CODES_UNKNOWN; + bool AndNotSupport = false; }; static inline NPire::TFsm Parse(const TStringBuf& regexp, @@ -74,10 +74,10 @@ namespace NRegExp { lexer.AddFeature(NPire::NFeatures::Capture(*opts.CapturePos)); } - if (opts.AndNotSupport) { - lexer.AddFeature(NPire::NFeatures::AndNotSupport()); - } - + if (opts.AndNotSupport) { + lexer.AddFeature(NPire::NFeatures::AndNotSupport()); + } + switch (opts.Charset) { case CODES_UNKNOWN: break; diff --git a/library/cpp/regex/pire/ut/regexp_ut.cpp b/library/cpp/regex/pire/ut/regexp_ut.cpp index 96b92bbc38..e7206de9ad 100644 --- a/library/cpp/regex/pire/ut/regexp_ut.cpp +++ b/library/cpp/regex/pire/ut/regexp_ut.cpp @@ -52,37 +52,37 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT(!TMatcher(TFsm("чзн", opts)).Match("чзх").Final()); } - Y_UNIT_TEST(AndNot) { - NRegExp::TFsmBase::TOptions opts; - opts.AndNotSupport = true; - { - NRegExp::TFsm fsm(".*&~([0-9]*)", opts); - UNIT_ASSERT(TMatcher(fsm).Match("a2").Final()); - UNIT_ASSERT(TMatcher(fsm).Match("ab").Final()); - UNIT_ASSERT(TMatcher(fsm).Match("1a").Final()); - UNIT_ASSERT(!TMatcher(fsm).Match("12").Final()); - } - { - NRegExp::TFsm fsm(".*&~(.*[0-9].*)", opts); - UNIT_ASSERT(TMatcher(fsm).Match("ab").Final()); - UNIT_ASSERT(!TMatcher(fsm).Match("a2").Final()); - UNIT_ASSERT(!TMatcher(fsm).Match("1a").Final()); - UNIT_ASSERT(!TMatcher(fsm).Match("12").Final()); - } - { - NRegExp::TFsm fsm( - "((([a-z0-9_\\-]+[.])*[a-z0-9_\\-]+)" - "&~(\\d+[.]\\d+[.]\\d+[.]\\d+))(:\\d+)?", - TFsm::TOptions().SetCaseInsensitive(true).SetAndNotSupport(true) - ); - UNIT_ASSERT(TMatcher(fsm).Match("yandex.ru").Final()); - UNIT_ASSERT(TMatcher(fsm).Match("yandex").Final()); - UNIT_ASSERT(TMatcher(fsm).Match("yandex:80").Final()); - UNIT_ASSERT(!TMatcher(fsm).Match("127.0.0.1").Final()); - UNIT_ASSERT(!TMatcher(fsm).Match("127.0.0.1:8080").Final()); - } - } - + Y_UNIT_TEST(AndNot) { + NRegExp::TFsmBase::TOptions opts; + opts.AndNotSupport = true; + { + NRegExp::TFsm fsm(".*&~([0-9]*)", opts); + UNIT_ASSERT(TMatcher(fsm).Match("a2").Final()); + UNIT_ASSERT(TMatcher(fsm).Match("ab").Final()); + UNIT_ASSERT(TMatcher(fsm).Match("1a").Final()); + UNIT_ASSERT(!TMatcher(fsm).Match("12").Final()); + } + { + NRegExp::TFsm fsm(".*&~(.*[0-9].*)", opts); + UNIT_ASSERT(TMatcher(fsm).Match("ab").Final()); + UNIT_ASSERT(!TMatcher(fsm).Match("a2").Final()); + UNIT_ASSERT(!TMatcher(fsm).Match("1a").Final()); + UNIT_ASSERT(!TMatcher(fsm).Match("12").Final()); + } + { + NRegExp::TFsm fsm( + "((([a-z0-9_\\-]+[.])*[a-z0-9_\\-]+)" + "&~(\\d+[.]\\d+[.]\\d+[.]\\d+))(:\\d+)?", + TFsm::TOptions().SetCaseInsensitive(true).SetAndNotSupport(true) + ); + UNIT_ASSERT(TMatcher(fsm).Match("yandex.ru").Final()); + UNIT_ASSERT(TMatcher(fsm).Match("yandex").Final()); + UNIT_ASSERT(TMatcher(fsm).Match("yandex:80").Final()); + UNIT_ASSERT(!TMatcher(fsm).Match("127.0.0.1").Final()); + UNIT_ASSERT(!TMatcher(fsm).Match("127.0.0.1:8080").Final()); + } + } + Y_UNIT_TEST(Glue) { TFsm glued = TFsm("qw", TFsm::TOptions().SetCaseInsensitive(true)) | -- cgit v1.2.3