Browse Source

Restoring authorship annotation for <ekrokhalev@yandex-team.ru>. Commit 1 of 2.

ekrokhalev 3 years ago
parent
commit
1c01ed5294

+ 15 - 15
library/cpp/accurate_accumulate/accurate_accumulate.h

@@ -42,24 +42,24 @@ public:
     template <typename TFloatType>
     inline bool operator<(const TKahanAccumulator<TFloatType>& other) const {
         return Get() < other.Get();
-    }
-
-    template <typename TFloatType>
+    } 
+ 
+    template <typename TFloatType> 
     inline bool operator<=(const TKahanAccumulator<TFloatType>& other) const {
-        return !(other < *this);
-    }
-
-    template <typename TFloatType>
+        return !(other < *this); 
+    } 
+ 
+    template <typename TFloatType> 
     inline bool operator>(const TKahanAccumulator<TFloatType>& other) const {
-        return other < *this;
-    }
-
-    template <typename TFloatType>
+        return other < *this; 
+    } 
+ 
+    template <typename TFloatType> 
     inline bool operator>=(const TKahanAccumulator<TFloatType>& other) const {
-        return !(*this < other);
-    }
-
-    template <typename TFloatType>
+        return !(*this < other); 
+    } 
+ 
+    template <typename TFloatType> 
     inline TKahanAccumulator& operator+=(const TFloatType x) {
         const TValueType y = TValueType(x) - Compensation_;
         const TValueType t = Sum_ + y;

+ 10 - 10
library/cpp/cgiparam/cgiparam_ut.cpp

@@ -205,16 +205,16 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) {
 
     Y_UNIT_TEST(TestContInit) {
         TCgiParameters c = {std::make_pair("a", "a1"), std::make_pair("b", "b1"), std::make_pair("a", "a2")};
-
-        UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("a"), 2u);
-        UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("b"), 1u);
-
-        UNIT_ASSERT_VALUES_EQUAL(c.Get("b"), "b1");
-        UNIT_ASSERT_VALUES_EQUAL(c.Get("a", 0), "a1");
-        UNIT_ASSERT_VALUES_EQUAL(c.Get("a", 1), "a2");
-
-        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "a=a1&a=a2&b=b1");
-    }
+ 
+        UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("a"), 2u); 
+        UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("b"), 1u); 
+ 
+        UNIT_ASSERT_VALUES_EQUAL(c.Get("b"), "b1"); 
+        UNIT_ASSERT_VALUES_EQUAL(c.Get("a", 0), "a1"); 
+        UNIT_ASSERT_VALUES_EQUAL(c.Get("a", 1), "a2"); 
+ 
+        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "a=a1&a=a2&b=b1"); 
+    } 
 
     Y_UNIT_TEST(TestPrintAsQuote) {
         TCgiParameters c = {

+ 5 - 5
library/cpp/deprecated/split/delim_string_iter.h

@@ -22,13 +22,13 @@ public:
     }
 
     inline TDelimStringIter(TStringBuf str, TStringBuf delim)
-        : IsValid(true)
+        : IsValid(true) 
         , Str(str)
-        , Delim(delim)
-    {
+        , Delim(delim) 
+    { 
         UpdateCurrent();
-    }
-
+    } 
+ 
     inline TDelimStringIter()
         : IsValid(false)
     {

+ 6 - 6
library/cpp/getopt/small/opt2.cpp

@@ -248,13 +248,13 @@ unsigned long Opt2::UInt(char opt, const char* help, unsigned long def, bool req
     return rv;
 }
 
-// Add user defined error message and set error flag
-void Opt2::AddError(const char* message) {
-    HasErrors = true;
+// Add user defined error message and set error flag 
+void Opt2::AddError(const char* message) { 
+    HasErrors = true; 
     if (message)
-        UserErrorMessages.push_back(message);
-}
-
+        UserErrorMessages.push_back(message); 
+} 
+ 
 int Opt2::AutoUsage(const char* free_arg_names) {
     if (!HasErrors)
         return 0;

+ 2 - 2
library/cpp/getopt/small/opt2.h

@@ -107,9 +107,9 @@ public:
     // For options w/o parameters
     bool Has(char opt, const char* helpUsage);
 
-    // Add user defined error message and set error flag
+    // Add user defined error message and set error flag 
     void AddError(const char* message = nullptr);
-
+ 
 public:
     // non-option args
     TVector<char*> Pos;

+ 18 - 18
util/charset/unidata.h

@@ -400,22 +400,22 @@ inline bool IsPrint(wchar32 ch) {
     return IsAlnum(ch) || IsPunct(ch) || IsSymbol(ch) || IsBlank(ch);
 }
 
-inline bool IsRomanDigit(wchar32 ch) {
-    if (NUnicode::CharHasType(ch, SHIFT(Nl_LETTER)) && 0x2160 <= ch && ch <= 0x2188)
-        return true;
-    if (ch < 127) {
-        switch (static_cast<char>(::ToLower(ch))) {
-            case 'i':
-            case 'v':
-            case 'x':
-            case 'l':
-            case 'c':
-            case 'd':
-            case 'm':
-                return true;
-        }
-    }
-    return false;
-}
-
+inline bool IsRomanDigit(wchar32 ch) { 
+    if (NUnicode::CharHasType(ch, SHIFT(Nl_LETTER)) && 0x2160 <= ch && ch <= 0x2188) 
+        return true; 
+    if (ch < 127) { 
+        switch (static_cast<char>(::ToLower(ch))) { 
+            case 'i': 
+            case 'v': 
+            case 'x': 
+            case 'l': 
+            case 'c': 
+            case 'd': 
+            case 'm': 
+                return true; 
+        } 
+    } 
+    return false; 
+} 
+ 
 #undef SHIFT

+ 47 - 47
util/generic/xrange.h

@@ -20,7 +20,7 @@
 
 namespace NPrivate {
     template <typename T>
-    class TSimpleXRange {
+    class TSimpleXRange { 
         using TDiff = decltype(T() - T());
 
     public:
@@ -125,21 +125,21 @@ namespace NPrivate {
         T Finish;
     };
 
-    template <typename T>
-    class TSteppedXRange {
-        using TDiff = decltype(T() - T());
+    template <typename T> 
+    class TSteppedXRange { 
+        using TDiff = decltype(T() - T()); 
 
-    public:
+    public: 
         constexpr TSteppedXRange(T start, T finish, TDiff step) noexcept
             : Start_(start)
             , Step_(step)
             , Finish_(CalcRealFinish(Start_, finish, Step_))
         {
             static_assert(std::is_integral<T>::value || std::is_pointer<T>::value, "T should be integral type or pointer");
-        }
-
+        } 
+ 
         class TIterator {
-        public:
+        public: 
             using value_type = T;
             using difference_type = TDiff;
             using pointer = const T*;
@@ -150,16 +150,16 @@ namespace NPrivate {
                 : Value_(value)
                 , Parent_(&parent)
             {
-            }
-
+            } 
+ 
             constexpr T operator*() const noexcept {
-                return Value_;
-            }
-
+                return Value_; 
+            } 
+ 
             constexpr bool operator!=(const TIterator& other) const noexcept {
-                return Value_ != other.Value_;
-            }
-
+                return Value_ != other.Value_; 
+            } 
+ 
             constexpr bool operator==(const TIterator& other) const noexcept {
                 return Value_ == other.Value_;
             }
@@ -167,8 +167,8 @@ namespace NPrivate {
             TIterator& operator++() noexcept {
                 Value_ += Parent_->Step_;
                 return *this;
-            }
-
+            } 
+ 
             TIterator& operator--() noexcept {
                 Value_ -= Parent_->Step_;
                 return *this;
@@ -200,34 +200,34 @@ namespace NPrivate {
                 return *this;
             }
 
-        private:
-            T Value_;
+        private: 
+            T Value_; 
             const TSteppedXRange* Parent_;
-        };
-
+        }; 
+ 
         using value_type = T;
         using iterator = TIterator;
         using const_iterator = TIterator;
 
         constexpr TIterator begin() const noexcept {
-            return TIterator(Start_, *this);
-        }
-
+            return TIterator(Start_, *this); 
+        } 
+ 
         constexpr TIterator end() const noexcept {
-            return TIterator(Finish_, *this);
-        }
-
-        static T CalcRealFinish(T start, T expFinish, TDiff step) {
+            return TIterator(Finish_, *this); 
+        } 
+ 
+        static T CalcRealFinish(T start, T expFinish, TDiff step) { 
             Y_ASSERT(step != 0);
-            if (step > 0) {
-                if (expFinish > start) {
-                    return start + step * ((expFinish - 1 - start) / step + 1);
-                }
-                return start;
-            }
-            return start - TSteppedXRange<TDiff>::CalcRealFinish(0, start - expFinish, -step);
-        }
-
+            if (step > 0) { 
+                if (expFinish > start) { 
+                    return start + step * ((expFinish - 1 - start) / step + 1); 
+                } 
+                return start; 
+            } 
+            return start - TSteppedXRange<TDiff>::CalcRealFinish(0, start - expFinish, -step); 
+        } 
+ 
         constexpr T size() const noexcept {
             return (Finish_ - Start_) / Step_;
         }
@@ -237,12 +237,12 @@ namespace NPrivate {
             return Container(begin(), end());
         }
 
-    private:
-        const T Start_;
-        const TDiff Step_;
-        const T Finish_;
-    };
-
+    private: 
+        const T Start_; 
+        const TDiff Step_; 
+        const T Finish_; 
+    }; 
+ 
 }
 
 /**
@@ -250,11 +250,11 @@ namespace NPrivate {
  *
  * @param step must be non-zero
  */
