diff options
author | geek <geek@yandex-team.ru> | 2022-02-10 16:49:34 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:34 +0300 |
commit | 62bad8df5b890e3012b8949bcf6d2e885ce8972c (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 | |
parent | 3edcc3fb0098c02c36c44dfcc0d0dfe4224639c9 (diff) | |
download | ydb-62bad8df5b890e3012b8949bcf6d2e885ce8972c.tar.gz |
Restoring authorship annotation for <geek@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | library/cpp/regex/pcre/regexp.cpp | 100 | ||||
-rw-r--r-- | library/cpp/regex/pcre/regexp.h | 8 | ||||
-rw-r--r-- | util/system/error.cpp | 2 |
3 files changed, 55 insertions, 55 deletions
diff --git a/library/cpp/regex/pcre/regexp.cpp b/library/cpp/regex/pcre/regexp.cpp index 8e743d4ff2..575c09cee4 100644 --- a/library/cpp/regex/pcre/regexp.cpp +++ b/library/cpp/regex/pcre/regexp.cpp @@ -131,73 +131,73 @@ private: }; class TRegExBaseImpl: public TAtomicRefCount<TRegExBaseImpl> { - friend class TRegExBase; - -protected: + friend class TRegExBase; + +protected: int CompileOptions; TString RegExpr; regex_t Preg; -public: - TRegExBaseImpl() - : CompileOptions(0) - { - memset(&Preg, 0, sizeof(Preg)); - } - +public: + TRegExBaseImpl() + : CompileOptions(0) + { + memset(&Preg, 0, sizeof(Preg)); + } + TRegExBaseImpl(const TString& re, int cflags) - : CompileOptions(cflags) - , RegExpr(re) - { + : CompileOptions(cflags) + , RegExpr(re) + { int rc = regcomp(&Preg, re.data(), cflags); - if (rc) { - const size_t ERRBUF_SIZE = 100; - char errbuf[ERRBUF_SIZE]; - regerror(rc, &Preg, errbuf, ERRBUF_SIZE); + if (rc) { + const size_t ERRBUF_SIZE = 100; + char errbuf[ERRBUF_SIZE]; + regerror(rc, &Preg, errbuf, ERRBUF_SIZE); Error = "Error: regular expression " + re + " is wrong: " + errbuf; ythrow yexception() << "RegExp " << re << ": " << Error.data(); } } - + int Exec(const char* str, regmatch_t pmatch[], int eflags, int nmatches) const { - if (!RegExpr) { + if (!RegExpr) { ythrow yexception() << "Regular expression is not compiled"; - } - if (!str) { + } + if (!str) { ythrow yexception() << "Empty string is passed to TRegExBaseImpl::Exec"; - } - if ((eflags & REGEXP_GLOBAL) == 0) { - return regexec(&Preg, str, nmatches, pmatch, eflags); - } else { - int options = 0; + } + if ((eflags & REGEXP_GLOBAL) == 0) { + return regexec(&Preg, str, nmatches, pmatch, eflags); + } else { + int options = 0; if ((eflags & REG_NOTBOL) != 0) options |= PCRE_NOTBOL; if ((eflags & REG_NOTEOL) != 0) options |= PCRE_NOTEOL; - + return TGlobalImpl(str, pmatch[0], options, (pcre*)Preg.re_pcre).ExecGlobal(); - } - } - - bool IsCompiled() { - return Preg.re_pcre; - } - - ~TRegExBaseImpl() { - regfree(&Preg); - } - -private: + } + } + + bool IsCompiled() { + return Preg.re_pcre; + } + + ~TRegExBaseImpl() { + regfree(&Preg); + } + +private: TString Error; -}; - -bool TRegExBase::IsCompiled() const { +}; + +bool TRegExBase::IsCompiled() const { return Impl && Impl->IsCompiled(); } TRegExBase::TRegExBase(const char* re, int cflags) { - if (re) { - Compile(re, cflags); + if (re) { + Compile(re, cflags); } } @@ -209,25 +209,25 @@ TRegExBase::~TRegExBase() { } void TRegExBase::Compile(const TString& re, int cflags) { - Impl = new TRegExBaseImpl(re, cflags); -} + Impl = new TRegExBaseImpl(re, cflags); +} int TRegExBase::Exec(const char* str, regmatch_t pmatch[], int eflags, int nmatches) const { if (!Impl) ythrow yexception() << "!Regular expression is not compiled"; - return Impl->Exec(str, pmatch, eflags, nmatches); + return Impl->Exec(str, pmatch, eflags, nmatches); } int TRegExBase::GetCompileOptions() const { if (!Impl) ythrow yexception() << "!Regular expression is not compiled"; - return Impl->CompileOptions; + return Impl->CompileOptions; } TString TRegExBase::GetRegExpr() const { if (!Impl) ythrow yexception() << "!Regular expression is not compiled"; - return Impl->RegExpr; + return Impl->RegExpr; } TRegExMatch::TRegExMatch(const char* re, int cflags) @@ -270,7 +270,7 @@ TString TRegExSubst::Replace(const char* str, int eflags) { } //*** -// ��� ������������ ������ aaa.$1.$$$$.$2.bbb.$$$ccc Brfs ����� �����: +// ��� ������������ ������ aaa.$1.$$$$.$2.bbb.$$$ccc Brfs ����� �����: // {beg = 0, end = 4, Refer = 1} => "aaa." + $1_match // {beg = 6, end = 8, Refer = -1} => ".$" // {beg = 9, end = 10, Refer = -1} => "$" diff --git a/library/cpp/regex/pcre/regexp.h b/library/cpp/regex/pcre/regexp.h index d39ce80fa0..bc610bd2f3 100644 --- a/library/cpp/regex/pcre/regexp.h +++ b/library/cpp/regex/pcre/regexp.h @@ -14,8 +14,8 @@ #define NMATCHES 100 #define REGEXP_GLOBAL 0x0080 // use this if you want to find all occurences -class TRegExBaseImpl; - +class TRegExBaseImpl; + class TRegExBase { protected: TSimpleIntrusivePtr<TRegExBaseImpl> Impl; @@ -24,11 +24,11 @@ public: TRegExBase(const char* regExpr = nullptr, int cflags = REG_EXTENDED); TRegExBase(const TString& regExpr, int cflags = REG_EXTENDED); - virtual ~TRegExBase(); + virtual ~TRegExBase(); int Exec(const char* str, regmatch_t pmatch[], int eflags, int nmatches = NMATCHES) const; void Compile(const TString& regExpr, int cflags = REG_EXTENDED); - bool IsCompiled() const; + bool IsCompiled() const; int GetCompileOptions() const; TString GetRegExpr() const; }; diff --git a/util/system/error.cpp b/util/system/error.cpp index 7eece9c3ec..f778ec42cb 100644 --- a/util/system/error.cpp +++ b/util/system/error.cpp @@ -20,7 +20,7 @@ void ClearLastSystemError() { #if defined(_win_) SetLastError(0); #else - errno = 0; + errno = 0; #endif } |