aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgaltsev <galtsev@yandex-team.ru>2022-02-10 16:49:32 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:32 +0300
commitb3770c4662dc5be7135e21630d44f69d0787c167 (patch)
treee8fca9ae46f702aa7e1d2a7fdb3d4e969ae2aff7
parentd6a9908bd3435a3571dfcb969988eba7a690802b (diff)
downloadydb-b3770c4662dc5be7135e21630d44f69d0787c167.tar.gz
Restoring authorship annotation for <galtsev@yandex-team.ru>. Commit 1 of 2.
-rw-r--r--library/cpp/regex/hyperscan/hyperscan.h4
-rw-r--r--library/cpp/regex/pire/ut/regexp_ut.cpp110
-rw-r--r--library/cpp/regex/pire/ut/ya.make2
-rw-r--r--library/cpp/regex/pire/ya.make4
-rw-r--r--util/string/cast_ut.cpp2
-rw-r--r--util/system/mutex.cpp2
-rw-r--r--util/system/rwlock.cpp140
-rw-r--r--util/system/rwlock.h4
8 files changed, 134 insertions, 134 deletions
diff --git a/library/cpp/regex/hyperscan/hyperscan.h b/library/cpp/regex/hyperscan/hyperscan.h
index 1c8f404389..f116d683d8 100644
--- a/library/cpp/regex/hyperscan/hyperscan.h
+++ b/library/cpp/regex/hyperscan/hyperscan.h
@@ -123,8 +123,8 @@ namespace NHyperscan {
TDatabase CompileMulti(
const TVector<const char*>& regexs,
const TVector<unsigned int>& flags,
- const TVector<unsigned int>& ids,
- const TVector<const hs_expr_ext_t*>* extendedParameters = nullptr);
+ const TVector<unsigned int>& ids,
+ const TVector<const hs_expr_ext_t*>* extendedParameters = nullptr);
TDatabase CompileMulti(
const TVector<const char*>& regexs,
diff --git a/library/cpp/regex/pire/ut/regexp_ut.cpp b/library/cpp/regex/pire/ut/regexp_ut.cpp
index e7206de9ad..90fdcc4a2c 100644
--- a/library/cpp/regex/pire/ut/regexp_ut.cpp
+++ b/library/cpp/regex/pire/ut/regexp_ut.cpp
@@ -156,66 +156,66 @@ Y_UNIT_TEST_SUITE(TRegExp) {
//UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("pref bla suff"));
}
- Y_UNIT_TEST(CaptureXA) {
- TCapturingFsm fsm(".*(xa).*");
-
- TSearcher searcher(fsm);
- searcher.Search("xa");
- UNIT_ASSERT(searcher.Captured());
+ Y_UNIT_TEST(CaptureXA) {
+ TCapturingFsm fsm(".*(xa).*");
+
+ TSearcher searcher(fsm);
+ searcher.Search("xa");
+ UNIT_ASSERT(searcher.Captured());
UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("xa"));
- }
-
- Y_UNIT_TEST(CaptureWrongXX) {
- TCapturingFsm fsm(".*(xx).*");
-
- TSearcher searcher(fsm);
- searcher.Search("xx");
- UNIT_ASSERT(searcher.Captured());
- // Surprise!
- // TCapturingFsm uses a fast - O(|text|) - but incorrect algorithm.
- // It works more or less for a particular class of regexps to which ".*(xx).*" does not belong.
- // So it returns not the expected "xx" but just the second "x" instead.
+ }
+
+ Y_UNIT_TEST(CaptureWrongXX) {
+ TCapturingFsm fsm(".*(xx).*");
+
+ TSearcher searcher(fsm);
+ searcher.Search("xx");
+ UNIT_ASSERT(searcher.Captured());
+ // Surprise!
+ // TCapturingFsm uses a fast - O(|text|) - but incorrect algorithm.
+ // It works more or less for a particular class of regexps to which ".*(xx).*" does not belong.
+ // So it returns not the expected "xx" but just the second "x" instead.
UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("x"));
- }
-
- Y_UNIT_TEST(CaptureRight1XX) {
- TCapturingFsm fsm("[^x]+(xx).*");
-
- TSearcher searcher(fsm);
-
- searcher.Search("xxx");
- UNIT_ASSERT(!searcher.Captured());
- }
-
- Y_UNIT_TEST(CaptureRight2XX) {
- TCapturingFsm fsm("[^x]+(xx).*");
-
- TSearcher searcher(fsm);
-
- searcher.Search("axx");
- UNIT_ASSERT(searcher.Captured());
+ }
+
+ Y_UNIT_TEST(CaptureRight1XX) {
+ TCapturingFsm fsm("[^x]+(xx).*");
+
+ TSearcher searcher(fsm);
+
+ searcher.Search("xxx");
+ UNIT_ASSERT(!searcher.Captured());
+ }
+
+ Y_UNIT_TEST(CaptureRight2XX) {
+ TCapturingFsm fsm("[^x]+(xx).*");
+
+ TSearcher searcher(fsm);
+
+ searcher.Search("axx");
+ UNIT_ASSERT(searcher.Captured());
UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("xx"));
- }
-
- Y_UNIT_TEST(CaptureRight3XX) {
- TCapturingFsm fsm("[^x]+(xx).*");
-
- TSearcher searcher(fsm);
-
- searcher.Search("axxb");
- UNIT_ASSERT(searcher.Captured());
+ }
+
+ Y_UNIT_TEST(CaptureRight3XX) {
+ TCapturingFsm fsm("[^x]+(xx).*");
+
+ TSearcher searcher(fsm);
+
+ searcher.Search("axxb");
+ UNIT_ASSERT(searcher.Captured());
UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("xx"));
- }
-
- Y_UNIT_TEST(SlowCaptureXX) {
- TSlowCapturingFsm fsm(".*(xx).*");
-
- TSlowSearcher searcher(fsm);
- searcher.Search("xx");
- UNIT_ASSERT(searcher.Captured());
+ }
+
+ Y_UNIT_TEST(SlowCaptureXX) {
+ TSlowCapturingFsm fsm(".*(xx).*");
+
+ TSlowSearcher searcher(fsm);
+ searcher.Search("xx");
+ UNIT_ASSERT(searcher.Captured());
UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("xx"));
- }
-
+ }
+
Y_UNIT_TEST(SlowCapture) {
TSlowCapturingFsm fsm("^http://vk(ontakte[.]ru|[.]com)/id(\\d+)([^0-9]|$)",
TFsm::TOptions().SetCapture(2));
diff --git a/library/cpp/regex/pire/ut/ya.make b/library/cpp/regex/pire/ut/ya.make
index 8776695f40..212901e911 100644
--- a/library/cpp/regex/pire/ut/ya.make
+++ b/library/cpp/regex/pire/ut/ya.make
@@ -28,7 +28,7 @@ SRCS(
pire_ut.cpp
capture_ut.cpp
count_ut.cpp
- glyph_ut.cpp
+ glyph_ut.cpp
easy_ut.cpp
read_unicode_ut.cpp
regexp_ut.cpp
diff --git a/library/cpp/regex/pire/ya.make b/library/cpp/regex/pire/ya.make
index c857e6d18b..50857fc11d 100644
--- a/library/cpp/regex/pire/ya.make
+++ b/library/cpp/regex/pire/ya.make
@@ -36,5 +36,5 @@ PEERDIR(
)
END()
-
-RECURSE_FOR_TESTS(ut)
+
+RECURSE_FOR_TESTS(ut)
diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp
index 033450c38c..40d6f310da 100644
--- a/util/string/cast_ut.cpp
+++ b/util/string/cast_ut.cpp
@@ -343,7 +343,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
CheckConvertToBuffer<size_t>(2, 5, "2");
CheckConvertToBuffer<ui64>(1005000000000000ull, 32, "1005000000000000");
CheckConvertToBuffer<ui64>(1005000000000000ull, 3, "1005000000000000");
-
+
// TString longNumber = TString("1.") + TString(1 << 20, '1');
// UNIT_ASSERT_EXCEPTION(FromString<double>(longNumber), yexception);
}
diff --git a/util/system/mutex.cpp b/util/system/mutex.cpp
index 4041402db9..d175f0f792 100644
--- a/util/system/mutex.cpp
+++ b/util/system/mutex.cpp
@@ -20,7 +20,7 @@ public:
inline T() {
int result;
-
+
memset(&Attr, 0, sizeof(Attr));
result = pthread_mutexattr_init(&Attr);
if (result != 0) {
diff --git a/util/system/rwlock.cpp b/util/system/rwlock.cpp
index bb3dcbf188..53e0357d39 100644
--- a/util/system/rwlock.cpp
+++ b/util/system/rwlock.cpp
@@ -2,39 +2,39 @@
#include "mutex.h"
#include "condvar.h"
-#include <util/generic/yexception.h>
-
+#include <util/generic/yexception.h>
+
#if defined(_unix_)
#include <errno.h>
#include <pthread.h>
-#endif
-
+#endif
+
#if defined(_win_) || defined(_darwin_)
//darwin rwlocks not recursive
-class TRWMutex::TImpl {
+class TRWMutex::TImpl {
public:
TImpl();
~TImpl();
-
+
void AcquireRead() noexcept;
bool TryAcquireRead() noexcept;
void ReleaseRead() noexcept;
-
+
void AcquireWrite() noexcept;
bool TryAcquireWrite() noexcept;
void ReleaseWrite() noexcept;
-
+
void Release() noexcept;
-
+
private:
TMutex Lock_;
int State_;
TCondVar ReadCond_;
TCondVar WriteCond_;
int BlockedWriters_;
-};
-
-TRWMutex::TImpl::TImpl()
+};
+
+TRWMutex::TImpl::TImpl()
: State_(0)
, BlockedWriters_(0)
{
@@ -43,8 +43,8 @@ TRWMutex::TImpl::TImpl()
TRWMutex::TImpl::~TImpl() {
Y_VERIFY(State_ == 0, "failure, State_ != 0");
Y_VERIFY(BlockedWriters_ == 0, "failure, BlockedWriters_ != 0");
-}
-
+}
+
void TRWMutex::TImpl::AcquireRead() noexcept {
with_lock (Lock_) {
while (BlockedWriters_ || State_ < 0) {
@@ -140,111 +140,111 @@ void TRWMutex::TImpl::Release() noexcept {
ReadCond_.Signal();
}
}
-}
-
-#else /* POSIX threads */
-
-class TRWMutex::TImpl {
+}
+
+#else /* POSIX threads */
+
+class TRWMutex::TImpl {
public:
TImpl();
~TImpl();
-
+
void AcquireRead() noexcept;
bool TryAcquireRead() noexcept;
void ReleaseRead() noexcept;
-
+
void AcquireWrite() noexcept;
bool TryAcquireWrite() noexcept;
void ReleaseWrite() noexcept;
-
+
void Release() noexcept;
-
+
private:
pthread_rwlock_t Lock_;
-};
-
-TRWMutex::TImpl::TImpl() {
+};
+
+TRWMutex::TImpl::TImpl() {
int result = pthread_rwlock_init(&Lock_, nullptr);
- if (result != 0) {
+ if (result != 0) {
ythrow yexception() << "rwlock init failed (" << LastSystemErrorText(result) << ")";
- }
-}
-
+ }
+}
+
TRWMutex::TImpl::~TImpl() {
const int result = pthread_rwlock_destroy(&Lock_);
Y_VERIFY(result == 0, "rwlock destroy failed (%s)", LastSystemErrorText(result));
-}
-
+}
+
void TRWMutex::TImpl::AcquireRead() noexcept {
const int result = pthread_rwlock_rdlock(&Lock_);
Y_VERIFY(result == 0, "rwlock rdlock failed (%s)", LastSystemErrorText(result));
-}
-
+}
+
bool TRWMutex::TImpl::TryAcquireRead() noexcept {
const int result = pthread_rwlock_tryrdlock(&Lock_);
Y_VERIFY(result == 0 || result == EBUSY, "rwlock tryrdlock failed (%s)", LastSystemErrorText(result));
- return result == 0;
-}
-
+ return result == 0;
+}
+
void TRWMutex::TImpl::ReleaseRead() noexcept {
const int result = pthread_rwlock_unlock(&Lock_);
Y_VERIFY(result == 0, "rwlock (read) unlock failed (%s)", LastSystemErrorText(result));
}
-
+
void TRWMutex::TImpl::AcquireWrite() noexcept {
const int result = pthread_rwlock_wrlock(&Lock_);
Y_VERIFY(result == 0, "rwlock wrlock failed (%s)", LastSystemErrorText(result));
-}
-
+}
+
bool TRWMutex::TImpl::TryAcquireWrite() noexcept {
const int result = pthread_rwlock_trywrlock(&Lock_);
Y_VERIFY(result == 0 || result == EBUSY, "rwlock trywrlock failed (%s)", LastSystemErrorText(result));
- return result == 0;
-}
-
+ return result == 0;
+}
+
void TRWMutex::TImpl::ReleaseWrite() noexcept {
const int result = pthread_rwlock_unlock(&Lock_);
Y_VERIFY(result == 0, "rwlock (write) unlock failed (%s)", LastSystemErrorText(result));
-}
-
+}
+
void TRWMutex::TImpl::Release() noexcept {
const int result = pthread_rwlock_unlock(&Lock_);
Y_VERIFY(result == 0, "rwlock unlock failed (%s)", LastSystemErrorText(result));
-}
-
+}
+
#endif
-
-TRWMutex::TRWMutex()
- : Impl_(new TImpl())
-{
-}
-
+
+TRWMutex::TRWMutex()
+ : Impl_(new TImpl())
+{
+}
+
TRWMutex::~TRWMutex() = default;
-
+
void TRWMutex::AcquireRead() noexcept {
- Impl_->AcquireRead();
-}
+ Impl_->AcquireRead();
+}
bool TRWMutex::TryAcquireRead() noexcept {
- return Impl_->TryAcquireRead();
-}
+ return Impl_->TryAcquireRead();
+}
void TRWMutex::ReleaseRead() noexcept {
- Impl_->ReleaseRead();
-}
-
+ Impl_->ReleaseRead();
+}
+
void TRWMutex::AcquireWrite() noexcept {
- Impl_->AcquireWrite();
-}
+ Impl_->AcquireWrite();
+}
bool TRWMutex::TryAcquireWrite() noexcept {
- return Impl_->TryAcquireWrite();
-}
+ return Impl_->TryAcquireWrite();
+}
void TRWMutex::ReleaseWrite() noexcept {
- Impl_->ReleaseWrite();
-}
-
+ Impl_->ReleaseWrite();
+}
+
void TRWMutex::Release() noexcept {
- Impl_->Release();
-}
+ Impl_->Release();
+}
diff --git a/util/system/rwlock.h b/util/system/rwlock.h
index 0bb9b3fe1c..924d459a06 100644
--- a/util/system/rwlock.h
+++ b/util/system/rwlock.h
@@ -3,8 +3,8 @@
#include "guard.h"
#include "defaults.h"
-#include <util/generic/ptr.h>
-
+#include <util/generic/ptr.h>
+
class TRWMutex {
public:
TRWMutex();