-template <typename T>
+template <typename T> 
 constexpr ::NPrivate::TSteppedXRange<T> xrange(T start, T finish, decltype(T() - T()) step) noexcept {
     return {start, finish, step};
-}
-
+} 
+ 
 /// generate sequence [start; finish)
 template <typename T>
 constexpr ::NPrivate::TSimpleXRange<T> xrange(T start, T finish) noexcept {

+ 23 - 23
util/generic/xrange_ut.cpp

@@ -31,26 +31,26 @@ Y_UNIT_TEST_SUITE(XRange) {
     }
 
     void TestSteppedXRangeImpl(int begin, int end, int step, const TVector<int>& expected) {
-        size_t expInd = 0;
+        size_t expInd = 0; 
         for (auto i : xrange(begin, end, step)) {
-            UNIT_ASSERT(expInd < expected.size());
-            UNIT_ASSERT_VALUES_EQUAL(i, expected[expInd]);
-            ++expInd;
-        }
-        UNIT_ASSERT_VALUES_EQUAL(expInd, expected.size());
-    }
-
+            UNIT_ASSERT(expInd < expected.size()); 
+            UNIT_ASSERT_VALUES_EQUAL(i, expected[expInd]); 
+            ++expInd; 
+        } 
+        UNIT_ASSERT_VALUES_EQUAL(expInd, expected.size()); 
+    } 
+ 
     Y_UNIT_TEST(IncrementWorks) {
         TestXRangeImpl(0, 10);
         TestXRangeImpl(10, 20);
     }
-
+ 
     Y_UNIT_TEST(DecrementWorks) {
         TestSteppedXRangeImpl(10, 0, -1, {10, 9, 8, 7, 6, 5, 4, 3, 2, 1});
         TestSteppedXRangeImpl(10, -1, -1, {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0});
         TestSteppedXRangeImpl(20, 9, -1, {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10});
-    }
-
+    } 
+ 
     Y_UNIT_TEST(StepWorks) {
         TestSteppedXRangeImpl(0, 0, 1, {});
         TestSteppedXRangeImpl(0, 9, 3, {0, 3, 6});
@@ -62,22 +62,22 @@ Y_UNIT_TEST_SUITE(XRange) {
         TestSteppedXRangeImpl(15, 0, -4, {15, 11, 7, 3});
         TestSteppedXRangeImpl(15, -1, -4, {15, 11, 7, 3});
         TestSteppedXRangeImpl(15, -2, -4, {15, 11, 7, 3, -1});
-    }
-
+    } 
+ 
     Y_UNIT_TEST(PointersWorks) {
         TVector<size_t> data = {3, 1, 4, 1, 5, 9, 2, 6};
-        const size_t digSumExpected = Accumulate(data.begin(), data.end(), static_cast<size_t>(0));
-        size_t digSumByIt = 0;
+        const size_t digSumExpected = Accumulate(data.begin(), data.end(), static_cast<size_t>(0)); 
+        size_t digSumByIt = 0; 
         for (auto ptr : xrange(data.begin(), data.end())) {
-            digSumByIt += *ptr;
-        }
-        UNIT_ASSERT_VALUES_EQUAL(digSumByIt, digSumExpected);
-        size_t digSumByPtr = 0;
+            digSumByIt += *ptr; 
+        } 
+        UNIT_ASSERT_VALUES_EQUAL(digSumByIt, digSumExpected); 
+        size_t digSumByPtr = 0; 
         for (auto ptr : xrange(&data[0], &data[0] + data.size())) {
-            digSumByPtr += *ptr;
-        }
-        UNIT_ASSERT_VALUES_EQUAL(digSumByPtr, digSumExpected);
-    }
+            digSumByPtr += *ptr; 
+        } 
+        UNIT_ASSERT_VALUES_EQUAL(digSumByPtr, digSumExpected); 
+    } 
 
     Y_UNIT_TEST(SizeMethodCheck) {
         UNIT_ASSERT_VALUES_EQUAL(xrange(5).size(), 5);

+ 28 - 28
util/stream/pipe.cpp

@@ -82,40 +82,40 @@ void TPipeOutput::Close() {
     }
 }
 
-TPipedBase::TPipedBase(PIPEHANDLE fd)
-    : Handle_(fd)
-{
-}
-
+TPipedBase::TPipedBase(PIPEHANDLE fd) 
+    : Handle_(fd) 
+{ 
+} 
+ 
 TPipedBase::~TPipedBase() {
     if (Handle_.IsOpen()) {
-        Handle_.Close();
+        Handle_.Close(); 
     }
-}
-
+} 
+ 
 TPipedInput::TPipedInput(PIPEHANDLE fd)
-    : TPipedBase(fd)
-{
-}
-
+    : TPipedBase(fd) 
+{ 
+} 
+ 
 TPipedInput::~TPipedInput() = default;
-
-size_t TPipedInput::DoRead(void* buf, size_t len) {
+ 
+size_t TPipedInput::DoRead(void* buf, size_t len) { 
     if (!Handle_.IsOpen()) {
-        return 0;
+        return 0; 
     }
     return Handle_.Read(buf, len);
-}
-
-TPipedOutput::TPipedOutput(PIPEHANDLE fd)
-    : TPipedBase(fd)
-{
-}
-
+} 
+ 
+TPipedOutput::TPipedOutput(PIPEHANDLE fd) 
+    : TPipedBase(fd) 
+{ 
+} 
+ 
 TPipedOutput::~TPipedOutput() = default;
-
-void TPipedOutput::DoWrite(const void* buf, size_t len) {
-    if (!Handle_.IsOpen() || static_cast<ssize_t>(len) != Handle_.Write(buf, len)) {
-        ythrow TSystemError() << "pipe writing failed";
-    }
-}
+ 
+void TPipedOutput::DoWrite(const void* buf, size_t len) { 
+    if (!Handle_.IsOpen() || static_cast<ssize_t>(len) != Handle_.Write(buf, len)) { 
+        ythrow TSystemError() << "pipe writing failed"; 
+    } 
+} 

+ 9 - 9
util/stream/pipe.h

@@ -76,15 +76,15 @@ private:
     void DoWrite(const void* buf, size_t len) override;
 };
 
-class TPipedBase {
+class TPipedBase { 
 protected:
     TPipedBase(PIPEHANDLE fd);
     virtual ~TPipedBase();
 
 protected:
     TPipeHandle Handle_;
-};
-
+}; 
+ 
 /**
  * Input stream that binds to a standard output stream of an existing process.
  */
@@ -92,11 +92,11 @@ class TPipedInput: public TPipedBase, public IInputStream {
 public:
     TPipedInput(PIPEHANDLE fd);
     ~TPipedInput() override;
-
+ 
 private:
     size_t DoRead(void* buf, size_t len) override;
-};
-
+}; 
+ 
 /**
  * Output stream that binds to a standard input stream of an existing process.
  */
@@ -104,9 +104,9 @@ class TPipedOutput: public TPipedBase, public IOutputStream {
 public:
     TPipedOutput(PIPEHANDLE fd);
     ~TPipedOutput() override;
-
+ 
 private:
     void DoWrite(const void* buf, size_t len) override;
-};
-
+}; 
+ 
 /** @} */