diff options
author | aosipenko <aosipenko@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
commit | 69e3c43df1c96bc2ac8946bf4dfb1f5fc438ff7f (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 | |
parent | 948fd24d47d4b3b7815aaef1686aea00ef3f4288 (diff) | |
download | ydb-69e3c43df1c96bc2ac8946bf4dfb1f5fc438ff7f.tar.gz |
Restoring authorship annotation for <aosipenko@yandex-team.ru>. Commit 2 of 2.
124 files changed, 952 insertions, 952 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/stlfwd b/contrib/libs/cxxsupp/libcxx/include/stlfwd index bb7dca55e3..adad6790dc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/stlfwd +++ b/contrib/libs/cxxsupp/libcxx/include/stlfwd @@ -13,9 +13,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class F, class S> struct pair; - template <class T, size_t N> - struct array; - + template <class T, size_t N> + struct array; + template <class T, class A> class vector; @@ -59,5 +59,5 @@ _LIBCPP_BEGIN_NAMESPACE_STD template<class T, class Traits> class basic_string_view; -_LIBCPP_END_NAMESPACE_STD - +_LIBCPP_END_NAMESPACE_STD + diff --git a/contrib/libs/pire/pire/re_parser.y b/contrib/libs/pire/pire/re_parser.y index a324b3b4a1..dbad88e287 100644 --- a/contrib/libs/pire/pire/re_parser.y +++ b/contrib/libs/pire/pire/re_parser.y @@ -28,7 +28,7 @@ #pragma warning(disable: 4060) // switch contains no 'case' or 'default' statements #pragma warning(disable: 4065) // switch contains 'default' but no 'case' statements #pragma warning(disable: 4102) // unreferenced label 'yyerrlabl' -#pragma warning(disable: 4702) // unreachable code +#pragma warning(disable: 4702) // unreachable code #endif #ifdef __GNUC__ diff --git a/library/cpp/archive/yarchive.cpp b/library/cpp/archive/yarchive.cpp index b750ac1c81..1becc3e5da 100644 --- a/library/cpp/archive/yarchive.cpp +++ b/library/cpp/archive/yarchive.cpp @@ -310,7 +310,7 @@ public: ythrow yexception() << "incorrect index"; } - + inline bool Has(const TStringBuf key) const { return Dict_.contains(key); } @@ -378,9 +378,9 @@ TString TArchiveReader::KeyByIndex(size_t n) const { } bool TArchiveReader::Has(const TStringBuf key) const { - return Impl_->Has(key); -} - + return Impl_->Has(key); +} + TAutoPtr<IInputStream> TArchiveReader::ObjectByKey(const TStringBuf key) const { return Impl_->ObjectByKey(key); } diff --git a/library/cpp/blockcodecs/core/stream.cpp b/library/cpp/blockcodecs/core/stream.cpp index bf1a9043a8..4f7db3c32b 100644 --- a/library/cpp/blockcodecs/core/stream.cpp +++ b/library/cpp/blockcodecs/core/stream.cpp @@ -172,7 +172,7 @@ size_t TDecodedInput::DoUnboundedNext(const void** ptr) { const size_t payload = sizeof(TCodecID) + sizeof(TBlockLen); char buf[32]; - S_->LoadOrFail(buf, payload); + S_->LoadOrFail(buf, payload); TMemoryInput in(buf, payload); diff --git a/library/cpp/charset/codepage.cpp b/library/cpp/charset/codepage.cpp index 5616dfcd3a..0431bef31b 100644 --- a/library/cpp/charset/codepage.cpp +++ b/library/cpp/charset/codepage.cpp @@ -146,16 +146,16 @@ private: AddNameWithCheck(name, code); TString temp = name; - RemoveAll(temp, '-'); - RemoveAll(temp, '_'); + RemoveAll(temp, '-'); + RemoveAll(temp, '_'); AddNameWithCheck(temp, code); temp = name; - SubstGlobal(temp, '-', '_'); + SubstGlobal(temp, '-', '_'); AddNameWithCheck(temp, code); temp = name; - SubstGlobal(temp, '_', '-'); + SubstGlobal(temp, '_', '-'); AddNameWithCheck(temp, code); } diff --git a/library/cpp/charset/codepage_ut.cpp b/library/cpp/charset/codepage_ut.cpp index 11ae010b6e..c3ac3ac478 100644 --- a/library/cpp/charset/codepage_ut.cpp +++ b/library/cpp/charset/codepage_ut.cpp @@ -12,21 +12,21 @@ #endif namespace { - const char yandexUpperCase[] = + const char yandexUpperCase[] = "\x81\x82\x83\x84\x85\x86\x87" "\x8E" "\xA1\xA2\xA3\xA4\xA5\xA6" "\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF" - "\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF" - "\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF"; + "\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF" + "\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF"; - const char yandexLowerCase[] = + const char yandexLowerCase[] = "\x91\x92\x93\x94\x95\x96\x97" "\x9E" "\xB1\xB2\xB3\xB4\xB5\xB6" "\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF" - "\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF" - "\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"; + "\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF" + "\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"; } class TCodepageTest: public TTestBase { @@ -163,7 +163,7 @@ void TCodepageTest::TestUTF() { void TCodepageTest::TestBrokenMultibyte() { const ECharset cp = CODES_EUC_JP; - const char sampletext[] = {'\xe3'}; + const char sampletext[] = {'\xe3'}; wchar32 recodeResult[100]; size_t nwritten = 0; @@ -332,7 +332,7 @@ void TCodepageTest::TestToLower() { const size_t n = Y_ARRAY_SIZE(yandexUpperCase); // including NTS memcpy(data, yandexUpperCase, n); ToLower(data, n - 1); - UNIT_ASSERT(strcmp(data, yandexLowerCase) == 0); + UNIT_ASSERT(strcmp(data, yandexLowerCase) == 0); } void TCodepageTest::TestToUpper() { @@ -341,7 +341,7 @@ void TCodepageTest::TestToUpper() { const size_t n = Y_ARRAY_SIZE(yandexLowerCase); // including NTS memcpy(data, yandexLowerCase, n); ToUpper(data, n - 1); - UNIT_ASSERT(strcmp(data, yandexUpperCase) == 0); + UNIT_ASSERT(strcmp(data, yandexUpperCase) == 0); } static void TestCanEncodeEmpty() { diff --git a/library/cpp/charset/generated/encrec_data.cpp b/library/cpp/charset/generated/encrec_data.cpp index 26a5066d3c..ca59f8ddef 100644 --- a/library/cpp/charset/generated/encrec_data.cpp +++ b/library/cpp/charset/generated/encrec_data.cpp @@ -614,8 +614,8 @@ static const char PP_35[257] = "\000\000\000\000"; #define P35 (char*)PP_35 static const char PP_36[257] = - "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" + "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -8410,8 +8410,8 @@ const Encoder* const NCodepagePrivate::TCodePageData::EncodeTo[] = { const struct Encoder &WideCharToYandex = encoder_09; const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -8425,8 +8425,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { "\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351" "\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373" "\374\375\376\377"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -8440,8 +8440,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { "\374\373\347\370\375\371\367\372\336\300\301\326\304\305\324\303\325\310" "\311\312\313\314\315\316\317\337\320\321\322\323\306\302\334\333\307\330" "\335\331\327\332"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -8455,8 +8455,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { "\260\260\260\260\260\260\260\260\360\361\362\363\364\365\366\367\370\371" "\372\373\374\375\376\377\250\270\256\276\257\277\254\274\260\075\055\075" "\267\044\260\240"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -8470,8 +8470,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { "\254\274\246\266\267\250\270\377\340\341\342\343\344\345\346\347\350\351" "\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373" "\374\375\376\044"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -8485,8 +8485,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { "\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371" "\372\373\374\375\376\377\267\270\266\343\276\266\275\277\266\266\266\266" "\352\247\274\266"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -8500,8 +8500,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { "\246\125\125\125\203\131\246\220\210\141\211\141\221\141\266\212\213\214" "\215\230\151\151\231\232\266\156\157\262\233\157\222\075\266\234\165\235" "\223\171\266\171"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -8515,8 +8515,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { "\260\260\260\260\260\260\260\260\260\260\260\260\260\260\260\260\260\260" "\260\260\260\260\260\260\260\260\260\260\260\260\260\260\260\260\260\260" "\260\260\260\260"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -8530,8 +8530,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { "\122\125\125\125\203\131\124\220\162\141\211\141\221\154\225\212\143\214" "\226\230\145\151\231\144\266\261\156\262\233\157\222\075\162\165\165\165" "\223\171\164\140"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -8545,8 +8545,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { "\122\125\125\125\203\131\124\220\162\141\211\141\221\154\225\212\143\214" "\226\230\145\151\231\144\266\261\156\262\233\157\222\075\162\165\165\165" "\223\171\164\140"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -8562,8 +8562,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { "\374\375\376\377"},}, {{},}, {{},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -8593,8 +8593,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { "\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077" "\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077" "\077\077\077\077"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -9744,8 +9744,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_yandex[] = { }; const Recoder NCodepagePrivate::TCodePageData::rcdr_from_yandex[] = { -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -9759,8 +9759,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_from_yandex[] = { "\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351" "\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373" "\374\375\376\377"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -9774,8 +9774,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_from_yandex[] = { "\373\375\377\371\370\374\340\361\301\302\327\307\304\305\326\332\311\312" "\313\314\315\316\317\320\322\323\324\325\306\310\303\336\333\335\337\331" "\330\334\300\321"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -9789,8 +9789,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_from_yandex[] = { "\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251" "\252\253\254\255\256\257\340\341\342\343\344\345\346\347\350\351\352\353" "\354\355\356\357"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -9804,8 +9804,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_from_yandex[] = { "\230\231\232\233\234\235\236\237\340\341\342\343\344\345\346\347\350\351" "\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373" "\374\375\376\337"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -9819,8 +9819,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_from_yandex[] = { "\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331" "\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353" "\354\355\356\357"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -9834,8 +9834,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_from_yandex[] = { "\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077" "\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077" "\077\077\077\077"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -9849,8 +9849,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_from_yandex[] = { "\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077" "\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077" "\077\077\077\077"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -9864,8 +9864,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_from_yandex[] = { "\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077" "\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077" "\077\077\077\077"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -9879,8 +9879,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_from_yandex[] = { "\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077" "\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077" "\077\077\077\077"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -9896,8 +9896,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_from_yandex[] = { "\374\375\376\377"},}, {{},}, {{},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" @@ -9927,8 +9927,8 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_from_yandex[] = { "\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077" "\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077" "\077\077\077\077"},}, -{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" - "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" +{{"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021" + "\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043" "\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065" "\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107" "\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131" diff --git a/library/cpp/charset/wide_ut.cpp b/library/cpp/charset/wide_ut.cpp index 218a329041..78947d51ba 100644 --- a/library/cpp/charset/wide_ut.cpp +++ b/library/cpp/charset/wide_ut.cpp @@ -1,6 +1,6 @@ #include "wide.h" #include "codepage.h" -#include "recyr.hh" +#include "recyr.hh" #include <library/cpp/testing/unittest/registar.h> @@ -12,25 +12,25 @@ namespace { //! three UTF8 encoded russian letters (A, B, V) - const char yandexCyrillicAlphabet[] = - "\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF" // A - P - "\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF" // R - YA - "\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF" // a - p - "\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"; // r - ya + const char yandexCyrillicAlphabet[] = + "\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF" // A - P + "\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF" // R - YA + "\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF" // a - p + "\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"; // r - ya const wchar16 wideCyrillicAlphabet[] = { 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, 0x00}; - const char utf8CyrillicAlphabet[] = - "\xd0\x90\xd0\x91\xd0\x92\xd0\x93\xd0\x94\xd0\x95\xd0\x96\xd0\x97" - "\xd0\x98\xd0\x99\xd0\x9a\xd0\x9b\xd0\x9c\xd0\x9d\xd0\x9e\xd0\x9f" - "\xd0\xa0\xd0\xa1\xd0\xa2\xd0\xa3\xd0\xa4\xd0\xa5\xd0\xa6\xd0\xa7" - "\xd0\xa8\xd0\xa9\xd0\xaa\xd0\xab\xd0\xac\xd0\xad\xd0\xae\xd0\xaf" - "\xd0\xb0\xd0\xb1\xd0\xb2\xd0\xb3\xd0\xb4\xd0\xb5\xd0\xb6\xd0\xb7" - "\xd0\xb8\xd0\xb9\xd0\xba\xd0\xbb\xd0\xbc\xd0\xbd\xd0\xbe\xd0\xbf" - "\xd1\x80\xd1\x81\xd1\x82\xd1\x83\xd1\x84\xd1\x85\xd1\x86\xd1\x87" - "\xd1\x88\xd1\x89\xd1\x8a\xd1\x8b\xd1\x8c\xd1\x8d\xd1\x8e\xd1\x8f"; + const char utf8CyrillicAlphabet[] = + "\xd0\x90\xd0\x91\xd0\x92\xd0\x93\xd0\x94\xd0\x95\xd0\x96\xd0\x97" + "\xd0\x98\xd0\x99\xd0\x9a\xd0\x9b\xd0\x9c\xd0\x9d\xd0\x9e\xd0\x9f" + "\xd0\xa0\xd0\xa1\xd0\xa2\xd0\xa3\xd0\xa4\xd0\xa5\xd0\xa6\xd0\xa7" + "\xd0\xa8\xd0\xa9\xd0\xaa\xd0\xab\xd0\xac\xd0\xad\xd0\xae\xd0\xaf" + "\xd0\xb0\xd0\xb1\xd0\xb2\xd0\xb3\xd0\xb4\xd0\xb5\xd0\xb6\xd0\xb7" + "\xd0\xb8\xd0\xb9\xd0\xba\xd0\xbb\xd0\xbc\xd0\xbd\xd0\xbe\xd0\xbf" + "\xd1\x80\xd1\x81\xd1\x82\xd1\x83\xd1\x84\xd1\x85\xd1\x86\xd1\x87" + "\xd1\x88\xd1\x89\xd1\x8a\xd1\x8b\xd1\x8c\xd1\x8d\xd1\x8e\xd1\x8f"; TString CreateYandexText() { const int len = 256; @@ -69,31 +69,31 @@ namespace { } TString CreateUTF8Text() { - char text[] = { - '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', - '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', - '\x20', '\x21', '\x22', '\x23', '\x24', '\x25', '\x26', '\x27', '\x28', '\x29', '\x2a', '\x2b', '\x2c', '\x2d', '\x2e', '\x2f', - '\x30', '\x31', '\x32', '\x33', '\x34', '\x35', '\x36', '\x37', '\x38', '\x39', '\x3a', '\x3b', '\x3c', '\x3d', '\x3e', '\x3f', - '\x40', '\x41', '\x42', '\x43', '\x44', '\x45', '\x46', '\x47', '\x48', '\x49', '\x4a', '\x4b', '\x4c', '\x4d', '\x4e', '\x4f', - '\x50', '\x51', '\x52', '\x53', '\x54', '\x55', '\x56', '\x57', '\x58', '\x59', '\x5a', '\x5b', '\x5c', '\x5d', '\x5e', '\x5f', - '\x60', '\x61', '\x62', '\x63', '\x64', '\x65', '\x66', '\x67', '\x68', '\x69', '\x6a', '\x6b', '\x6c', '\x6d', '\x6e', '\x6f', - '\x70', '\x71', '\x72', '\x73', '\x74', '\x75', '\x76', '\x77', '\x78', '\x79', '\x7a', '\x7b', '\x7c', '\x7d', '\x7e', '\x7f', - '\xcc', '\x81', '\xc3', '\x84', '\xc3', '\x96', '\xc3', '\x9c', '\xc4', '\x84', '\xc4', '\x86', '\xc4', '\x98', '\xc5', '\x81', - '\xc3', '\xa0', '\xc3', '\xa2', '\xc3', '\xa7', '\xc3', '\xa8', '\xc3', '\xa9', '\xc3', '\xaa', '\xd2', '\x90', '\xc2', '\xad', - '\xc3', '\x9f', '\xc3', '\xa4', '\xc3', '\xb6', '\xc3', '\xbc', '\xc4', '\x85', '\xc4', '\x87', '\xc4', '\x99', '\xc5', '\x82', - '\xc3', '\xab', '\xc3', '\xae', '\xc3', '\xaf', '\xc3', '\xb4', '\xc3', '\xb9', '\xc3', '\xbb', '\xd2', '\x91', '\xe9', '\x8b', - '\x8f', '\xc2', '\xa0', '\xc5', '\x83', '\xc3', '\x93', '\xc5', '\x9a', '\xc5', '\xbb', '\xc5', '\xb9', '\xd1', '\xac', '\xc2', - '\xa7', '\xd0', '\x81', '\xd1', '\xa2', '\xd1', '\xb2', '\xd1', '\xb4', '\xd0', '\x8e', '\xd0', '\x86', '\xd0', '\x84', '\xd0', - '\x87', '\xc2', '\xb0', '\xc5', '\x84', '\xc3', '\xb3', '\xc5', '\x9b', '\xc5', '\xbc', '\xc5', '\xba', '\xd1', '\xad', '\xe2', - '\x84', '\x96', '\xd1', '\x91', '\xd1', '\xa3', '\xd1', '\xb3', '\xd1', '\xb5', '\xd1', '\x9e', '\xd1', '\x96', '\xd1', '\x94', - '\xd1', '\x97', '\xd0', '\x90', '\xd0', '\x91', '\xd0', '\x92', '\xd0', '\x93', '\xd0', '\x94', '\xd0', '\x95', '\xd0', '\x96', - '\xd0', '\x97', '\xd0', '\x98', '\xd0', '\x99', '\xd0', '\x9a', '\xd0', '\x9b', '\xd0', '\x9c', '\xd0', '\x9d', '\xd0', '\x9e', - '\xd0', '\x9f', '\xd0', '\xa0', '\xd0', '\xa1', '\xd0', '\xa2', '\xd0', '\xa3', '\xd0', '\xa4', '\xd0', '\xa5', '\xd0', '\xa6', - '\xd0', '\xa7', '\xd0', '\xa8', '\xd0', '\xa9', '\xd0', '\xaa', '\xd0', '\xab', '\xd0', '\xac', '\xd0', '\xad', '\xd0', '\xae', - '\xd0', '\xaf', '\xd0', '\xb0', '\xd0', '\xb1', '\xd0', '\xb2', '\xd0', '\xb3', '\xd0', '\xb4', '\xd0', '\xb5', '\xd0', '\xb6', - '\xd0', '\xb7', '\xd0', '\xb8', '\xd0', '\xb9', '\xd0', '\xba', '\xd0', '\xbb', '\xd0', '\xbc', '\xd0', '\xbd', '\xd0', '\xbe', - '\xd0', '\xbf', '\xd1', '\x80', '\xd1', '\x81', '\xd1', '\x82', '\xd1', '\x83', '\xd1', '\x84', '\xd1', '\x85', '\xd1', '\x86', - '\xd1', '\x87', '\xd1', '\x88', '\xd1', '\x89', '\xd1', '\x8a', '\xd1', '\x8b', '\xd1', '\x8c', '\xd1', '\x8d', '\xd1', '\x8e', + char text[] = { + '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', + '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', + '\x20', '\x21', '\x22', '\x23', '\x24', '\x25', '\x26', '\x27', '\x28', '\x29', '\x2a', '\x2b', '\x2c', '\x2d', '\x2e', '\x2f', + '\x30', '\x31', '\x32', '\x33', '\x34', '\x35', '\x36', '\x37', '\x38', '\x39', '\x3a', '\x3b', '\x3c', '\x3d', '\x3e', '\x3f', + '\x40', '\x41', '\x42', '\x43', '\x44', '\x45', '\x46', '\x47', '\x48', '\x49', '\x4a', '\x4b', '\x4c', '\x4d', '\x4e', '\x4f', + '\x50', '\x51', '\x52', '\x53', '\x54', '\x55', '\x56', '\x57', '\x58', '\x59', '\x5a', '\x5b', '\x5c', '\x5d', '\x5e', '\x5f', + '\x60', '\x61', '\x62', '\x63', '\x64', '\x65', '\x66', '\x67', '\x68', '\x69', '\x6a', '\x6b', '\x6c', '\x6d', '\x6e', '\x6f', + '\x70', '\x71', '\x72', '\x73', '\x74', '\x75', '\x76', '\x77', '\x78', '\x79', '\x7a', '\x7b', '\x7c', '\x7d', '\x7e', '\x7f', + '\xcc', '\x81', '\xc3', '\x84', '\xc3', '\x96', '\xc3', '\x9c', '\xc4', '\x84', '\xc4', '\x86', '\xc4', '\x98', '\xc5', '\x81', + '\xc3', '\xa0', '\xc3', '\xa2', '\xc3', '\xa7', '\xc3', '\xa8', '\xc3', '\xa9', '\xc3', '\xaa', '\xd2', '\x90', '\xc2', '\xad', + '\xc3', '\x9f', '\xc3', '\xa4', '\xc3', '\xb6', '\xc3', '\xbc', '\xc4', '\x85', '\xc4', '\x87', '\xc4', '\x99', '\xc5', '\x82', + '\xc3', '\xab', '\xc3', '\xae', '\xc3', '\xaf', '\xc3', '\xb4', '\xc3', '\xb9', '\xc3', '\xbb', '\xd2', '\x91', '\xe9', '\x8b', + '\x8f', '\xc2', '\xa0', '\xc5', '\x83', '\xc3', '\x93', '\xc5', '\x9a', '\xc5', '\xbb', '\xc5', '\xb9', '\xd1', '\xac', '\xc2', + '\xa7', '\xd0', '\x81', '\xd1', '\xa2', '\xd1', '\xb2', '\xd1', '\xb4', '\xd0', '\x8e', '\xd0', '\x86', '\xd0', '\x84', '\xd0', + '\x87', '\xc2', '\xb0', '\xc5', '\x84', '\xc3', '\xb3', '\xc5', '\x9b', '\xc5', '\xbc', '\xc5', '\xba', '\xd1', '\xad', '\xe2', + '\x84', '\x96', '\xd1', '\x91', '\xd1', '\xa3', '\xd1', '\xb3', '\xd1', '\xb5', '\xd1', '\x9e', '\xd1', '\x96', '\xd1', '\x94', + '\xd1', '\x97', '\xd0', '\x90', '\xd0', '\x91', '\xd0', '\x92', '\xd0', '\x93', '\xd0', '\x94', '\xd0', '\x95', '\xd0', '\x96', + '\xd0', '\x97', '\xd0', '\x98', '\xd0', '\x99', '\xd0', '\x9a', '\xd0', '\x9b', '\xd0', '\x9c', '\xd0', '\x9d', '\xd0', '\x9e', + '\xd0', '\x9f', '\xd0', '\xa0', '\xd0', '\xa1', '\xd0', '\xa2', '\xd0', '\xa3', '\xd0', '\xa4', '\xd0', '\xa5', '\xd0', '\xa6', + '\xd0', '\xa7', '\xd0', '\xa8', '\xd0', '\xa9', '\xd0', '\xaa', '\xd0', '\xab', '\xd0', '\xac', '\xd0', '\xad', '\xd0', '\xae', + '\xd0', '\xaf', '\xd0', '\xb0', '\xd0', '\xb1', '\xd0', '\xb2', '\xd0', '\xb3', '\xd0', '\xb4', '\xd0', '\xb5', '\xd0', '\xb6', + '\xd0', '\xb7', '\xd0', '\xb8', '\xd0', '\xb9', '\xd0', '\xba', '\xd0', '\xbb', '\xd0', '\xbc', '\xd0', '\xbd', '\xd0', '\xbe', + '\xd0', '\xbf', '\xd1', '\x80', '\xd1', '\x81', '\xd1', '\x82', '\xd1', '\x83', '\xd1', '\x84', '\xd1', '\x85', '\xd1', '\x86', + '\xd1', '\x87', '\xd1', '\x88', '\xd1', '\x89', '\xd1', '\x8a', '\xd1', '\x8b', '\xd1', '\x8c', '\xd1', '\x8d', '\xd1', '\x8e', '\xd1', '\x8f'}; return TString(text, Y_ARRAY_SIZE(text)); } @@ -206,7 +206,7 @@ static void TestSurrogates(const char* str, const wchar16* wide, size_t wideSize void TConversionTest::TestYandexEncoding() { TUtf16String w = UTF8ToWide(utf8CyrillicAlphabet, strlen(utf8CyrillicAlphabet), csYandex); UNIT_ASSERT(w == wideCyrillicAlphabet); - w = UTF8ToWide(yandexCyrillicAlphabet, strlen(yandexCyrillicAlphabet), csYandex); + w = UTF8ToWide(yandexCyrillicAlphabet, strlen(yandexCyrillicAlphabet), csYandex); UNIT_ASSERT(w == wideCyrillicAlphabet); const char* utf8NonBMP2 = "ab\xf4\x80\x89\x87n"; diff --git a/library/cpp/containers/compact_vector/compact_vector.h b/library/cpp/containers/compact_vector/compact_vector.h index 51282f52fd..dbe7473f0c 100644 --- a/library/cpp/containers/compact_vector/compact_vector.h +++ b/library/cpp/containers/compact_vector/compact_vector.h @@ -59,7 +59,7 @@ public: } catch (...) { } } - if (Ptr) + if (Ptr) free(Header()); } @@ -120,7 +120,7 @@ public: } size_t Size() const { - return Ptr ? Header()->Size : 0; + return Ptr ? Header()->Size : 0; } size_t size() const { @@ -136,7 +136,7 @@ public: } size_t Capacity() const { - return Ptr ? Header()->Capacity : 0; + return Ptr ? Header()->Capacity : 0; } void PushBack(const T& elem) { diff --git a/library/cpp/containers/comptrie/comptrie_builder.inl b/library/cpp/containers/comptrie/comptrie_builder.inl index 51a6f976d0..f273fa6571 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.inl +++ b/library/cpp/containers/comptrie/comptrie_builder.inl @@ -160,8 +160,8 @@ public: return 0; size_t median = (from + to) / 2; - size_t leftsize = (size_t)MeasureRange(builder, from, median); - size_t rightsize = (size_t)MeasureRange(builder, median + 1, to); + size_t leftsize = (size_t)MeasureRange(builder, from, median); + size_t rightsize = (size_t)MeasureRange(builder, median + 1, to); return builder->ArcMeasure(&(*this)[median], leftsize, rightsize); } @@ -825,7 +825,7 @@ void TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeLinkTo(TNode* th template <class T, class D, class S> size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeMeasureSubtree(TNode* thiz) const { - return (size_t)thiz->Subtree()->Measure(this); + return (size_t)thiz->Subtree()->Measure(this); } template <class T, class D, class S> diff --git a/library/cpp/containers/comptrie/comptrie_trie.h b/library/cpp/containers/comptrie/comptrie_trie.h index 63e3e50304..40ec1e52b3 100644 --- a/library/cpp/containers/comptrie/comptrie_trie.h +++ b/library/cpp/containers/comptrie/comptrie_trie.h @@ -655,7 +655,7 @@ typename TCompactTrie<T, D, S>::TData TCompactTrie<T, D, S>::TConstIterator::Get template <class T, class D, class S> void TCompactTrie<T, D, S>::TConstIterator::GetValue(typename TCompactTrie<T, D, S>::TData& data) const { const char* ptr = GetValuePtr(); - if (ptr) { + if (ptr) { Packer.UnpackLeaf(ptr, data); } else { data = typename TCompactTrie<T, D, S>::TData(); diff --git a/library/cpp/containers/comptrie/comptrie_ut.cpp b/library/cpp/containers/comptrie/comptrie_ut.cpp index 969518fa1f..74bee09b5d 100644 --- a/library/cpp/containers/comptrie/comptrie_ut.cpp +++ b/library/cpp/containers/comptrie/comptrie_ut.cpp @@ -340,13 +340,13 @@ static bool LexicographicStep(TString& s) { template <class T> void TCompactTrieTest::CheckUpperBound(const char* data, size_t datalen) { TCompactTrie<T> trie(data, datalen); - typedef typename TCompactTrie<T>::TKey TKey; - typedef typename TCompactTrie<T>::TData TData; + typedef typename TCompactTrie<T>::TKey TKey; + typedef typename TCompactTrie<T>::TData TData; TString key; do { const TKey wideKey = MakeWideKey<T>(key); - typename TCompactTrie<T>::TConstIterator it = trie.UpperBound(wideKey); + typename TCompactTrie<T>::TConstIterator it = trie.UpperBound(wideKey); UNIT_ASSERT_C(it == trie.End() || it.GetKey() >= wideKey, "key=" + key); TData data; const bool found = trie.Find(wideKey, &data); @@ -454,7 +454,7 @@ void TCompactTrieTest::CheckIterator(const char* data, size_t datalen) { std::reverse(items.begin(), items.end()); typename TCompactTrie<T>::TConstIterator revIt = trie.End(); typename TCompactTrie<T>::TConstIterator const begin = trie.Begin(); - typename TCompactTrie<T>::TConstIterator emptyIt; + typename TCompactTrie<T>::TConstIterator emptyIt; size_t pos = 0; while (revIt != begin) { revIt--; @@ -465,11 +465,11 @@ void TCompactTrieTest::CheckIterator(const char* data, size_t datalen) { revIt = begin; UNIT_ASSERT(revIt == trie.Begin()); UNIT_ASSERT(!revIt.IsEmpty()); - UNIT_ASSERT(revIt != emptyIt); + UNIT_ASSERT(revIt != emptyIt); UNIT_ASSERT(revIt != trie.End()); ++revIt; // Call a method that uses Skipper. - revIt = emptyIt; - UNIT_ASSERT(revIt == emptyIt); + revIt = emptyIt; + UNIT_ASSERT(revIt == emptyIt); UNIT_ASSERT(revIt.IsEmpty()); UNIT_ASSERT(revIt != trie.End()); // Checking the move assignment operator. diff --git a/library/cpp/deprecated/kmp/kmp_ut.cpp b/library/cpp/deprecated/kmp/kmp_ut.cpp index cc46b96c00..c2eda83c57 100644 --- a/library/cpp/deprecated/kmp/kmp_ut.cpp +++ b/library/cpp/deprecated/kmp/kmp_ut.cpp @@ -29,7 +29,7 @@ public: UNIT_ASSERT_EQUAL(FindAll("a", "aba"), ans); ans = {0}; UNIT_ASSERT_EQUAL(FindAll("aba", "aba"), ans); - ans.clear(); + ans.clear(); UNIT_ASSERT_EQUAL(FindAll("abad", "aba"), ans); ans = {0, 2}; UNIT_ASSERT_EQUAL(FindAll("ab", "abab"), ans); diff --git a/library/cpp/deprecated/mapped_file/mapped_file.cpp b/library/cpp/deprecated/mapped_file/mapped_file.cpp index db995c67ee..b0e4511299 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.cpp +++ b/library/cpp/deprecated/mapped_file/mapped_file.cpp @@ -23,7 +23,7 @@ TMappedFile::TMappedFile(const TFile& file, TFileMap::EOpenMode om, const char* void TMappedFile::precharge(size_t off, size_t size) const { if (!Map_) return; - + Map_->Precharge(off, size); } diff --git a/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp b/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp index 057a5f6bc6..afbd5b3358 100644 --- a/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp +++ b/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp @@ -8,10 +8,10 @@ Y_UNIT_TEST_SUITE(TMappedFileTest) { Y_UNIT_TEST(TestFileMapEmpty) { TFile file(FileName_, CreateAlways | WrOnly); file.Close(); - + TMappedFile map; map.init(FileName_); - map.getData(0); + map.getData(0); NFs::Remove(FileName_); } diff --git a/library/cpp/getopt/small/modchooser.cpp b/library/cpp/getopt/small/modchooser.cpp index 10e6f741e4..2fa5cfd070 100644 --- a/library/cpp/getopt/small/modchooser.cpp +++ b/library/cpp/getopt/small/modchooser.cpp @@ -189,7 +189,7 @@ int TModChooser::Run(const int argc, const char** argv) const { return 0; } if (!SvnRevisionOptionDisabled && modeName == "--svnrevision") { - NLastGetopt::PrintVersionAndExit(nullptr); + NLastGetopt::PrintVersionAndExit(nullptr); } auto modeIter = Modes.find(modeName); diff --git a/library/cpp/getopt/small/opt.cpp b/library/cpp/getopt/small/opt.cpp index ee44f7c77d..744501765c 100644 --- a/library/cpp/getopt/small/opt.cpp +++ b/library/cpp/getopt/small/opt.cpp @@ -25,7 +25,7 @@ void Opt::Init(int argc, char* argv[], const char* optString, const Ion* longOpt Opts_.Reset(new TOptsNoDefault(optString)); for (const Ion* o = longOptions; o != nullptr && o->name != nullptr; ++o) { TOpt* opt; - if ((unsigned)o->val < 0x80 && isalnum(o->val)) { + if ((unsigned)o->val < 0x80 && isalnum(o->val)) { opt = &Opts_->CharOption(char(o->val)); opt->AddLongName(o->name); } else { @@ -73,7 +73,7 @@ int Opt::Get(int* longOptionIndex) { return 1; } else { const Ion* ion = (const Ion*)OptsParser_->CurOpt()->UserValue(); - if (longOptionIndex) { + if (longOptionIndex) { *longOptionIndex = int(ion - Ions_); } char c = OptsParser_->CurOpt()->GetCharOr0(); diff --git a/library/cpp/getopt/small/posix_getopt.cpp b/library/cpp/getopt/small/posix_getopt.cpp index 5ccf6e76cb..bd06f3499f 100644 --- a/library/cpp/getopt/small/posix_getopt.cpp +++ b/library/cpp/getopt/small/posix_getopt.cpp @@ -27,7 +27,7 @@ namespace NLastGetopt { for (const struct option* o = longopts; o != nullptr && o->name != nullptr; ++o) { TOpt* opt; - if ((unsigned)o->val < 0x80 && isalnum(o->val)) { + if ((unsigned)o->val < 0x80 && isalnum(o->val)) { opt = &Opts->CharOption(char(o->val)); opt->AddLongName(o->name); } else { @@ -49,9 +49,9 @@ namespace NLastGetopt { } else { optarg = (char*)OptsParser->CurVal(); optind = (int)OptsParser->Pos_; - if (longindex && OptsParser->CurOpt()) + if (longindex && OptsParser->CurOpt()) *longindex = (int)Opts->IndexOf(OptsParser->CurOpt()); - return OptsParser->CurOpt() ? OptsParser->CurOpt()->GetCharOr0() : 1; + return OptsParser->CurOpt() ? OptsParser->CurOpt()->GetCharOr0() : 1; } } catch (const NLastGetopt::TException&) { return '?'; diff --git a/library/cpp/http/fetch/http_digest.h b/library/cpp/http/fetch/http_digest.h index 62cda1a29f..3b1872d70b 100644 --- a/library/cpp/http/fetch/http_digest.h +++ b/library/cpp/http/fetch/http_digest.h @@ -43,5 +43,5 @@ public: return (!User_); } - const char* getHeaderInstruction() const; + const char* getHeaderInstruction() const; }; diff --git a/library/cpp/http/fetch/httpfetcher.h b/library/cpp/http/fetch/httpfetcher.h index fa7e7ab1c5..7fc251afd2 100644 --- a/library/cpp/http/fetch/httpfetcher.h +++ b/library/cpp/http/fetch/httpfetcher.h @@ -36,16 +36,16 @@ public: static int TerminateNow; THttpFetcher() - : THttpParser<TCheck>() - , TAlloc() - , TWriter() - , TAgent() + : THttpParser<TCheck>() + , TAlloc() + , TWriter() + , TAgent() { } - + virtual ~THttpFetcher() { } - + int Fetch(THttpHeader* header, const char* path, const char* const* headers, int persistent, bool head_request = false) { int ret = 0; int fetcherr = 0; diff --git a/library/cpp/http/fetch/httpfsm.rl6 b/library/cpp/http/fetch/httpfsm.rl6 index 35a6f972bb..eab0328b18 100644 --- a/library/cpp/http/fetch/httpfsm.rl6 +++ b/library/cpp/http/fetch/httpfsm.rl6 @@ -11,10 +11,10 @@ #include <library/cpp/http/fetch/httpheader.h> #include <library/cpp/http/fetch/httpfsm.h> -#ifdef _MSC_VER -#pragma warning(disable: 4702) // unreachable code -#endif - +#ifdef _MSC_VER +#pragma warning(disable: 4702) // unreachable code +#endif + #define c(i) I = i; #define m(i) I = std::max(I, (long)i); diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp index 8a1319bc10..6689be684f 100644 --- a/library/cpp/http/io/stream.cpp +++ b/library/cpp/http/io/stream.cpp @@ -284,7 +284,7 @@ private: inline void BuildInputChain() { TParsedHeaders p; - + size_t pos = FirstLine_.rfind(' '); // In HTTP/1.1 Keep-Alive is turned on by default if (pos != TString::npos && strcmp(FirstLine_.c_str() + pos + 1, "HTTP/1.1") == 0) { @@ -321,7 +321,7 @@ private: p.KeepAlive = true; } else if (stricmp(header.Value().data(), "close") == 0) { p.KeepAlive = false; - } + } } [[fallthrough]]; HEADERCMP(header, "expect") { @@ -536,7 +536,7 @@ public: if (*c == '\n') { Line_.append(b, c); - if (!Line_.empty() && Line_.back() == '\r') { + if (!Line_.empty() && Line_.back() == '\r') { Line_.pop_back(); } @@ -906,7 +906,7 @@ void THttpOutput::DoFinish() { } const THttpHeaders& THttpOutput::SentHeaders() const noexcept { - return Impl_->SentHeaders(); + return Impl_->SentHeaders(); } void THttpOutput::EnableCompression(bool enable) { diff --git a/library/cpp/http/misc/httpdate.h b/library/cpp/http/misc/httpdate.h index 16907280d2..04876f38fe 100644 --- a/library/cpp/http/misc/httpdate.h +++ b/library/cpp/http/misc/httpdate.h @@ -7,7 +7,7 @@ #define BAD_DATE ((time_t)-1) -inline time_t parse_http_date(const TStringBuf& datestring) { +inline time_t parse_http_date(const TStringBuf& datestring) { try { return TInstant::ParseHttpDeprecated(datestring).TimeT(); } catch (const TDateTimeParseException&) { diff --git a/library/cpp/http/misc/httpreqdata.h b/library/cpp/http/misc/httpreqdata.h index 08f10a2717..16e59c4d78 100644 --- a/library/cpp/http/misc/httpreqdata.h +++ b/library/cpp/http/misc/httpreqdata.h @@ -28,7 +28,7 @@ public: } const TString& ServerName() const { - return Host; + return Host; } NAddr::IRemoteAddrPtr ServerAddress() const { @@ -36,7 +36,7 @@ public: } const TString& ServerPort() const { - return Port; + return Port; } const char* ScriptName() const { @@ -96,7 +96,7 @@ private: size_t SearchLength; // length of Search TStringBuf OrigSearch; THttpHeadersContainer HeadersIn_; - mutable char AddrData[INET6_ADDRSTRLEN]; + mutable char AddrData[INET6_ADDRSTRLEN]; SOCKET Socket; ui64 BeginTime; mutable TString CurPage; diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index d63d86e26f..128583bdd7 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -172,11 +172,11 @@ public: ErrorCode = WSAGetLastError(); } - int GetErrorCode() const { + int GetErrorCode() const { return ErrorCode; } - const char* GetError() const { + const char* GetError() const { return LastSystemErrorText(ErrorCode); } @@ -213,7 +213,7 @@ public: void Wait() { Cb_->OnWait(); TGuard<TMutex> g(StopMutex); - if (ListenThread) { + if (ListenThread) { ListenThread->Join(); ListenThread.Reset(nullptr); } @@ -223,7 +223,7 @@ public: Shutdown(); TGuard<TMutex> g(StopMutex); - if (ListenThread) { + if (ListenThread) { ListenThread->Join(); ListenThread.Reset(nullptr); } @@ -560,7 +560,7 @@ TClientConnection::TClientConnection(const TSocket& s, THttpServer::TImpl* serv, const TDuration& clientTimeout = HttpServ_->Options().ClientTimeout; if (clientTimeout != TDuration::Zero()) { - SetSocketTimeout(Socket_, (long)clientTimeout.Seconds(), clientTimeout.MilliSecondsOfSecond()); + SetSocketTimeout(Socket_, (long)clientTimeout.Seconds(), clientTimeout.MilliSecondsOfSecond()); } HttpServ_->IncreaseConnections(); @@ -738,7 +738,7 @@ void TClientRequest::ProcessFailRequest(int failstate) { // Skipping spaces before url... size_t start = 3; - while (str[start] == ' ') { + while (str[start] == ' ') { ++start; } diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp index 38ae9cd4e6..c61e8d1dc4 100644 --- a/library/cpp/json/writer/json_value.cpp +++ b/library/cpp/json/writer/json_value.cpp @@ -73,7 +73,7 @@ namespace NJson { TJsonValue::TJsonValue(const EJsonValueType type) { SetType(type); } - + TJsonValue::TJsonValue(TJsonValue&& vval) noexcept : Type(JSON_UNDEFINED) { diff --git a/library/cpp/json/writer/json_value.h b/library/cpp/json/writer/json_value.h index 0b18f1ab3e..3f0f50bc4c 100644 --- a/library/cpp/json/writer/json_value.h +++ b/library/cpp/json/writer/json_value.h @@ -203,7 +203,7 @@ namespace NJson { TString String; TMapType* Map; TArray* Array; - + TValueUnion() noexcept { Zero(*this); } diff --git a/library/cpp/logger/system.cpp b/library/cpp/logger/system.cpp index 2c223b4463..42233f63d2 100644 --- a/library/cpp/logger/system.cpp +++ b/library/cpp/logger/system.cpp @@ -55,7 +55,7 @@ TSysLogBackend::~TSysLogBackend() { void TSysLogBackend::WriteData(const TLogRecord& rec) { #if defined(_unix_) syslog(ELogPriority2SyslogPriority(rec.Priority), "%.*s", (int)rec.Len, rec.Data); -#else +#else Y_UNUSED(rec); #endif } diff --git a/library/cpp/mime/types/mime.cpp b/library/cpp/mime/types/mime.cpp index 3fa0cd9ada..706d776b24 100644 --- a/library/cpp/mime/types/mime.cpp +++ b/library/cpp/mime/types/mime.cpp @@ -9,49 +9,49 @@ #include <cctype> /* - * MIME types + * MIME types */ -class TMimeTypes { +class TMimeTypes { // Constructor -public: - TMimeTypes(); - +public: + TMimeTypes(); + // Methods -public: - const char* StrByExt(const char* ext) const; +public: + const char* StrByExt(const char* ext) const; MimeTypes MimeByStr(const char* str) const; - MimeTypes MimeByStr(const TStringBuf& str) const; - const char* StrByMime(MimeTypes mime) const; - + MimeTypes MimeByStr(const TStringBuf& str) const; + const char* StrByMime(MimeTypes mime) const; + // Constants -public: +public: static const size_t MAX_EXT_LEN = 11; // max length of supported extensions - + // Helper methods -private: - void SetContentTypes(); - void SetExt(); - +private: + void SetContentTypes(); + void SetExt(); + // Types -private: - struct TRecord { - MimeTypes Mime; - const char* ContentType; - const char* Ext; - }; - +private: + struct TRecord { + MimeTypes Mime; + const char* ContentType; + const char* Ext; + }; + typedef THashMap<const char*, int> TRecordHash; - + // Fields -private: - static const TRecord Records[]; - TRecordHash ContentTypes; - TRecordHash Ext; -}; - -const TMimeTypes::TRecord TMimeTypes::Records[] = { +private: + static const TRecord Records[]; + TRecordHash ContentTypes; + TRecordHash Ext; +}; + +const TMimeTypes::TRecord TMimeTypes::Records[] = { {MIME_UNKNOWN, nullptr, nullptr}, {MIME_TEXT, "text/plain\0", "asc\0txt\0"}, {MIME_HTML, "text/html\0", "html\0htm\0shtml\0"}, @@ -86,7 +86,7 @@ const TMimeTypes::TRecord TMimeTypes::Records[] = { {MIME_TEX, "application/x-tex\0application/x-latex\0text/x-tex\0", "tex\0"}, {MIME_JSON, "application/json\0", "json\0"}, {MIME_APK, "application/vnd.android.package-archive\0", "apk\0"}, - {MIME_CSS, "text/css\0", "css\0"}, + {MIME_CSS, "text/css\0", "css\0"}, {MIME_IMAGE_WEBP, "image/webp\0", "webp\0"}, {MIME_DJVU, "image/vnd.djvu\0image/x-djvu\0", "djvu\0djv\0"}, {MIME_CHM, "application/x-chm\0application/vnd.ms-htmlhelp\0", "chm\0"}, @@ -100,70 +100,70 @@ const TMimeTypes::TRecord TMimeTypes::Records[] = { {MIME_TTF, "font/ttf\0", "ttf\0"}, {MIME_WEBMANIFEST, "application/manifest+json\0", "webmanifest\0"}, {MIME_MAX, nullptr, nullptr}, - - // Additional records + + // Additional records {MIME_HTML, "application/xhtml+xml\0", "xhtml\0"}, -}; - -TMimeTypes::TMimeTypes() +}; + +TMimeTypes::TMimeTypes() : ContentTypes() , Ext() -{ - SetContentTypes(); - SetExt(); -} - -void TMimeTypes::SetContentTypes() { +{ + SetContentTypes(); + SetExt(); +} + +void TMimeTypes::SetContentTypes() { for (int i = 0; i < (int)Y_ARRAY_SIZE(Records); ++i) { - const TRecord& record(Records[i]); - assert(i == record.Mime || i > MIME_MAX || record.Mime == MIME_UNKNOWN); - if (!record.ContentType) - continue; - for (const char* type = record.ContentType; *type; type += strlen(type) + 1) { - assert(ContentTypes.find(type) == ContentTypes.end()); - ContentTypes[type] = i; - } - } -} - -void TMimeTypes::SetExt() { + const TRecord& record(Records[i]); + assert(i == record.Mime || i > MIME_MAX || record.Mime == MIME_UNKNOWN); + if (!record.ContentType) + continue; + for (const char* type = record.ContentType; *type; type += strlen(type) + 1) { + assert(ContentTypes.find(type) == ContentTypes.end()); + ContentTypes[type] = i; + } + } +} + +void TMimeTypes::SetExt() { for (int i = 0; i < (int)Y_ARRAY_SIZE(Records); ++i) { - const TRecord& record(Records[i]); - if (!record.Ext) - continue; - for (const char* ext = record.Ext; *ext; ext += strlen(ext) + 1) { - assert(strlen(ext) <= MAX_EXT_LEN); - assert(Ext.find(ext) == Ext.end()); - Ext[ext] = i; - } - } -} - -const char* TMimeTypes::StrByExt(const char* ext) const { - TRecordHash::const_iterator it = Ext.find(ext); - if (it == Ext.end()) + const TRecord& record(Records[i]); + if (!record.Ext) + continue; + for (const char* ext = record.Ext; *ext; ext += strlen(ext) + 1) { + assert(strlen(ext) <= MAX_EXT_LEN); + assert(Ext.find(ext) == Ext.end()); + Ext[ext] = i; + } + } +} + +const char* TMimeTypes::StrByExt(const char* ext) const { + TRecordHash::const_iterator it = Ext.find(ext); + if (it == Ext.end()) return nullptr; - return Records[it->second].ContentType; -} - -MimeTypes TMimeTypes::MimeByStr(const char* str) const { - TRecordHash::const_iterator it = ContentTypes.find(str); - if (it == ContentTypes.end()) - return MIME_UNKNOWN; - return Records[it->second].Mime; -} - -MimeTypes TMimeTypes::MimeByStr(const TStringBuf& str) const { - TRecordHash::const_iterator it = ContentTypes.find(str); - if (it == ContentTypes.end()) - return MIME_UNKNOWN; - return Records[it->second].Mime; -} - -const char* TMimeTypes::StrByMime(MimeTypes mime) const { - return Records[mime].ContentType; -} - + return Records[it->second].ContentType; +} + +MimeTypes TMimeTypes::MimeByStr(const char* str) const { + TRecordHash::const_iterator it = ContentTypes.find(str); + if (it == ContentTypes.end()) + return MIME_UNKNOWN; + return Records[it->second].Mime; +} + +MimeTypes TMimeTypes::MimeByStr(const TStringBuf& str) const { + TRecordHash::const_iterator it = ContentTypes.find(str); + if (it == ContentTypes.end()) + return MIME_UNKNOWN; + return Records[it->second].Mime; +} + +const char* TMimeTypes::StrByMime(MimeTypes mime) const { + return Records[mime].ContentType; +} + const char* mimetypeByExt(const char* fname, const char* check_ext) { const char* ext_p; if (fname == nullptr || *fname == 0 || @@ -171,7 +171,7 @@ const char* mimetypeByExt(const char* fname, const char* check_ext) { return nullptr; } - char ext[TMimeTypes::MAX_EXT_LEN + 1]; + char ext[TMimeTypes::MAX_EXT_LEN + 1]; size_t i; ext_p++; for (i = 0; i < TMimeTypes::MAX_EXT_LEN && ext_p[i]; i++) @@ -185,23 +185,23 @@ const char* mimetypeByExt(const char* fname, const char* check_ext) { return nullptr; } - return Singleton<TMimeTypes>()->StrByExt(ext); + return Singleton<TMimeTypes>()->StrByExt(ext); +} + +MimeTypes mimeByStr(const char* mimeStr) { + return Singleton<TMimeTypes>()->MimeByStr(mimeStr); } -MimeTypes mimeByStr(const char* mimeStr) { - return Singleton<TMimeTypes>()->MimeByStr(mimeStr); -} - -MimeTypes mimeByStr(const TStringBuf& mimeStr) { - return Singleton<TMimeTypes>()->MimeByStr(mimeStr); -} - -const char* strByMime(MimeTypes mime) { - if (mime < 0 || mime > MIME_MAX) +MimeTypes mimeByStr(const TStringBuf& mimeStr) { + return Singleton<TMimeTypes>()->MimeByStr(mimeStr); +} + +const char* strByMime(MimeTypes mime) { + if (mime < 0 || mime > MIME_MAX) return nullptr; // index may contain documents with invalid MIME (ex. 255) - return Singleton<TMimeTypes>()->StrByMime(mime); -} - + return Singleton<TMimeTypes>()->StrByMime(mime); +} + const char* MimeNames[MIME_MAX] = { "unknown", // MIME_UNKNOWN // 0 "text", // MIME_TEXT // 1 @@ -237,7 +237,7 @@ const char* MimeNames[MIME_MAX] = { "tex", // MIME_TEX // 31 "json", // MIME_JSON // 32 "apk", // MIME_APK // 33 - "css", // MIME_CSS // 34 + "css", // MIME_CSS // 34 "webp", // MIME_IMAGE_WEBP // 35 "djvu", // MIME_DJVU // 36 "chm", // MIME_CHM // 37 diff --git a/library/cpp/mime/types/mime.h b/library/cpp/mime/types/mime.h index e9ba5a92db..05da389ea9 100644 --- a/library/cpp/mime/types/mime.h +++ b/library/cpp/mime/types/mime.h @@ -45,7 +45,7 @@ enum MimeTypes { MIME_TEX = 31, MIME_JSON = 32, MIME_APK = 33, - MIME_CSS = 34, + MIME_CSS = 34, MIME_IMAGE_WEBP = 35, MIME_DJVU = 36, MIME_CHM = 37, @@ -65,8 +65,8 @@ extern const char* MimeNames[MIME_MAX]; const char* mimetypeByExt(const char* fname, const char* check_ext = nullptr); MimeTypes mimeByStr(const char* mimeStr); -MimeTypes mimeByStr(const TStringBuf& mimeStr); -const char* strByMime(MimeTypes mime); +MimeTypes mimeByStr(const TStringBuf& mimeStr); +const char* strByMime(MimeTypes mime); // autogenerated with GENERATE_ENUM_SERIALIZATION const TString& ToString(MimeTypes x); diff --git a/library/cpp/packers/packers.h b/library/cpp/packers/packers.h index d947722c98..1bde1b59aa 100644 --- a/library/cpp/packers/packers.h +++ b/library/cpp/packers/packers.h @@ -42,7 +42,7 @@ public: } size_t MeasureLeaf(const T& data) const { Y_UNUSED(data); - return sizeof(T); + return sizeof(T); } size_t SkipLeaf(const char*) const { return sizeof(T); diff --git a/library/cpp/regex/pcre/regexp.cpp b/library/cpp/regex/pcre/regexp.cpp index d13d532572..575c09cee4 100644 --- a/library/cpp/regex/pcre/regexp.cpp +++ b/library/cpp/regex/pcre/regexp.cpp @@ -1,7 +1,7 @@ #include "regexp.h" #include <util/generic/string.h> -#include <util/string/ascii.h> +#include <util/string/ascii.h> #include <util/system/defaults.h> #include <cstdlib> @@ -154,7 +154,7 @@ public: const size_t ERRBUF_SIZE = 100; char errbuf[ERRBUF_SIZE]; regerror(rc, &Preg, errbuf, ERRBUF_SIZE); - Error = "Error: regular expression " + re + " is wrong: " + errbuf; + Error = "Error: regular expression " + re + " is wrong: " + errbuf; ythrow yexception() << "RegExp " << re << ": " << Error.data(); } } @@ -192,7 +192,7 @@ private: }; bool TRegExBase::IsCompiled() const { - return Impl && Impl->IsCompiled(); + return Impl && Impl->IsCompiled(); } TRegExBase::TRegExBase(const char* re, int cflags) { @@ -202,9 +202,9 @@ TRegExBase::TRegExBase(const char* re, int cflags) { } TRegExBase::TRegExBase(const TString& re, int cflags) { - Compile(re, cflags); -} - + Compile(re, cflags); +} + TRegExBase::~TRegExBase() { } @@ -236,10 +236,10 @@ TRegExMatch::TRegExMatch(const char* re, int cflags) } TRegExMatch::TRegExMatch(const TString& re, int cflags) - : TRegExBase(re, cflags) -{ -} - + : TRegExBase(re, cflags) +{ +} + bool TRegExMatch::Match(const char* str) const { return Exec(str, nullptr, 0, 0) == 0; } @@ -294,7 +294,7 @@ int TRegExSubst::ParseReplacement(const char* repl) { pos2 = pos1; if (pos1) { pos2 = pos1 + 1; - while (IsAsciiDigit(*pos2)) + while (IsAsciiDigit(*pos2)) pos2++; if (pos2 > pos1 + 1) { Brfs[i].Refer = atol(TString(Replacement, pos1 + 1 - Replacement, pos2 - (pos1 + 1)).data()); diff --git a/library/cpp/scheme/ya.make b/library/cpp/scheme/ya.make index da4e9d2ee2..bac08ba5a4 100644 --- a/library/cpp/scheme/ya.make +++ b/library/cpp/scheme/ya.make @@ -4,9 +4,9 @@ OWNER(velavokr) SRCS( scheme.cpp - scheme_cast.h - scimpl.h - scimpl_defs.h + scheme_cast.h + scimpl.h + scimpl_defs.h scimpl_private.cpp scimpl_protobuf.cpp scimpl_select.rl6 diff --git a/library/cpp/streams/bzip2/bzip2.cpp b/library/cpp/streams/bzip2/bzip2.cpp index cba78c4ad6..bccc5c6807 100644 --- a/library/cpp/streams/bzip2/bzip2.cpp +++ b/library/cpp/streams/bzip2/bzip2.cpp @@ -190,7 +190,7 @@ void TBZipCompress::DoWrite(const void* buf, size_t size) { } void TBZipCompress::DoFlush() { - if (Impl_) { + if (Impl_) { Impl_->Flush(); } } @@ -198,7 +198,7 @@ void TBZipCompress::DoFlush() { void TBZipCompress::DoFinish() { THolder<TImpl> impl(Impl_.Release()); - if (impl) { + if (impl) { impl->Finish(); } } diff --git a/library/cpp/streams/lzma/lzma.cpp b/library/cpp/streams/lzma/lzma.cpp index 900a5b884b..f1942fa546 100644 --- a/library/cpp/streams/lzma/lzma.cpp +++ b/library/cpp/streams/lzma/lzma.cpp @@ -497,7 +497,7 @@ void TLzmaCompress::DoWrite(const void* buf, size_t len) { void TLzmaCompress::DoFinish() { THolder<TImpl> impl(Impl_.Release()); - if (impl) { + if (impl) { impl->Finish(); } } diff --git a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h index 859b6698c8..8a240bfed8 100644 --- a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h +++ b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h @@ -154,12 +154,12 @@ namespace NLevenshtein { /// Calculates substrings to be replaced for str1->str2 transformation struct TReplacement { int CorrectOffset, CorrectLength, MisspelledOffset, MisspelledLength; - TReplacement() - : CorrectOffset(0) - , CorrectLength(0) - , MisspelledOffset(0) - , MisspelledLength(0) - { + TReplacement() + : CorrectOffset(0) + , CorrectLength(0) + , MisspelledOffset(0) + , MisspelledLength(0) + { } TReplacement(int correctOffset, int correctLength, int misspelledOffset, int misspelledLength) : CorrectOffset(correctOffset) diff --git a/library/cpp/testing/common/env.cpp b/library/cpp/testing/common/env.cpp index 2da27631e3..fa3a47fe16 100644 --- a/library/cpp/testing/common/env.cpp +++ b/library/cpp/testing/common/env.cpp @@ -2,7 +2,7 @@ #include <build/scripts/c_templates/svnversion.h> -#include <util/folder/dirut.h> +#include <util/folder/dirut.h> #include <util/folder/path.h> #include <util/generic/singleton.h> #include <util/stream/file.h> @@ -48,21 +48,21 @@ TString GetArcadiaTestsData() { TString path = NPrivate::GetCwd(); const char pathsep = GetDirectorySeparator(); - while (!path.empty()) { + while (!path.empty()) { TString dataDir = path + "/arcadia_tests_data"; if (IsDir(dataDir)) { - return dataDir; + return dataDir; } - + size_t pos = path.find_last_of(pathsep); if (pos == TString::npos) { - pos = 0; + pos = 0; } - path.erase(pos); - } - + path.erase(pos); + } + return {}; -} +} TString GetWorkPath() { TString workPath = NPrivate::GetTestEnv().WorkPath; diff --git a/library/cpp/testing/common/env.h b/library/cpp/testing/common/env.h index 8256fc8656..7b89aa1bed 100644 --- a/library/cpp/testing/common/env.h +++ b/library/cpp/testing/common/env.h @@ -1,12 +1,12 @@ #pragma once - + #include <unordered_map> #include <util/folder/path.h> #include <util/generic/string.h> #include <util/generic/strbuf.h> #include <util/system/src_location.h> - + // @brief return full path to arcadia root TString ArcadiaSourceRoot(); diff --git a/library/cpp/testing/unittest/checks.cpp b/library/cpp/testing/unittest/checks.cpp index 2fbbde6ceb..c5712ae9d2 100644 --- a/library/cpp/testing/unittest/checks.cpp +++ b/library/cpp/testing/unittest/checks.cpp @@ -1,31 +1,31 @@ #include <util/generic/string.h> #include <util/string/type.h> - + bool CheckExceptionMessage(const char* msg, TString& err) { - static const char* badMsg[] = { + static const char* badMsg[] = { // Операция успешно завершена [cp1251] "\xce\xef\xe5\xf0\xe0\xf6\xe8\xff\x20\xf3\xf1\xef\xe5\xf8\xed\xee\x20\xe7\xe0\xe2\xe5\xf0\xf8\xe5\xed\xe0", - "The operation completed successfully", + "The operation completed successfully", "No error"}; - - err.clear(); - + + err.clear(); + if (msg == nullptr) { - err = "Error message is null"; - return false; - } - - if (IsSpace(msg)) { - err = "Error message is empty"; - return false; - } - + err = "Error message is null"; + return false; + } + + if (IsSpace(msg)) { + err = "Error message is empty"; + return false; + } + for (auto& i : badMsg) { if (strstr(msg, i) != nullptr) { err = "Invalid error message: " + TString(msg); - return false; - } - } - - return true; -} + return false; + } + } + + return true; +} diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h index d8db81d556..44517a0092 100644 --- a/library/cpp/testing/unittest/registar.h +++ b/library/cpp/testing/unittest/registar.h @@ -7,7 +7,7 @@ #include <util/generic/intrlist.h> #include <util/generic/map.h> #include <util/generic/ptr.h> -#include <util/generic/set.h> +#include <util/generic/set.h> #include <util/generic/typetraits.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> @@ -86,19 +86,19 @@ namespace NUnitTest { }; struct TTest { - const TUnit* unit; - const char* name; + const TUnit* unit; + const char* name; }; struct TError { - const TTest* test; - const char* msg; + const TTest* test; + const char* msg; TString BackTrace; TTestContext* Context; }; struct TFinish { - const TTest* test; + const TTest* test; TTestContext* Context; bool Success; }; @@ -790,7 +790,7 @@ public: \ } inline TString Name() const noexcept override { - return T::StaticName(); + return T::StaticName(); } }; diff --git a/library/cpp/testing/unittest/tests_data.cpp b/library/cpp/testing/unittest/tests_data.cpp index 8aa7d6eaa7..b51cbc4b87 100644 --- a/library/cpp/testing/unittest/tests_data.cpp +++ b/library/cpp/testing/unittest/tests_data.cpp @@ -1,8 +1,8 @@ -#include "tests_data.h" +#include "tests_data.h" #include "registar.h" - + #include <library/cpp/testing/common/network.h> - + #include <util/system/env.h> #include <util/system/mutex.h> diff --git a/library/cpp/testing/unittest/tests_data.h b/library/cpp/testing/unittest/tests_data.h index 4643a77e38..6536bc1ae6 100644 --- a/library/cpp/testing/unittest/tests_data.h +++ b/library/cpp/testing/unittest/tests_data.h @@ -1,12 +1,12 @@ #pragma once - + #include <library/cpp/testing/common/env.h> #include <util/generic/noncopyable.h> #include <util/generic/ptr.h> #include <util/generic/string.h> #include <util/network/sock.h> - + class TInet6StreamSocket; // set two options: SO_REUSEADDR and SO_REUSEPORT, both are required for diff --git a/library/cpp/testing/unittest/utmain.cpp b/library/cpp/testing/unittest/utmain.cpp index d9fc967886..305bc6b40f 100644 --- a/library/cpp/testing/unittest/utmain.cpp +++ b/library/cpp/testing/unittest/utmain.cpp @@ -83,7 +83,7 @@ private: inline void TraceSubtestFinished(const char* className, const char* subtestName, const char* status, const TString comment, const TTestContext* context) { const TInstant now = TInstant::Now(); - NJson::TJsonValue event; + NJson::TJsonValue event; event.InsertValue("class", className); event.InsertValue("subtest", subtestName); event.InsertValue("status", status); @@ -116,7 +116,7 @@ private: } void OnBeforeTest(const TTest* test) override { - NJson::TJsonValue event; + NJson::TJsonValue event; event.InsertValue("class", test->unit->name); event.InsertValue("subtest", test->name); Trace("subtest-started", event); @@ -128,13 +128,13 @@ private: } void OnUnitStart(const TUnit* unit) override { - NJson::TJsonValue event; + NJson::TJsonValue event; event.InsertValue("class", unit->name); Trace("test-started", event); } void OnUnitStop(const TUnit* unit) override { - NJson::TJsonValue event; + NJson::TJsonValue event; event.InsertValue("class", unit->name); Trace("test-finished", event); } @@ -417,7 +417,7 @@ private: fprintf(stderr, ", err: %s%u%s", LightRedColor().data(), FailTests(), OldColor().data()); fprintf(stderr, "\n"); - + if (ShowFails) { for (size_t i = 0; i < Fails.size(); ++i) { printf("%s", Fails[i].data()); @@ -567,16 +567,16 @@ private: IOutputStream& Stream_; }; -#ifdef _win_ -class TWinEnvironment { -public: - TWinEnvironment() +#ifdef _win_ +class TWinEnvironment { +public: + TWinEnvironment() : OutputCP(GetConsoleOutputCP()) - { - setmode(fileno(stdout), _O_BINARY); - SetConsoleOutputCP(CP_UTF8); - - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); + { + setmode(fileno(stdout), _O_BINARY); + SetConsoleOutputCP(CP_UTF8); + + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); if (!IsDebuggerPresent()) { _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); @@ -586,20 +586,20 @@ public: } } ~TWinEnvironment() { - if (!IsDebuggerPresent()) { - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); - _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); - } - - SetConsoleOutputCP(OutputCP); // restore original output CP at program exit - } - -private: - UINT OutputCP; // original codepage -}; -static const TWinEnvironment Instance; -#endif // _win_ - + if (!IsDebuggerPresent()) { + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + } + + SetConsoleOutputCP(OutputCP); // restore original output CP at program exit + } + +private: + UINT OutputCP; // original codepage +}; +static const TWinEnvironment Instance; +#endif // _win_ + static int DoList(bool verbose, IOutputStream& stream) { TEnumeratingProcessor eproc(verbose, stream); TTestFactory::Instance().SetProcessor(&eproc); diff --git a/library/cpp/testing/unittest/ya.make b/library/cpp/testing/unittest/ya.make index bdc71c13cc..aaa4f2ba85 100644 --- a/library/cpp/testing/unittest/ya.make +++ b/library/cpp/testing/unittest/ya.make @@ -18,10 +18,10 @@ PEERDIR( SRCS( gtest.cpp - checks.cpp + checks.cpp plugin.cpp registar.cpp - tests_data.cpp + tests_data.cpp utmain.cpp ) diff --git a/library/cpp/unicode/normalization/normalization.h b/library/cpp/unicode/normalization/normalization.h index 4acef5f0eb..4f5f57881c 100644 --- a/library/cpp/unicode/normalization/normalization.h +++ b/library/cpp/unicode/normalization/normalization.h @@ -84,9 +84,9 @@ namespace NUnicode { class TComposition { private: struct TRawData { - wchar32 Lead; - wchar32 Tail; - wchar32 Comp; + wchar32 Lead; + wchar32 Tail; + wchar32 Comp; }; static const TRawData RawData[]; diff --git a/library/cpp/uri/encodefsm.rl6 b/library/cpp/uri/encodefsm.rl6 index b184fb2e9c..6a323aa85a 100644 --- a/library/cpp/uri/encodefsm.rl6 +++ b/library/cpp/uri/encodefsm.rl6 @@ -1,9 +1,9 @@ #include <library/cpp/uri/encode.h> -#ifdef __clang__ - #pragma clang diagnostic ignored "-Wunused-variable" -#endif - +#ifdef __clang__ + #pragma clang diagnostic ignored "-Wunused-variable" +#endif + namespace NUri { namespace NEncode { diff --git a/library/cpp/uri/parsefsm.rl6 b/library/cpp/uri/parsefsm.rl6 index 70c4833c32..7097723650 100644 --- a/library/cpp/uri/parsefsm.rl6 +++ b/library/cpp/uri/parsefsm.rl6 @@ -1,9 +1,9 @@ #include <library/cpp/uri/parse.h> -#ifdef __clang__ - #pragma clang diagnostic ignored "-Wunused-variable" -#endif - +#ifdef __clang__ + #pragma clang diagnostic ignored "-Wunused-variable" +#endif + %%{ machine TParser; diff --git a/library/cpp/uri/ya.make b/library/cpp/uri/ya.make index 9bc5dc3d3c..8fc808a6af 100644 --- a/library/cpp/uri/ya.make +++ b/library/cpp/uri/ya.make @@ -9,7 +9,7 @@ SRCS( assign.cpp common.cpp encode.cpp - http_url.h + http_url.h location.cpp other.cpp parse.cpp diff --git a/tools/archiver/main.cpp b/tools/archiver/main.cpp index 9a5cc863ef..6cda54c1ea 100644 --- a/tools/archiver/main.cpp +++ b/tools/archiver/main.cpp @@ -615,16 +615,16 @@ int main(int argc, char** argv) { for (size_t i = 0; i < files.size(); ++i) { const auto& path = files[i]; - size_t off = 0; -#ifdef _win_ - if (path[0] > 0 && isalpha(path[0]) && path[1] == ':') - off = 2; // skip drive letter ("d:") + size_t off = 0; +#ifdef _win_ + if (path[0] > 0 && isalpha(path[0]) && path[1] == ':') + off = 2; // skip drive letter ("d:") #endif // _win_ - const size_t pos = path.find(':', off); + const size_t pos = path.find(':', off); TRec cur; - cur.Path = path.substr(0, pos); + cur.Path = path.substr(0, pos); if (pos != TString::npos) - cur.Prefix = path.substr(pos + 1); + cur.Prefix = path.substr(pos + 1); if (keys.size()) cur.Key = keys[i]; cur.Recursive = recursive; diff --git a/util/charset/wide.h b/util/charset/wide.h index cc0ac7ccd1..04e6928aab 100644 --- a/util/charset/wide.h +++ b/util/charset/wide.h @@ -673,11 +673,11 @@ inline bool IsSpace(const wchar16* s, size_t n) { return true; } -//! returns @c true if string contains whitespace characters only +//! returns @c true if string contains whitespace characters only inline bool IsSpace(const TWtringBuf s) { return IsSpace(s.data(), s.length()); -} - +} + //! replaces multiple sequential whitespace characters with a single space character void Collapse(TUtf16String& w); diff --git a/util/charset/wide_ut.cpp b/util/charset/wide_ut.cpp index 8d7360cbfa..d8f3233e73 100644 --- a/util/charset/wide_ut.cpp +++ b/util/charset/wide_ut.cpp @@ -9,7 +9,7 @@ namespace { //! three UTF8 encoded russian letters (A, B, V) - const char utext[] = "\xd0\x90\xd0\x91\xd0\x92"; + const char utext[] = "\xd0\x90\xd0\x91\xd0\x92"; const char asciiLatinAlphabet[] = "ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz"; const wchar16 wideLatinAlphabet[] = { @@ -20,15 +20,15 @@ namespace { 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, 0x00}; - const char utf8CyrillicAlphabet[] = - "\xd0\x90\xd0\x91\xd0\x92\xd0\x93\xd0\x94\xd0\x95\xd0\x96\xd0\x97" - "\xd0\x98\xd0\x99\xd0\x9a\xd0\x9b\xd0\x9c\xd0\x9d\xd0\x9e\xd0\x9f" - "\xd0\xa0\xd0\xa1\xd0\xa2\xd0\xa3\xd0\xa4\xd0\xa5\xd0\xa6\xd0\xa7" - "\xd0\xa8\xd0\xa9\xd0\xaa\xd0\xab\xd0\xac\xd0\xad\xd0\xae\xd0\xaf" - "\xd0\xb0\xd0\xb1\xd0\xb2\xd0\xb3\xd0\xb4\xd0\xb5\xd0\xb6\xd0\xb7" - "\xd0\xb8\xd0\xb9\xd0\xba\xd0\xbb\xd0\xbc\xd0\xbd\xd0\xbe\xd0\xbf" - "\xd1\x80\xd1\x81\xd1\x82\xd1\x83\xd1\x84\xd1\x85\xd1\x86\xd1\x87" - "\xd1\x88\xd1\x89\xd1\x8a\xd1\x8b\xd1\x8c\xd1\x8d\xd1\x8e\xd1\x8f"; + const char utf8CyrillicAlphabet[] = + "\xd0\x90\xd0\x91\xd0\x92\xd0\x93\xd0\x94\xd0\x95\xd0\x96\xd0\x97" + "\xd0\x98\xd0\x99\xd0\x9a\xd0\x9b\xd0\x9c\xd0\x9d\xd0\x9e\xd0\x9f" + "\xd0\xa0\xd0\xa1\xd0\xa2\xd0\xa3\xd0\xa4\xd0\xa5\xd0\xa6\xd0\xa7" + "\xd0\xa8\xd0\xa9\xd0\xaa\xd0\xab\xd0\xac\xd0\xad\xd0\xae\xd0\xaf" + "\xd0\xb0\xd0\xb1\xd0\xb2\xd0\xb3\xd0\xb4\xd0\xb5\xd0\xb6\xd0\xb7" + "\xd0\xb8\xd0\xb9\xd0\xba\xd0\xbb\xd0\xbc\xd0\xbd\xd0\xbe\xd0\xbf" + "\xd1\x80\xd1\x81\xd1\x82\xd1\x83\xd1\x84\xd1\x85\xd1\x86\xd1\x87" + "\xd1\x88\xd1\x89\xd1\x8a\xd1\x8b\xd1\x8c\xd1\x8d\xd1\x8e\xd1\x8f"; const wchar32 LEAD_BITS_MASK_2_BYTES = 0x1F; const wchar32 LEAD_BITS_MASK_3_BYTES = 0x0F; @@ -81,31 +81,31 @@ namespace { } TString CreateUTF8Text() { - char text[] = { - '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', - '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', - '\x20', '\x21', '\x22', '\x23', '\x24', '\x25', '\x26', '\x27', '\x28', '\x29', '\x2a', '\x2b', '\x2c', '\x2d', '\x2e', '\x2f', - '\x30', '\x31', '\x32', '\x33', '\x34', '\x35', '\x36', '\x37', '\x38', '\x39', '\x3a', '\x3b', '\x3c', '\x3d', '\x3e', '\x3f', - '\x40', '\x41', '\x42', '\x43', '\x44', '\x45', '\x46', '\x47', '\x48', '\x49', '\x4a', '\x4b', '\x4c', '\x4d', '\x4e', '\x4f', - '\x50', '\x51', '\x52', '\x53', '\x54', '\x55', '\x56', '\x57', '\x58', '\x59', '\x5a', '\x5b', '\x5c', '\x5d', '\x5e', '\x5f', - '\x60', '\x61', '\x62', '\x63', '\x64', '\x65', '\x66', '\x67', '\x68', '\x69', '\x6a', '\x6b', '\x6c', '\x6d', '\x6e', '\x6f', - '\x70', '\x71', '\x72', '\x73', '\x74', '\x75', '\x76', '\x77', '\x78', '\x79', '\x7a', '\x7b', '\x7c', '\x7d', '\x7e', '\x7f', - '\xcc', '\x81', '\xc3', '\x84', '\xc3', '\x96', '\xc3', '\x9c', '\xc4', '\x84', '\xc4', '\x86', '\xc4', '\x98', '\xc5', '\x81', - '\xc3', '\xa0', '\xc3', '\xa2', '\xc3', '\xa7', '\xc3', '\xa8', '\xc3', '\xa9', '\xc3', '\xaa', '\xd2', '\x90', '\xc2', '\xad', - '\xc3', '\x9f', '\xc3', '\xa4', '\xc3', '\xb6', '\xc3', '\xbc', '\xc4', '\x85', '\xc4', '\x87', '\xc4', '\x99', '\xc5', '\x82', - '\xc3', '\xab', '\xc3', '\xae', '\xc3', '\xaf', '\xc3', '\xb4', '\xc3', '\xb9', '\xc3', '\xbb', '\xd2', '\x91', '\xe9', '\x8b', - '\x8f', '\xc2', '\xa0', '\xc5', '\x83', '\xc3', '\x93', '\xc5', '\x9a', '\xc5', '\xbb', '\xc5', '\xb9', '\xd1', '\xac', '\xc2', - '\xa7', '\xd0', '\x81', '\xd1', '\xa2', '\xd1', '\xb2', '\xd1', '\xb4', '\xd0', '\x8e', '\xd0', '\x86', '\xd0', '\x84', '\xd0', - '\x87', '\xc2', '\xb0', '\xc5', '\x84', '\xc3', '\xb3', '\xc5', '\x9b', '\xc5', '\xbc', '\xc5', '\xba', '\xd1', '\xad', '\xe2', - '\x84', '\x96', '\xd1', '\x91', '\xd1', '\xa3', '\xd1', '\xb3', '\xd1', '\xb5', '\xd1', '\x9e', '\xd1', '\x96', '\xd1', '\x94', - '\xd1', '\x97', '\xd0', '\x90', '\xd0', '\x91', '\xd0', '\x92', '\xd0', '\x93', '\xd0', '\x94', '\xd0', '\x95', '\xd0', '\x96', - '\xd0', '\x97', '\xd0', '\x98', '\xd0', '\x99', '\xd0', '\x9a', '\xd0', '\x9b', '\xd0', '\x9c', '\xd0', '\x9d', '\xd0', '\x9e', - '\xd0', '\x9f', '\xd0', '\xa0', '\xd0', '\xa1', '\xd0', '\xa2', '\xd0', '\xa3', '\xd0', '\xa4', '\xd0', '\xa5', '\xd0', '\xa6', - '\xd0', '\xa7', '\xd0', '\xa8', '\xd0', '\xa9', '\xd0', '\xaa', '\xd0', '\xab', '\xd0', '\xac', '\xd0', '\xad', '\xd0', '\xae', - '\xd0', '\xaf', '\xd0', '\xb0', '\xd0', '\xb1', '\xd0', '\xb2', '\xd0', '\xb3', '\xd0', '\xb4', '\xd0', '\xb5', '\xd0', '\xb6', - '\xd0', '\xb7', '\xd0', '\xb8', '\xd0', '\xb9', '\xd0', '\xba', '\xd0', '\xbb', '\xd0', '\xbc', '\xd0', '\xbd', '\xd0', '\xbe', - '\xd0', '\xbf', '\xd1', '\x80', '\xd1', '\x81', '\xd1', '\x82', '\xd1', '\x83', '\xd1', '\x84', '\xd1', '\x85', '\xd1', '\x86', - '\xd1', '\x87', '\xd1', '\x88', '\xd1', '\x89', '\xd1', '\x8a', '\xd1', '\x8b', '\xd1', '\x8c', '\xd1', '\x8d', '\xd1', '\x8e', + char text[] = { + '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', + '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', + '\x20', '\x21', '\x22', '\x23', '\x24', '\x25', '\x26', '\x27', '\x28', '\x29', '\x2a', '\x2b', '\x2c', '\x2d', '\x2e', '\x2f', + '\x30', '\x31', '\x32', '\x33', '\x34', '\x35', '\x36', '\x37', '\x38', '\x39', '\x3a', '\x3b', '\x3c', '\x3d', '\x3e', '\x3f', + '\x40', '\x41', '\x42', '\x43', '\x44', '\x45', '\x46', '\x47', '\x48', '\x49', '\x4a', '\x4b', '\x4c', '\x4d', '\x4e', '\x4f', + '\x50', '\x51', '\x52', '\x53', '\x54', '\x55', '\x56', '\x57', '\x58', '\x59', '\x5a', '\x5b', '\x5c', '\x5d', '\x5e', '\x5f', + '\x60', '\x61', '\x62', '\x63', '\x64', '\x65', '\x66', '\x67', '\x68', '\x69', '\x6a', '\x6b', '\x6c', '\x6d', '\x6e', '\x6f', + '\x70', '\x71', '\x72', '\x73', '\x74', '\x75', '\x76', '\x77', '\x78', '\x79', '\x7a', '\x7b', '\x7c', '\x7d', '\x7e', '\x7f', + '\xcc', '\x81', '\xc3', '\x84', '\xc3', '\x96', '\xc3', '\x9c', '\xc4', '\x84', '\xc4', '\x86', '\xc4', '\x98', '\xc5', '\x81', + '\xc3', '\xa0', '\xc3', '\xa2', '\xc3', '\xa7', '\xc3', '\xa8', '\xc3', '\xa9', '\xc3', '\xaa', '\xd2', '\x90', '\xc2', '\xad', + '\xc3', '\x9f', '\xc3', '\xa4', '\xc3', '\xb6', '\xc3', '\xbc', '\xc4', '\x85', '\xc4', '\x87', '\xc4', '\x99', '\xc5', '\x82', + '\xc3', '\xab', '\xc3', '\xae', '\xc3', '\xaf', '\xc3', '\xb4', '\xc3', '\xb9', '\xc3', '\xbb', '\xd2', '\x91', '\xe9', '\x8b', + '\x8f', '\xc2', '\xa0', '\xc5', '\x83', '\xc3', '\x93', '\xc5', '\x9a', '\xc5', '\xbb', '\xc5', '\xb9', '\xd1', '\xac', '\xc2', + '\xa7', '\xd0', '\x81', '\xd1', '\xa2', '\xd1', '\xb2', '\xd1', '\xb4', '\xd0', '\x8e', '\xd0', '\x86', '\xd0', '\x84', '\xd0', + '\x87', '\xc2', '\xb0', '\xc5', '\x84', '\xc3', '\xb3', '\xc5', '\x9b', '\xc5', '\xbc', '\xc5', '\xba', '\xd1', '\xad', '\xe2', + '\x84', '\x96', '\xd1', '\x91', '\xd1', '\xa3', '\xd1', '\xb3', '\xd1', '\xb5', '\xd1', '\x9e', '\xd1', '\x96', '\xd1', '\x94', + '\xd1', '\x97', '\xd0', '\x90', '\xd0', '\x91', '\xd0', '\x92', '\xd0', '\x93', '\xd0', '\x94', '\xd0', '\x95', '\xd0', '\x96', + '\xd0', '\x97', '\xd0', '\x98', '\xd0', '\x99', '\xd0', '\x9a', '\xd0', '\x9b', '\xd0', '\x9c', '\xd0', '\x9d', '\xd0', '\x9e', + '\xd0', '\x9f', '\xd0', '\xa0', '\xd0', '\xa1', '\xd0', '\xa2', '\xd0', '\xa3', '\xd0', '\xa4', '\xd0', '\xa5', '\xd0', '\xa6', + '\xd0', '\xa7', '\xd0', '\xa8', '\xd0', '\xa9', '\xd0', '\xaa', '\xd0', '\xab', '\xd0', '\xac', '\xd0', '\xad', '\xd0', '\xae', + '\xd0', '\xaf', '\xd0', '\xb0', '\xd0', '\xb1', '\xd0', '\xb2', '\xd0', '\xb3', '\xd0', '\xb4', '\xd0', '\xb5', '\xd0', '\xb6', + '\xd0', '\xb7', '\xd0', '\xb8', '\xd0', '\xb9', '\xd0', '\xba', '\xd0', '\xbb', '\xd0', '\xbc', '\xd0', '\xbd', '\xd0', '\xbe', + '\xd0', '\xbf', '\xd1', '\x80', '\xd1', '\x81', '\xd1', '\x82', '\xd1', '\x83', '\xd1', '\x84', '\xd1', '\x85', '\xd1', '\x86', + '\xd1', '\x87', '\xd1', '\x88', '\xd1', '\x89', '\xd1', '\x8a', '\xd1', '\x8b', '\xd1', '\x8c', '\xd1', '\x8d', '\xd1', '\x8e', '\xd1', '\x8f'}; return TString(text, Y_ARRAY_SIZE(text)); } @@ -478,7 +478,7 @@ void TConversionTest::TestUTF8ToWide() { wchar16 buffer[4] = {0}; size_t written = 0; // the function must extract 2 symbols only - bool result = UTF8ToWide(utext, 5, buffer, written); + bool result = UTF8ToWide(utext, 5, buffer, written); UNIT_ASSERT(!result); UNIT_ASSERT(buffer[0] == 0x0410); UNIT_ASSERT(buffer[1] == 0x0411); @@ -488,7 +488,7 @@ void TConversionTest::TestUTF8ToWide() { memset(buffer, 0, 4); written = 0; - result = UTF8ToWide(utext, 1, buffer, written); + result = UTF8ToWide(utext, 1, buffer, written); UNIT_ASSERT(!result); UNIT_ASSERT(buffer[0] == 0x0000); UNIT_ASSERT(buffer[1] == 0x0000); @@ -537,12 +537,12 @@ void TConversionTest::TestGetNumOfUTF8Chars() { UNIT_ASSERT(n == 256); n = 0; - result = GetNumberOfUTF8Chars(utext, 5, n); + result = GetNumberOfUTF8Chars(utext, 5, n); UNIT_ASSERT(!result); UNIT_ASSERT(n == 2); n = 0; - result = GetNumberOfUTF8Chars(utext, 1, n); + result = GetNumberOfUTF8Chars(utext, 1, n); UNIT_ASSERT(!result); UNIT_ASSERT(n == 0); diff --git a/util/datetime/base.h b/util/datetime/base.h index 91d987a865..5e902b8f63 100644 --- a/util/datetime/base.h +++ b/util/datetime/base.h @@ -24,11 +24,11 @@ #include <time.h> -#ifdef _MSC_VER +#ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4244) // conversion from 'time_t' to 'long', possible loss of data #endif // _MSC_VER - + // Microseconds since epoch class TInstant; @@ -818,6 +818,6 @@ static inline TInstant Now() noexcept { return TInstant::Now(); } -#ifdef _MSC_VER +#ifdef _MSC_VER #pragma warning(pop) -#endif // _MSC_VER +#endif // _MSC_VER diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp index 5db2bead12..afc3f802eb 100644 --- a/util/datetime/base_ut.cpp +++ b/util/datetime/base_ut.cpp @@ -298,7 +298,7 @@ Y_UNIT_TEST_SUITE(TDateTimeTest) { } return strcmp(zone0, zone1) == 0; } - + static bool CompareTMFull(const tm* t0, const tm* t1) { return t0 && t1 && CompareTM(*t0, *t1) && @@ -320,14 +320,14 @@ Y_UNIT_TEST_SUITE(TDateTimeTest) { for (time_t t = starttime; t < finishtime; t += step) { ptm0 = GmTimeR(&t, &tms0); UNIT_ASSERT_EQUAL(ptm0, &tms0); - -#ifdef _win_ + +#ifdef _win_ if (tms0.tm_year + 1900 > 3000) { // Windows: _MAX__TIME64_T == 23:59:59. 12/31/3000 UTC continue; } -#endif - +#endif + ptm1 = gmtime_r(&t, &tms1); if (!ptm1) { continue; @@ -372,7 +372,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { } Y_UNIT_TEST(TestFromString) { - static const struct T { + static const struct T { const char* const Str; const TDuration::TValue MicroSeconds; const bool Parseable; @@ -383,7 +383,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { {"3ms", 3000, true}, {"x3ms", 0, false}, }; - + for (const T* t = tests; t != std::end(tests); ++t) { // FromString bool parsed = false; @@ -400,9 +400,9 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { if (t->Parseable) { UNIT_ASSERT_EQUAL(t->MicroSeconds, tryTime.MicroSeconds()); } - } - } - + } + } + Y_UNIT_TEST(TestSleep) { // check does not throw Sleep(TDuration::Seconds(0)); diff --git a/util/datetime/systime.cpp b/util/datetime/systime.cpp index 6425aafe0c..6ee7e8fc6e 100644 --- a/util/datetime/systime.cpp +++ b/util/datetime/systime.cpp @@ -89,9 +89,9 @@ struct tm* GmTimeR(const time_t* timer, struct tm* tmbuf) { static const int _ytab[2][12] = { {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; - + i64 time = static_cast<i64>(*timer); - + ui64 dayclock, dayno; int year = EPOCH_YR; diff --git a/util/draft/holder_vector.h b/util/draft/holder_vector.h index 7c80c64453..1c62055bd9 100644 --- a/util/draft/holder_vector.h +++ b/util/draft/holder_vector.h @@ -42,9 +42,9 @@ public: } void PushBack(std::unique_ptr<T> t) { - PushBack(t.release()); - } - + PushBack(t.release()); + } + void PushBack(THolder<T> t) { PushBack(t.Release()); } @@ -78,10 +78,10 @@ public: TBase::resize(newSize); } - void Swap(THolderVector& other) { - TBase::swap(other); - } - + void Swap(THolderVector& other) { + TBase::swap(other); + } + using TBase::operator[]; using TBase::operator bool; using TBase::at; diff --git a/util/draft/holder_vector_ut.cpp b/util/draft/holder_vector_ut.cpp index 265af73549..f64393860a 100644 --- a/util/draft/holder_vector_ut.cpp +++ b/util/draft/holder_vector_ut.cpp @@ -49,21 +49,21 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) { UNIT_ASSERT_VALUES_EQUAL(*ints[0], 1); UNIT_ASSERT(!holder); } - + Y_UNIT_TEST(TestSwap) { - THolderVector<int> v1; - v1.PushBack(new int(1)); - - THolderVector<int> v2; - v1.Swap(v2); - UNIT_ASSERT(v1.empty() && v2.size() == 1 && *v2.front() == 1); - } - + THolderVector<int> v1; + v1.PushBack(new int(1)); + + THolderVector<int> v2; + v1.Swap(v2); + UNIT_ASSERT(v1.empty() && v2.size() == 1 && *v2.front() == 1); + } + Y_UNIT_TEST(TestUniquePtr) { THolderVector<TString> v; std::unique_ptr<TString> str(new TString("hello")); - v.PushBack(std::move(str)); - UNIT_ASSERT(v.Size() == 1); - UNIT_ASSERT(str.get() == nullptr); - } + v.PushBack(std::move(str)); + UNIT_ASSERT(v.Size() == 1); + UNIT_ASSERT(str.get() == nullptr); + } } diff --git a/util/draft/matrix.h b/util/draft/matrix.h index 6383cee03d..154d00b35e 100644 --- a/util/draft/matrix.h +++ b/util/draft/matrix.h @@ -1,15 +1,15 @@ #pragma once - + #include <util/generic/noncopyable.h> #include <util/system/yassert.h> #include <util/system/defaults.h> -#include <string.h> - +#include <string.h> + template <typename T> class TMatrix: TNonCopyable { // Constructor/Destructor -public: - TMatrix() +public: + TMatrix() : Buf(nullptr) , Arr(nullptr) , M(0) @@ -17,7 +17,7 @@ public: , BufSize(0) { } - + TMatrix(size_t m, size_t n) : Buf(new T[m * n]) , Arr(Buf) @@ -26,7 +26,7 @@ public: , BufSize(m * n) { } - + TMatrix(size_t m, size_t n, T* buf) : Buf(nullptr) , Arr(buf) @@ -35,74 +35,74 @@ public: , BufSize(m * n) { } - - ~TMatrix() { - delete[] Buf; - } - + + ~TMatrix() { + delete[] Buf; + } + // Properties/Methods -public: - void Clear() { - M = N = 0; - } - +public: + void Clear() { + M = N = 0; + } + void ReDim(size_t m, size_t n) { Y_ASSERT(m >= 1 && n >= 1); - size_t newSize = m * n; - if (newSize > BufSize) { - T* newBuf = new T[newSize]; + size_t newSize = m * n; + if (newSize > BufSize) { + T* newBuf = new T[newSize]; delete[] Buf; - Arr = Buf = newBuf; - BufSize = newSize; - } + Arr = Buf = newBuf; + BufSize = newSize; + } M = m; N = n; - } - + } + size_t Width() const { - return N; - } - + return N; + } + size_t Height() const { - return M; - } - - // Access element matrix[i][j] + return M; + } + + // Access element matrix[i][j] T* operator[](size_t i) { Y_ASSERT(i >= 0 && i < M); - return Arr + i * N; - } - - // Access element matrix[i][j] + return Arr + i * N; + } + + // Access element matrix[i][j] const T* operator[](size_t i) const { Y_ASSERT(i >= 0 && i < M); - return Arr + i * N; - } - - // Access element matrix(i, j) + return Arr + i * N; + } + + // Access element matrix(i, j) T& operator()(size_t i, size_t j) { Y_ASSERT(i >= 0 && i < M && j >= 0 && j < N); - return Arr[i * N + j]; - } - - // Access element matrix(i, j) + return Arr[i * N + j]; + } + + // Access element matrix(i, j) const T& operator()(size_t i, size_t j) const { Y_ASSERT(i >= 0 && i < M && j >= 0 && j < N); - return Arr[i * N + j]; - } - - void Zero() { + return Arr[i * N + j]; + } + + void Zero() { memset((void*)Arr, 0, M * N * sizeof(T)); - } + } - void Fill(T value) { + void Fill(T value) { for (T *p = Arr, *end = Arr + M * N; p < end; ++p) - *p = value; - } - -private: - T* Buf; - T* Arr; + *p = value; + } + +private: + T* Buf; + T* Arr; size_t M, N; - size_t BufSize; -}; + size_t BufSize; +}; diff --git a/util/folder/dirent_win.c b/util/folder/dirent_win.c index b945630eaa..7e6db74ce5 100644 --- a/util/folder/dirent_win.c +++ b/util/folder/dirent_win.c @@ -21,13 +21,13 @@ static void SetErrno() { struct DIR* opendir(const char* dirname) { struct DIR* dir = (struct DIR*)malloc(sizeof(struct DIR)); - if (!dir) { - return NULL; + if (!dir) { + return NULL; } - dir->sh = INVALID_HANDLE_VALUE; - dir->fff_templ = NULL; - dir->file_no = 0; - dir->readdir_buf = NULL; + dir->sh = INVALID_HANDLE_VALUE; + dir->fff_templ = NULL; + dir->file_no = 0; + dir->readdir_buf = NULL; int len = strlen(dirname); //Remove trailing slashes @@ -36,31 +36,31 @@ struct DIR* opendir(const char* dirname) { } int len_converted = MultiByteToWideChar(CP_UTF8, 0, dirname, len, 0, 0); if (len_converted == 0) { - closedir(dir); - return NULL; + closedir(dir); + return NULL; } dir->fff_templ = (WCHAR*)malloc((len_converted + 5) * sizeof(WCHAR)); - if (!dir->fff_templ) { - closedir(dir); - return NULL; + if (!dir->fff_templ) { + closedir(dir); + return NULL; } MultiByteToWideChar(CP_UTF8, 0, dirname, len, dir->fff_templ, len_converted); WCHAR append[] = {'\\', '*', '.', '*', 0}; memcpy(dir->fff_templ + len_converted, append, sizeof(append)); dir->sh = FindFirstFileW(dir->fff_templ, &dir->wfd); - if (dir->sh == INVALID_HANDLE_VALUE) { + if (dir->sh == INVALID_HANDLE_VALUE) { SetErrno(); - closedir(dir); - return NULL; + closedir(dir); + return NULL; } - + return dir; } int closedir(struct DIR* dir) { - if (dir->sh != INVALID_HANDLE_VALUE) - FindClose(dir->sh); + if (dir->sh != INVALID_HANDLE_VALUE) + FindClose(dir->sh); free(dir->fff_templ); free(dir->readdir_buf); free(dir); diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp index c05a54831a..ffc9b09f96 100644 --- a/util/folder/dirut.cpp +++ b/util/folder/dirut.cpp @@ -459,7 +459,7 @@ TString GetHomeDir() { #ifndef _win32_ passwd* pw = nullptr; s = getenv("USER"); - if (s) + if (s) pw = getpwnam(s.data()); else pw = getpwuid(getuid()); @@ -517,7 +517,7 @@ TString GetSystemTempDir() { const char* var = "TMPDIR"; const char* def = "/tmp"; const char* r = getenv(var); - const char* result = r ? r : def; + const char* result = r ? r : def; return result[0] == '/' ? result : ResolveDir(result); #endif } diff --git a/util/folder/dirut_ut.cpp b/util/folder/dirut_ut.cpp index fcdbc96d33..45ebfc842c 100644 --- a/util/folder/dirut_ut.cpp +++ b/util/folder/dirut_ut.cpp @@ -1,5 +1,5 @@ #include "dirut.h" -#include "tempdir.h" +#include "tempdir.h" #include <library/cpp/testing/unittest/registar.h> diff --git a/util/folder/filelist_ut.cpp b/util/folder/filelist_ut.cpp index b042dd1ff5..0cdcdf3d00 100644 --- a/util/folder/filelist_ut.cpp +++ b/util/folder/filelist_ut.cpp @@ -1,6 +1,6 @@ #include "dirut.h" #include "filelist.h" -#include "tempdir.h" +#include "tempdir.h" #include <library/cpp/testing/unittest/registar.h> diff --git a/util/folder/fts_ut.cpp b/util/folder/fts_ut.cpp index 050aa467ad..c5d59e35f4 100644 --- a/util/folder/fts_ut.cpp +++ b/util/folder/fts_ut.cpp @@ -1,6 +1,6 @@ #include "fts.h" #include "dirut.h" -#include "tempdir.h" +#include "tempdir.h" #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/threading/future/async.h> diff --git a/util/folder/path.cpp b/util/folder/path.cpp index 96ebdc3dbe..bfe0c67d68 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -335,7 +335,7 @@ bool TFsPath::Exists() const { void TFsPath::CheckExists() const { if (!Exists()) { - ythrow TIoException() << "path does not exist " << Path_; + ythrow TIoException() << "path does not exist " << Path_; } } @@ -452,7 +452,7 @@ void TFsPath::CopyTo(const TString& newPath, bool force) const { void TFsPath::ForceRenameTo(const TString& newPath) const { try { RenameTo(newPath); - } catch (const TIoSystemError& /* error */) { + } catch (const TIoSystemError& /* error */) { CopyTo(newPath, true); ForceDelete(); } diff --git a/util/folder/tempdir.cpp b/util/folder/tempdir.cpp index 760cc03fa1..6fdf8f753c 100644 --- a/util/folder/tempdir.cpp +++ b/util/folder/tempdir.cpp @@ -1,34 +1,34 @@ -#include "tempdir.h" +#include "tempdir.h" -#include "dirut.h" +#include "dirut.h" -#include <util/system/fs.h> -#include <util/system/maxlen.h> - -TTempDir::TTempDir() +#include <util/system/fs.h> +#include <util/system/maxlen.h> + +TTempDir::TTempDir() : TTempDir(nullptr, TCreationToken{}) { } TTempDir::TTempDir(const char* prefix, TCreationToken) - : TempDir() + : TempDir() , Remove(true) -{ - char tempDir[MAX_PATH]; +{ + char tempDir[MAX_PATH]; if (MakeTempDir(tempDir, prefix) != 0) { ythrow TSystemError() << "Can't create temporary directory"; } - TempDir = tempDir; -} - + TempDir = tempDir; +} + TTempDir::TTempDir(const TString& tempDir) - : TempDir(tempDir) + : TempDir(tempDir) , Remove(true) -{ +{ NFs::Remove(TempDir); MakeDirIfNotExist(TempDir.c_str()); -} - +} + TTempDir TTempDir::NewTempDir(const TString& root) { return {root.c_str(), TCreationToken{}}; } @@ -37,8 +37,8 @@ void TTempDir::DoNotRemove() { Remove = false; } -TTempDir::~TTempDir() { +TTempDir::~TTempDir() { if (Remove) { RemoveDirWithContents(TempDir); } -} +} diff --git a/util/folder/tempdir.h b/util/folder/tempdir.h index 1422669f02..ff458f83b9 100644 --- a/util/folder/tempdir.h +++ b/util/folder/tempdir.h @@ -1,19 +1,19 @@ -#pragma once - +#pragma once + #include "fwd.h" #include "path.h" #include <util/generic/string.h> - -class TTempDir { -public: + +class TTempDir { +public: /// Create new directory in system tmp folder. - TTempDir(); + TTempDir(); /// Create new directory with this fixed name. If it already exists, clear it. TTempDir(const TString& tempDir); - ~TTempDir(); - + ~TTempDir(); + /// Create new directory in given folder. static TTempDir NewTempDir(const TString& root); @@ -26,12 +26,12 @@ public: } const TFsPath& Path() const { - return TempDir; - } - + return TempDir; + } + void DoNotRemove(); -private: +private: struct TCreationToken {}; // Prevent people from confusing this ctor with the public one @@ -40,4 +40,4 @@ private: TFsPath TempDir; bool Remove; -}; +}; diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h index 88f6e25021..badfb88993 100644 --- a/util/generic/algorithm.h +++ b/util/generic/algorithm.h @@ -337,11 +337,11 @@ void StableSortUniqueBy(C& c, const TGetKey& getKey) { c.erase(UniqueBy(c.begin(), c.end(), getKey), c.end()); } -template <class C, class TValue> -void Erase(C& c, const TValue& value) { - c.erase(std::remove(c.begin(), c.end(), value), c.end()); -} - +template <class C, class TValue> +void Erase(C& c, const TValue& value) { + c.erase(std::remove(c.begin(), c.end(), value), c.end()); +} + template <class C, class P> void EraseIf(C& c, P p) { c.erase(std::remove_if(c.begin(), c.end(), p), c.end()); diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp index 7cb719d3b1..8d732fcc0c 100644 --- a/util/generic/algorithm_ut.cpp +++ b/util/generic/algorithm_ut.cpp @@ -269,10 +269,10 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { Y_UNIT_TEST(EraseTest) { TVector<int> data = {5, 4, 3, 2, 1, 0}; TVector<int> expected = {5, 4, 2, 1, 0}; - Erase(data, 3); - UNIT_ASSERT_EQUAL(data, expected); - } - + Erase(data, 3); + UNIT_ASSERT_EQUAL(data, expected); + } + Y_UNIT_TEST(EraseIfTest) { TVector<int> data = {5, 4, 3, 2, 1, 0}; TVector<int> expected = {2, 1, 0}; diff --git a/util/generic/bitops.h b/util/generic/bitops.h index 787a5bc69d..2db15fc59b 100644 --- a/util/generic/bitops.h +++ b/util/generic/bitops.h @@ -57,7 +57,7 @@ namespace NBitOps { return (v >> 32ULL) | (v << 32ULL); } -#if defined(__GNUC__) +#if defined(__GNUC__) inline unsigned GetValueBitCountImpl(unsigned int value) noexcept { Y_ASSERT(value); // because __builtin_clz* have undefined result for zero. return std::numeric_limits<unsigned int>::digits - __builtin_clz(value); @@ -88,7 +88,7 @@ namespace NBitOps { } #endif -#if defined(__GNUC__) +#if defined(__GNUC__) inline unsigned CountTrailingZeroBitsImpl(unsigned int value) noexcept { Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero. return __builtin_ctz(value); diff --git a/util/generic/strbase.h b/util/generic/strbase.h index 3b16c03c72..ab39fc7537 100644 --- a/util/generic/strbase.h +++ b/util/generic/strbase.h @@ -312,8 +312,8 @@ public: inline bool StartsWith(TCharType ch) const noexcept { return !empty() && TTraits::eq(*Ptr(), ch); - } - + } + inline bool EndsWith(const TCharType* s, size_t n) const noexcept { return EndsWith(Ptr(), Len(), s, n); } @@ -324,8 +324,8 @@ public: inline bool EndsWith(TCharType ch) const noexcept { return !empty() && TTraits::eq(Ptr()[Len() - 1], ch); - } - + } + template <typename TDerived2, typename TTraits2> bool operator==(const TStringBase<TDerived2, TChar, TTraits2>& s2) const noexcept { return equal(*this, s2); @@ -473,8 +473,8 @@ public: inline size_t rfind(const TStringView str, size_t pos = npos) const { return AsStringView().rfind(str.data(), pos, str.size()); - } - + } + //~~~~Contains~~~~ /** * @returns Whether this string contains the provided substring. diff --git a/util/generic/string.h b/util/generic/string.h index dfbd626a4a..8cd8aa6917 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -266,22 +266,22 @@ public: #endif } - using TBase::back; - + using TBase::back; + inline reference back() noexcept { Y_ASSERT(!this->empty()); #ifdef TSTRING_IS_STD_STRING return Storage_.back(); #else - if (Y_UNLIKELY(this->empty())) { + if (Y_UNLIKELY(this->empty())) { return reference(*this, 0); - } + } return reference(*this, length() - 1); #endif - } - + } + using TBase::front; inline reference front() noexcept { @@ -606,9 +606,9 @@ public: } TBasicString& assign(TCharType ch) { - return assign(&ch, 1); - } - + return assign(&ch, 1); + } + TBasicString& assign(const TCharType* pc, size_t len) { #if defined(address_sanitizer_enabled) || defined(thread_sanitizer_enabled) pc = (const TCharType*)HidePointerOrigin((void*)pc); @@ -704,9 +704,9 @@ public: TBasicString& operator=(std::nullptr_t) = delete; TBasicString& operator=(TExplicitType<TCharType> ch) { - return assign(ch); - } - + return assign(ch); + } + inline void reserve(size_t len) { MutRef().reserve(len); } @@ -931,12 +931,12 @@ public: friend TBasicString operator+(const TBasicStringBuf<TCharType, TTraits> s1, const TBasicString& s2) Y_WARN_UNUSED_RESULT { return Join(s1, s2); - } - + } + friend TBasicString operator+(const TCharType* s1, const TBasicString& s2) Y_WARN_UNUSED_RESULT { return Join(s1, s2); - } - + } + friend TBasicString operator+(std::basic_string<TCharType, TTraits> l, TBasicString r) { return l + r.ConstRef(); } diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp index 86fc6aef99..ac82e9091d 100644 --- a/util/generic/string_ut.cpp +++ b/util/generic/string_ut.cpp @@ -740,11 +740,11 @@ public: UNIT_TEST(TestJoin); UNIT_TEST(TestCopy); UNIT_TEST(TestStrCpy); - UNIT_TEST(TestPrefixSuffix); + UNIT_TEST(TestPrefixSuffix); #ifndef TSTRING_IS_STD_STRING UNIT_TEST(TestCharRef); #endif - UNIT_TEST(TestBack) + UNIT_TEST(TestBack) UNIT_TEST(TestFront) UNIT_TEST(TestIterators); UNIT_TEST(TestReverseIterators); @@ -794,7 +794,7 @@ public: UNIT_TEST(TestFind); UNIT_TEST(TestContains); UNIT_TEST(TestOperators); - UNIT_TEST(TestLetOperator) + UNIT_TEST(TestLetOperator) UNIT_TEST(TestMulOperators); UNIT_TEST(TestFuncs); UNIT_TEST(TestUtils); @@ -802,11 +802,11 @@ public: UNIT_TEST(TestJoin); UNIT_TEST(TestCopy); UNIT_TEST(TestStrCpy); - UNIT_TEST(TestPrefixSuffix); + UNIT_TEST(TestPrefixSuffix); #ifndef TSTRING_IS_STD_STRING UNIT_TEST(TestCharRef); #endif - UNIT_TEST(TestBack); + UNIT_TEST(TestBack); UNIT_TEST(TestFront) UNIT_TEST(TestDecodingMethods); UNIT_TEST(TestIterators); @@ -881,20 +881,20 @@ private: s2.AppendUtf8(text); UNIT_ASSERT(testAppend == s2); } - - void TestLetOperator() { + + void TestLetOperator() { TUtf16String str; - + str = wchar16('X'); UNIT_ASSERT(str == TUtf16String::FromAscii("X")); - + const TUtf16String hello = TUtf16String::FromAscii("hello"); str = hello.data(); - UNIT_ASSERT(str == hello); - - str = hello; - UNIT_ASSERT(str == hello); - } + UNIT_ASSERT(str == hello); + + str = hello; + UNIT_ASSERT(str == hello); + } void TestStringLiterals() { TUtf16String s1 = u"hello"; diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h index 518e6d10ea..44bb10bdeb 100644 --- a/util/generic/string_ut.h +++ b/util/generic/string_ut.h @@ -699,20 +699,20 @@ public: const TStringType rs = Data._0123401234(); UNIT_ASSERT(rs.rfind(*Data._3()) == 8); - + const TStringType empty; - UNIT_ASSERT(empty.find(empty) == 0); - UNIT_ASSERT(s.find(empty, 0) == 0); - UNIT_ASSERT(s.find(empty, 1) == 1); - UNIT_ASSERT(s.find(empty, s.length()) == s.length()); + UNIT_ASSERT(empty.find(empty) == 0); + UNIT_ASSERT(s.find(empty, 0) == 0); + UNIT_ASSERT(s.find(empty, 1) == 1); + UNIT_ASSERT(s.find(empty, s.length()) == s.length()); UNIT_ASSERT(s.find(empty, s.length() + 1) == TStringType::npos); - - UNIT_ASSERT(s.rfind(empty) == s.length()); - UNIT_ASSERT(empty.rfind(empty) == 0); + + UNIT_ASSERT(s.rfind(empty) == s.length()); + UNIT_ASSERT(empty.rfind(empty) == 0); UNIT_ASSERT(empty.rfind(s) == TStringType::npos); - + UNIT_ASSERT(s2.rfind(s) == TStringType::npos); - UNIT_ASSERT(s.rfind(s2) == 0); + UNIT_ASSERT(s.rfind(s2) == 0); UNIT_ASSERT(s.rfind(TStringType(Data._345())) == 10); UNIT_ASSERT(s.rfind(TStringType(Data._345()), 13) == 10); UNIT_ASSERT(s.rfind(TStringType(Data._345()), 10) == 10); @@ -736,7 +736,7 @@ public: UNIT_ASSERT(s.Contains(empty)); UNIT_ASSERT(!empty.Contains(s)); UNIT_ASSERT(empty.Contains(empty)); - UNIT_ASSERT(s.Contains(empty, s.length())); + UNIT_ASSERT(s.Contains(empty, s.length())); } // Operators @@ -885,9 +885,9 @@ public: s2.assign(Data._0123456(), 4); UNIT_ASSERT(s2 == Data._0123()); - s2.assign('1'); - UNIT_ASSERT(s2 == Data._1()); - + s2.assign('1'); + UNIT_ASSERT(s2 == Data._1()); + s2.assign(Data._0123456()); UNIT_ASSERT(s2 == Data._0123456()); @@ -978,8 +978,8 @@ public: UNIT_ASSERT_EQUAL(data[4], 0); } } - - void TestPrefixSuffix() { + + void TestPrefixSuffix() { const TStringType emptyStr; UNIT_ASSERT_EQUAL(emptyStr.StartsWith('x'), false); UNIT_ASSERT_EQUAL(emptyStr.EndsWith('x'), false); @@ -987,7 +987,7 @@ public: UNIT_ASSERT_EQUAL(emptyStr.EndsWith(0), false); UNIT_ASSERT_EQUAL(emptyStr.StartsWith(emptyStr), true); UNIT_ASSERT_EQUAL(emptyStr.EndsWith(emptyStr), true); - + const char_type chars[] = {'h', 'e', 'l', 'l', 'o', 0}; const TStringType str(chars); UNIT_ASSERT_EQUAL(str.StartsWith('h'), true); @@ -996,7 +996,7 @@ public: UNIT_ASSERT_EQUAL(str.EndsWith('h'), false); UNIT_ASSERT_EQUAL(str.StartsWith(emptyStr), true); UNIT_ASSERT_EQUAL(str.EndsWith(emptyStr), true); - } + } #ifndef TSTRING_IS_STD_STRING void TestCharRef() { @@ -1046,20 +1046,20 @@ public: } } #endif - - void TestBack() { - const char_type chars[] = {'f', 'o', 'o', 0}; - + + void TestBack() { + const char_type chars[] = {'f', 'o', 'o', 0}; + TStringType str = chars; const TStringType constStr = str; - + UNIT_ASSERT_VALUES_EQUAL(constStr.back(), (ui8)'o'); UNIT_ASSERT_VALUES_EQUAL(str.back(), (ui8)'o'); - - str.back() = 'r'; + + str.back() = 'r'; UNIT_ASSERT_VALUES_EQUAL(constStr.back(), (ui8)'o'); UNIT_ASSERT_VALUES_EQUAL(str.back(), (ui8)'r'); - } + } void TestFront() { const char_type chars[] = {'f', 'o', 'o', 0}; diff --git a/util/generic/ymath.cpp b/util/generic/ymath.cpp index ec83f696f7..31270728f4 100644 --- a/util/generic/ymath.cpp +++ b/util/generic/ymath.cpp @@ -1,5 +1,5 @@ -#include "ymath.h" - +#include "ymath.h" + double Exp2(double x) { return pow(2.0, x); } @@ -9,23 +9,23 @@ float Exp2f(float x) { } #ifdef _MSC_VER - -double Erf(double x) { + +double Erf(double x) { static constexpr double _M_2_SQRTPI = 1.12837916709551257390; static constexpr double eps = 1.0e-7; - if (fabs(x) >= 3.75) - return x > 0 ? 1.0 : -1.0; - double r = _M_2_SQRTPI * x; - double f = r; - for (int i = 1;; ++i) { - r *= -x * x / i; - f += r / (2 * i + 1); - if (fabs(r) < eps * (2 * i + 1)) - break; - } - return f; -} - + if (fabs(x) >= 3.75) + return x > 0 ? 1.0 : -1.0; + double r = _M_2_SQRTPI * x; + double f = r; + for (int i = 1;; ++i) { + r *= -x * x / i; + f += r / (2 * i + 1); + if (fabs(r) < eps * (2 * i + 1)) + break; + } + return f; +} + #endif // _MSC_VER double LogGammaImpl(double x) { diff --git a/util/generic/ymath.h b/util/generic/ymath.h index 97abaf6e31..9ff9ae2abe 100644 --- a/util/generic/ymath.h +++ b/util/generic/ymath.h @@ -1,7 +1,7 @@ #pragma once #include <util/system/yassert.h> -#include <util/system/defaults.h> +#include <util/system/defaults.h> #include <cmath> #include <cfloat> @@ -91,14 +91,14 @@ static inline bool IsNan(double f) { inline bool IsValidFloat(double f) { return IsFinite(f) && !IsNan(f); } - + #ifdef _MSC_VER -double Erf(double x); -#else -inline double Erf(double x) { - return erf(x); -} -#endif +double Erf(double x); +#else +inline double Erf(double x) { + return erf(x); +} +#endif /** * @returns Natural logarithm of the absolute value diff --git a/util/generic/ymath_ut.cpp b/util/generic/ymath_ut.cpp index 8861c05dcd..29190b55eb 100644 --- a/util/generic/ymath_ut.cpp +++ b/util/generic/ymath_ut.cpp @@ -123,32 +123,32 @@ void TMathTest::TestClp2() { } } } - -void TMathTest::TestErf() { - static const double a = -5.0; + +void TMathTest::TestErf() { + static const double a = -5.0; static const double b = 5.0; - static const int n = 50; - static const double step = (b - a) / n; - - static const double values[n + 1] = { - -1.0000000, -1.0000000, -1.0000000, -1.0000000, -1.0000000, - -1.0000000, -0.9999999, -0.9999996, -0.9999985, -0.9999940, - -0.9999779, -0.9999250, -0.9997640, -0.9993115, -0.9981372, - -0.9953223, -0.9890905, -0.9763484, -0.9522851, -0.9103140, - -0.8427008, -0.7421010, -0.6038561, -0.4283924, -0.2227026, + static const int n = 50; + static const double step = (b - a) / n; + + static const double values[n + 1] = { + -1.0000000, -1.0000000, -1.0000000, -1.0000000, -1.0000000, + -1.0000000, -0.9999999, -0.9999996, -0.9999985, -0.9999940, + -0.9999779, -0.9999250, -0.9997640, -0.9993115, -0.9981372, + -0.9953223, -0.9890905, -0.9763484, -0.9522851, -0.9103140, + -0.8427008, -0.7421010, -0.6038561, -0.4283924, -0.2227026, 0.0000000, 0.2227026, 0.4283924, 0.6038561, 0.7421010, 0.8427008, 0.9103140, 0.9522851, 0.9763484, 0.9890905, 0.9953223, 0.9981372, 0.9993115, 0.9997640, 0.9999250, 0.9999779, 0.9999940, 0.9999985, 0.9999996, 0.9999999, 1.0000000, 1.0000000, 1.0000000, 1.0000000, 1.0000000, 1.0000000}; - - double x = a; - for (int i = 0; i <= n; ++i, x += step) { - double f = Erf(x); - UNIT_ASSERT_DOUBLES_EQUAL(f, values[i], 1e-7); - } -} + + double x = a; + for (int i = 0; i <= n; ++i, x += step) { + double f = Erf(x); + UNIT_ASSERT_DOUBLES_EQUAL(f, values[i], 1e-7); + } +} void TMathTest::TestLogGamma() { double curVal = 0.0; diff --git a/util/memory/pool.h b/util/memory/pool.h index da1b544c37..13c8b6b9ed 100644 --- a/util/memory/pool.h +++ b/util/memory/pool.h @@ -159,7 +159,7 @@ public: inline T* Allocate() { return (T*)this->Allocate(sizeof(T), alignof(T)); } - + template <typename T> inline T* Allocate(size_t align) { return (T*)this->Allocate(sizeof(T), Max(align, alignof(T))); @@ -175,20 +175,20 @@ public: return (T*)this->Allocate(sizeof(T) * count, Max(align, alignof(T))); } - template <typename T> - inline T* AllocateZeroArray(size_t count) { - T* ptr = AllocateArray<T>(count); - memset(ptr, 0, count * sizeof(T)); - return ptr; - } - - template <typename T> - inline T* AllocateZeroArray(size_t count, size_t align) { - T* ptr = AllocateArray<T>(count, align); - memset(ptr, 0, count * sizeof(T)); - return ptr; - } - + template <typename T> + inline T* AllocateZeroArray(size_t count) { + T* ptr = AllocateArray<T>(count); + memset(ptr, 0, count * sizeof(T)); + return ptr; + } + + template <typename T> + inline T* AllocateZeroArray(size_t count, size_t align) { + T* ptr = AllocateArray<T>(count, align); + memset(ptr, 0, count * sizeof(T)); + return ptr; + } + template <typename T, typename... Args> inline T* New(Args&&... args) { return new (Allocate<T>()) T(std::forward<Args>(args)...); diff --git a/util/memory/pool_ut.cpp b/util/memory/pool_ut.cpp index 3268ed841f..1158a8ca42 100644 --- a/util/memory/pool_ut.cpp +++ b/util/memory/pool_ut.cpp @@ -80,7 +80,7 @@ class TMemPoolTest: public TTestBase { UNIT_TEST_SUITE(TMemPoolTest); UNIT_TEST(TestMemPool) UNIT_TEST(TestAlign) - UNIT_TEST(TestZeroArray) + UNIT_TEST(TestZeroArray) UNIT_TEST(TestLargeStartingAlign) UNIT_TEST(TestMoveAlloc) UNIT_TEST(TestRoundUpToNextPowerOfTwoOption) @@ -196,22 +196,22 @@ private: UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned256) & 255, 0); UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned1024) & 1023, 0); } - - void TestZeroArray() { - TMemoryPool pool(1); - size_t size = 10; - i32* intArray = pool.AllocateZeroArray<i32>(size); - for (size_t i = 0; i < size; ++i) { - UNIT_ASSERT(intArray[i] == 0); - } - + + void TestZeroArray() { + TMemoryPool pool(1); + size_t size = 10; + i32* intArray = pool.AllocateZeroArray<i32>(size); + for (size_t i = 0; i < size; ++i) { + UNIT_ASSERT(intArray[i] == 0); + } + size_t align = 256; - ui8* byteArray = pool.AllocateZeroArray<ui8>(size, align); - UNIT_ASSERT(size_t(byteArray) % align == 0); - for (size_t i = 0; i < size; ++i) { - UNIT_ASSERT(byteArray[i] == 0); + ui8* byteArray = pool.AllocateZeroArray<ui8>(size, align); + UNIT_ASSERT(size_t(byteArray) % align == 0); + for (size_t i = 0; i < size; ++i) { + UNIT_ASSERT(byteArray[i] == 0); } - } + } void TestLargeStartingAlign() { TMemoryPool pool(1); diff --git a/util/network/endpoint_ut.cpp b/util/network/endpoint_ut.cpp index 69f6365d77..d5e40dd6e1 100644 --- a/util/network/endpoint_ut.cpp +++ b/util/network/endpoint_ut.cpp @@ -70,20 +70,20 @@ Y_UNIT_TEST_SUITE(TEndpointTest) { he.insert(ep1); he.insert(ep2); - UNIT_ASSERT_VALUES_EQUAL(3u, he.size()); + UNIT_ASSERT_VALUES_EQUAL(3u, he.size()); he.insert(ep2_); - UNIT_ASSERT_VALUES_EQUAL(3u, he.size()); + UNIT_ASSERT_VALUES_EQUAL(3u, he.size()); he.insert(ep3); he.insert(ep3_); - UNIT_ASSERT_VALUES_EQUAL(4u, he.size()); + UNIT_ASSERT_VALUES_EQUAL(4u, he.size()); he.insert(ep4); - UNIT_ASSERT_VALUES_EQUAL(5u, he.size()); + UNIT_ASSERT_VALUES_EQUAL(5u, he.size()); } Y_UNIT_TEST(TestEqual) { diff --git a/util/network/socket.cpp b/util/network/socket.cpp index 44d04424bf..4f6e804346 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -713,7 +713,7 @@ static inline ssize_t DoSendV(SOCKET fd, const struct iovec* iov, size_t count) } while (ret == -1 && errno == EINTR); if (ret < 0) { - return -LastSystemError(); + return -LastSystemError(); } return ret; @@ -1092,11 +1092,11 @@ struct addrinfo* TNetworkAddress::Info() const noexcept { TNetworkResolutionError::TNetworkResolutionError(int error) { const char* errMsg = nullptr; -#ifdef _win_ +#ifdef _win_ errMsg = LastSystemErrorText(error); // gai_strerror is not thread-safe on Windows -#else - errMsg = gai_strerror(error); -#endif +#else + errMsg = gai_strerror(error); +#endif (*this) << errMsg << "(" << error; #if defined(_unix_) @@ -1106,8 +1106,8 @@ TNetworkResolutionError::TNetworkResolutionError(int error) { #endif (*this) << "): "; -} - +} + #if defined(_unix_) static inline int GetFlags(int fd) { const int ret = fcntl(fd, F_GETFL); diff --git a/util/network/socket.h b/util/network/socket.h index 0e587d2fff..40c8648b40 100644 --- a/util/network/socket.h +++ b/util/network/socket.h @@ -148,8 +148,8 @@ struct addrinfo; class TNetworkResolutionError: public yexception { public: - // @param error error code (EAI_XXX) returned by getaddrinfo or getnameinfo (not errno) - TNetworkResolutionError(int error); + // @param error error code (EAI_XXX) returned by getaddrinfo or getnameinfo (not errno) + TNetworkResolutionError(int error); }; struct TUnixSocketPath { diff --git a/util/network/socket_ut.cpp b/util/network/socket_ut.cpp index 4a826dc170..6b20e11f70 100644 --- a/util/network/socket_ut.cpp +++ b/util/network/socket_ut.cpp @@ -15,18 +15,18 @@ #endif class TSockTest: public TTestBase { - UNIT_TEST_SUITE(TSockTest); + UNIT_TEST_SUITE(TSockTest); UNIT_TEST(TestSock); UNIT_TEST(TestTimeout); -#ifndef _win_ // Test hangs on Windows +#ifndef _win_ // Test hangs on Windows UNIT_TEST_EXCEPTION(TestConnectionRefused, yexception); -#endif +#endif UNIT_TEST(TestNetworkResolutionError); UNIT_TEST(TestNetworkResolutionErrorMessage); UNIT_TEST(TestBrokenPipe); UNIT_TEST(TestClose); UNIT_TEST(TestReusePortAvailCheck); - UNIT_TEST_SUITE_END(); + UNIT_TEST_SUITE_END(); public: void TestSock(); @@ -53,45 +53,45 @@ void TSockTest::TestSock() { UNIT_ASSERT(!si.ReadLine().empty()); } -void TSockTest::TestTimeout() { - static const int timeout = 1000; - i64 startTime = millisec(); - try { - TNetworkAddress addr("localhost", 1313); - TSocket s(addr, TDuration::MilliSeconds(timeout)); +void TSockTest::TestTimeout() { + static const int timeout = 1000; + i64 startTime = millisec(); + try { + TNetworkAddress addr("localhost", 1313); + TSocket s(addr, TDuration::MilliSeconds(timeout)); } catch (const yexception&) { - } - int realTimeout = (int)(millisec() - startTime); - if (realTimeout > timeout + 2000) { + } + int realTimeout = (int)(millisec() - startTime); + if (realTimeout > timeout + 2000) { TString err = TStringBuilder() << "Timeout exceeded: " << realTimeout << " ms (expected " << timeout << " ms)"; - UNIT_FAIL(err); - } -} - -void TSockTest::TestConnectionRefused() { - TNetworkAddress addr("localhost", 1313); - TSocket s(addr); -} - -void TSockTest::TestNetworkResolutionError() { + UNIT_FAIL(err); + } +} + +void TSockTest::TestConnectionRefused() { + TNetworkAddress addr("localhost", 1313); + TSocket s(addr); +} + +void TSockTest::TestNetworkResolutionError() { TString errMsg; - try { - TNetworkAddress addr("", 0); + try { + TNetworkAddress addr("", 0); } catch (const TNetworkResolutionError& e) { - errMsg = e.what(); - } - + errMsg = e.what(); + } + if (errMsg.empty()) { - return; // on Windows getaddrinfo("", 0, ...) returns "OK" + return; // on Windows getaddrinfo("", 0, ...) returns "OK" } - - int expectedErr = EAI_NONAME; + + int expectedErr = EAI_NONAME; TString expectedErrMsg = gai_strerror(expectedErr); if (errMsg.find(expectedErrMsg) == TString::npos) { UNIT_FAIL("TNetworkResolutionError contains\nInvalid msg: " + errMsg + "\nExpected msg: " + expectedErrMsg + "\n"); - } -} - + } +} + void TSockTest::TestNetworkResolutionErrorMessage() { #ifdef _unix_ auto str = [](int code) -> TString { diff --git a/util/random/mersenne.cpp b/util/random/mersenne.cpp index 9d27da21aa..59779c1ec1 100644 --- a/util/random/mersenne.cpp +++ b/util/random/mersenne.cpp @@ -1 +1 @@ -#include "mersenne.h" +#include "mersenne.h" diff --git a/util/str_stl.h b/util/str_stl.h index 3ec85f5084..f1e137181d 100644 --- a/util/str_stl.h +++ b/util/str_stl.h @@ -62,14 +62,14 @@ struct hash: public NHashPrivate::THashHelper<T, std::is_scalar<T>::value && !st }; template <typename T> -struct hash<const T*> { +struct hash<const T*> { inline size_t operator()(const T* t) const noexcept { return NumericHash(t); } }; template <class T> -struct hash<T*>: public ::hash<const T*> { +struct hash<T*>: public ::hash<const T*> { }; template <> diff --git a/util/stream/buffered.cpp b/util/stream/buffered.cpp index 0455092912..a00e592e1c 100644 --- a/util/stream/buffered.cpp +++ b/util/stream/buffered.cpp @@ -396,7 +396,7 @@ void TBufferedOutputBase::DoFlush() { void TBufferedOutputBase::DoFinish() { THolder<TImpl> impl(Impl_.Release()); - if (impl) { + if (impl) { impl->Finish(); } } diff --git a/util/stream/input.cpp b/util/stream/input.cpp index 27bdfb404e..6e8170f2f9 100644 --- a/util/stream/input.cpp +++ b/util/stream/input.cpp @@ -81,7 +81,7 @@ void IInputStream::LoadOrFail(void* buf, size_t len) { size_t IInputStream::ReadLine(TString& st) { const size_t ret = ReadTo(st, '\n'); - if (ret && !st.empty() && st.back() == '\r') { + if (ret && !st.empty() && st.back() == '\r') { st.pop_back(); } @@ -170,7 +170,7 @@ namespace { const size_t ret = fread(buf, 1, len, F_); if (ret < len && ferror(F_)) { - ythrow TSystemError() << "can not read from stdin"; + ythrow TSystemError() << "can not read from stdin"; } return ret; @@ -192,7 +192,7 @@ namespace { size_t DoReadTo(TString& st, char ch) override { auto&& guard = Guard(M_); - + (void)guard; const auto r = getdelim(&B_, &L_, ch, F_); @@ -200,22 +200,22 @@ namespace { if (r < 0) { if (ferror(F_)) { ythrow TSystemError() << "can not read from stdin"; - } + } st.clear(); return 0; - } + } st.AssignNoAlias(B_, r); if (st && st.back() == ch) { st.pop_back(); - } + } return r; - } - + } + TAdaptiveLock M_; char* B_ = nullptr; size_t L_ = 0; diff --git a/util/stream/ios_ut.cpp b/util/stream/ios_ut.cpp index 9fd05ebd87..139f4296e5 100644 --- a/util/stream/ios_ut.cpp +++ b/util/stream/ios_ut.cpp @@ -304,32 +304,32 @@ namespace { size_t Index_; }; - const char Text[] = + const char Text[] = // UTF8 encoded "one \ntwo\r\nthree\n\tfour\nfive\n" in russian and ... - "один \n" - "два\r\n" - "три\n" - "\tчетыре\n" - "пять\n" + "один \n" + "два\r\n" + "три\n" + "\tчетыре\n" + "пять\n" // ... additional test cases - "\r\n" - "\n\r" // this char goes to the front of the next string - "one two\n" - "123\r\n" - "\t\r "; + "\r\n" + "\n\r" // this char goes to the front of the next string + "one two\n" + "123\r\n" + "\t\r "; - const char* Expected[] = { + const char* Expected[] = { // UTF8 encoded "one ", "two", "three", "\tfour", "five" in russian and ... - "один ", - "два", - "три", - "\tчетыре", - "пять", + "один ", + "два", + "три", + "\tчетыре", + "пять", // ... additional test cases - "", - "", - "\rone two", - "123", + "", + "", + "\rone two", + "123", "\t\r "}; void TestStreamReadTo1(IInputStream& input, const char* comment) { TString tmp; diff --git a/util/stream/output.cpp b/util/stream/output.cpp index 73f0e97e71..db81b81b70 100644 --- a/util/stream/output.cpp +++ b/util/stream/output.cpp @@ -352,11 +352,11 @@ namespace { void DoWrite(const void* buf, size_t len) override { if (len != fwrite(buf, 1, len, F_)) { #if defined(_win_) - // On Windows, if 'F_' is console -- 'fwrite' returns count of written characters. - // If, for example, console output codepage is UTF-8, then returned value is - // not equal to 'len'. So, we ignore some 'errno' values... + // On Windows, if 'F_' is console -- 'fwrite' returns count of written characters. + // If, for example, console output codepage is UTF-8, then returned value is + // not equal to 'len'. So, we ignore some 'errno' values... if ((errno == 0 || errno == EINVAL || errno == EILSEQ) && _isatty(fileno(F_))) { - return; + return; } #endif ythrow TSystemError() << "write failed"; diff --git a/util/stream/output.h b/util/stream/output.h index e9fe6ef7a2..00eef50b95 100644 --- a/util/stream/output.h +++ b/util/stream/output.h @@ -283,7 +283,7 @@ namespace NPrivate { * End-of-line output manipulator, basically the same as `std::endl`. */ static inline void Endl(IOutputStream& o) { - (o << '\n').Flush(); + (o << '\n').Flush(); } /** diff --git a/util/stream/pipe.cpp b/util/stream/pipe.cpp index abe1dcd2cb..51be1934a7 100644 --- a/util/stream/pipe.cpp +++ b/util/stream/pipe.cpp @@ -10,11 +10,11 @@ public: inline TImpl(const TString& command, const char* mode) : Pipe_(nullptr) { -#ifndef _freebsd_ +#ifndef _freebsd_ if (strcmp(mode, "r+") == 0) { ythrow TSystemError(EINVAL) << "pipe \"r+\" mode is implemented only on FreeBSD"; } -#endif +#endif Pipe_ = ::popen(command.data(), mode); if (Pipe_ == nullptr) { ythrow TSystemError() << "failed to open pipe: " << command.Quote(); diff --git a/util/stream/printf_ut.cpp b/util/stream/printf_ut.cpp index e7fb7dbe8d..0eab167062 100644 --- a/util/stream/printf_ut.cpp +++ b/util/stream/printf_ut.cpp @@ -14,12 +14,12 @@ Y_UNIT_TEST_SUITE(TStreamPrintfTest) { UNIT_ASSERT_EQUAL(ss.Str(), "qw er 1"); } -#ifdef __GNUC__ +#ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wformat-zero-length" -#endif // __GNUC__ - +#endif // __GNUC__ + Y_UNIT_TEST(TestZeroString) { - UNIT_ASSERT_EQUAL(Printf(Cnull, ""), 0); + UNIT_ASSERT_EQUAL(Printf(Cnull, ""), 0); } Y_UNIT_TEST(TestLargePrintf) { diff --git a/util/stream/zlib.cpp b/util/stream/zlib.cpp index 958be7af2c..60f4e9439f 100644 --- a/util/stream/zlib.cpp +++ b/util/stream/zlib.cpp @@ -171,7 +171,7 @@ namespace { } ~TDecompressStream() override = default; - + private: size_t DoNext(const void** ptr, size_t len) override { void* buf = AdditionalData(); @@ -364,7 +364,7 @@ void TZLibCompress::DoWrite(const void* buf, size_t size) { } void TZLibCompress::DoFlush() { - if (Impl_) { + if (Impl_) { Impl_->Flush(); } } @@ -372,7 +372,7 @@ void TZLibCompress::DoFlush() { void TZLibCompress::DoFinish() { THolder<TImpl> impl(Impl_.Release()); - if (impl) { + if (impl) { impl->Finish(); } } diff --git a/util/string/cast.h b/util/string/cast.h index af827da78b..90e925c194 100644 --- a/util/string/cast.h +++ b/util/string/cast.h @@ -165,11 +165,11 @@ inline T FromString(const std::string& s) { return ::FromString<T>(s.data(), s.size()); } -template <> +template <> inline TString FromString<TString>(const TString& s) { - return s; -} - + return s; +} + template <class T> inline T FromString(const TWtringBuf& s) { return ::FromString<T, typename TWtringBuf::char_type>(s.data(), s.size()); diff --git a/util/string/printf_ut.cpp b/util/string/printf_ut.cpp index 1b63d0f8bc..2b2f980b70 100644 --- a/util/string/printf_ut.cpp +++ b/util/string/printf_ut.cpp @@ -5,10 +5,10 @@ Y_UNIT_TEST_SUITE(TStringPrintf) { Y_UNIT_TEST(TestSprintf) { TString s; - int len = sprintf(s, "Hello %s", "world"); + int len = sprintf(s, "Hello %s", "world"); UNIT_ASSERT_EQUAL(s, TString("Hello world")); UNIT_ASSERT_EQUAL(len, 11); - } + } Y_UNIT_TEST(TestFcat) { TString s; diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp index 25b6279863..d1029d1498 100644 --- a/util/string/strip_ut.cpp +++ b/util/string/strip_ut.cpp @@ -7,7 +7,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { Y_UNIT_TEST(TestStrip) { struct TTest { - const char* Str; + const char* Str; const char* StripLeftRes; const char* StripRightRes; const char* StripRes; @@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { {"abc", "abc", "abc", "abc"}, {"a c", "a c", "a c", "a c"}, }; - + for (const auto& test : tests) { TString inputStr(test.Str); @@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { UNIT_ASSERT_EQUAL(StripString(inputStrBuf), test.StripRes); UNIT_ASSERT_EQUAL(StripStringLeft(inputStrBuf), test.StripLeftRes); UNIT_ASSERT_EQUAL(StripStringRight(inputStrBuf), test.StripRightRes); - }; + }; } Y_UNIT_TEST(TestCustomStrip) { diff --git a/util/string/subst_ut.cpp b/util/string/subst_ut.cpp index 940d5195bc..21eccef779 100644 --- a/util/string/subst_ut.cpp +++ b/util/string/subst_ut.cpp @@ -121,13 +121,13 @@ Y_UNIT_TEST_SUITE(TStringSubst) { Y_UNIT_TEST(TestSubstGlobalOld) { TString s; - s = "aaa"; + s = "aaa"; SubstGlobal(s, "a", "bb"); UNIT_ASSERT_EQUAL(s, TString("bbbbbb")); - s = "aaa"; + s = "aaa"; SubstGlobal(s, "a", "b"); UNIT_ASSERT_EQUAL(s, TString("bbb")); - s = "aaa"; + s = "aaa"; SubstGlobal(s, "a", ""); UNIT_ASSERT_EQUAL(s, TString("")); s = "abcdefbcbcdfb"; @@ -168,7 +168,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) { TString s = "aaa"; SubstGlobal(s, 'a', 'b', 1); UNIT_ASSERT_EQUAL(s, TString("abb")); - } + } Y_UNIT_TEST(TestSubstCharGlobalRet) { const TUtf16String w1 = u"abcdabcd"; diff --git a/util/string/type_ut.cpp b/util/string/type_ut.cpp index daff2a7eec..03e7af62bd 100644 --- a/util/string/type_ut.cpp +++ b/util/string/type_ut.cpp @@ -6,11 +6,11 @@ Y_UNIT_TEST_SUITE(TStringClassify) { Y_UNIT_TEST(TestIsSpace) { - UNIT_ASSERT_EQUAL(IsSpace(" "), true); - UNIT_ASSERT_EQUAL(IsSpace("\t\r\n"), true); - UNIT_ASSERT_EQUAL(IsSpace(""), false); - UNIT_ASSERT_EQUAL(IsSpace(" a"), false); - } + UNIT_ASSERT_EQUAL(IsSpace(" "), true); + UNIT_ASSERT_EQUAL(IsSpace("\t\r\n"), true); + UNIT_ASSERT_EQUAL(IsSpace(""), false); + UNIT_ASSERT_EQUAL(IsSpace(" a"), false); + } Y_UNIT_TEST(TestIsTrue) { UNIT_ASSERT(IsTrue("1")); diff --git a/util/string/util.cpp b/util/string/util.cpp index 10f265ee00..b14f20bf75 100644 --- a/util/string/util.cpp +++ b/util/string/util.cpp @@ -69,4 +69,4 @@ void Tr::Do(TString& str) const { for (auto it = str.begin() + changePosition; it != str.end(); ++it) { *it = ConvertChar(*it); } -} +} diff --git a/util/string/util.h b/util/string/util.h index 1e173ab75f..0d77a5042b 100644 --- a/util/string/util.h +++ b/util/string/util.h @@ -4,7 +4,7 @@ #include <cstring> #include <cstdarg> -#include <algorithm> +#include <algorithm> #include <util/system/defaults.h> #include <util/generic/string.h> @@ -13,7 +13,7 @@ /// @addtogroup Strings_Miscellaneous /// @{ int a2i(const TString& s); - + /// Removes the last character if it is equal to c. template <class T> inline void RemoveIfLast(T& s, int c) { @@ -170,7 +170,7 @@ public: *dst = 0; } void Do(char* s, size_t l) const { - for (size_t i = 0; i < l && s[i]; i++) + for (size_t i = 0; i < l && s[i]; i++) s[i] = ConvertChar(s[i]); } void Do(TString& str) const; @@ -180,16 +180,16 @@ private: size_t FindFirstChangePosition(const TString& str) const; }; - -// Removes all occurrences of given character from string + +// Removes all occurrences of given character from string template <typename TStringType> void RemoveAll(TStringType& str, typename TStringType::char_type ch) { size_t pos = str.find(ch); // 'find' to avoid cloning of string in 'TString.begin()' if (pos == TStringType::npos) - return; - + return; + typename TStringType::iterator begin = str.begin(); typename TStringType::iterator end = begin + str.length(); typename TStringType::iterator it = std::remove(begin + pos, end, ch); - str.erase(it, end); -} + str.erase(it, end); +} diff --git a/util/string/util_ut.cpp b/util/string/util_ut.cpp index 7012e9714c..18a2d8e195 100644 --- a/util/string/util_ut.cpp +++ b/util/string/util_ut.cpp @@ -22,25 +22,25 @@ public: UNIT_ASSERT_EQUAL(strcmp(rul.sep(s1), "+-"), 0); UNIT_ASSERT_EQUAL(rul.sep(s1), nullptr); } - - void TestRemoveAll() { - static const struct T { - const char* Str; - char Ch; - const char* Result; + + void TestRemoveAll() { + static const struct T { + const char* Str; + char Ch; + const char* Result; } tests[] = { {"", 'x', ""}, {"hello world", 'h', "ello world"}, {"hello world", 'l', "heo word"}, {"hello world", 'x', "hello world"}, }; - + for (const T* t = tests; t != std::end(tests); ++t) { TString str(t->Str); - RemoveAll(str, t->Ch); - UNIT_ASSERT_EQUAL(t->Result, str); - } - } + RemoveAll(str, t->Ch); + UNIT_ASSERT_EQUAL(t->Result, str); + } + } }; UNIT_TEST_SUITE_REGISTRATION(TStrUtilTest); diff --git a/util/string/vector.cpp b/util/string/vector.cpp index 963186fe1e..9ba401f0a2 100644 --- a/util/string/vector.cpp +++ b/util/string/vector.cpp @@ -88,4 +88,4 @@ TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t co const size_t l = f + Min(count, v.size() - f); return JoinStrings(v.begin() + f, v.begin() + l, delim); -} +} diff --git a/util/string/vector.h b/util/string/vector.h index 8322f349f1..e36c348bbe 100644 --- a/util/string/vector.h +++ b/util/string/vector.h @@ -119,14 +119,14 @@ inline TString JoinVectorIntoString(const TVector<T>& v, size_t index, size_t co TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim); TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim); - + //! Converts vector of strings to vector of type T variables template <typename T, typename TStringType> TVector<T> Scan(const TVector<TStringType>& input) { TVector<T> output; - output.reserve(input.size()); + output.reserve(input.size()); for (int i = 0; i < input.ysize(); ++i) { - output.push_back(FromString<T>(input[i])); - } - return output; -} + output.push_back(FromString<T>(input[i])); + } + return output; +} diff --git a/util/string/vector_ut.cpp b/util/string/vector_ut.cpp index 49ed32497b..817120f268 100644 --- a/util/string/vector_ut.cpp +++ b/util/string/vector_ut.cpp @@ -1,5 +1,5 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/charset/wide.h> +#include <util/charset/wide.h> #include "cast.h" #include "vector.h" @@ -28,11 +28,11 @@ Y_UNIT_TEST_SUITE(TStringJoinTest) { UNIT_ASSERT_EQUAL(JoinStrings(v, 1, 10, ToWtring(" ")), ToWtring("2")); } - + Y_UNIT_TEST(TestJoinWStrings) { const TUtf16String str = u"Яндекс"; const TVector<TUtf16String> v(1, str); - + UNIT_ASSERT_EQUAL(JoinStrings(v, TUtf16String()), str); - } + } } diff --git a/util/system/compat.h b/util/system/compat.h index 67f1b2af27..c53dbcca17 100644 --- a/util/system/compat.h +++ b/util/system/compat.h @@ -28,7 +28,7 @@ extern "C" { #define SIGALRM 14 //will not receive under win? #endif -#if defined(__FreeBSD__) || defined(_darwin_) +#if defined(__FreeBSD__) || defined(_darwin_) #define HAVE_NATIVE_GETPROGNAME #endif diff --git a/util/system/compiler.h b/util/system/compiler.h index de93b5240d..b373edcc46 100644 --- a/util/system/compiler.h +++ b/util/system/compiler.h @@ -76,7 +76,7 @@ #define Y_DECLARE_UNUSED #endif -#if defined(__GNUC__) +#if defined(__GNUC__) #define Y_LIKELY(Cond) __builtin_expect(!!(Cond), 1) #define Y_UNLIKELY(Cond) __builtin_expect(!!(Cond), 0) #define Y_PREFETCH_READ(Pointer, Priority) __builtin_prefetch((const void*)(Pointer), 0, Priority) @@ -163,7 +163,7 @@ #define Y_PACKED #endif -#if defined(__GNUC__) +#if defined(__GNUC__) #define Y_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) #endif diff --git a/util/system/context.cpp b/util/system/context.cpp index b3ba4bf13d..ad99309088 100644 --- a/util/system/context.cpp +++ b/util/system/context.cpp @@ -217,7 +217,7 @@ void ContextTrampoLine(void* arg) { #endif #if defined(USE_FIBER_CONT) -TContMachineContext::TContMachineContext() +TContMachineContext::TContMachineContext() : Fiber_(ConvertThreadToFiber(this)) , MainFiber_(true) { diff --git a/util/system/daemon.cpp b/util/system/daemon.cpp index f7c3106242..130e6c8f45 100644 --- a/util/system/daemon.cpp +++ b/util/system/daemon.cpp @@ -85,11 +85,11 @@ bool NDaemonMaker::MakeMeDaemon(ECloseDescriptors cd, EStdIoDescriptors iod, ECh return true; } - if (chd == chdirRoot) { + if (chd == chdirRoot) { if (chdir("/")) { - ythrow TSystemError() << "chdir(\"/\") failed"; + ythrow TSystemError() << "chdir(\"/\") failed"; } - } + } int fd[4] = {-1, -1, -1, -1}; switch (iod) { diff --git a/util/system/defaults.h b/util/system/defaults.h index b5b3b4569b..dcd7abea38 100644 --- a/util/system/defaults.h +++ b/util/system/defaults.h @@ -56,7 +56,7 @@ #define _must_align2_ #endif -#if defined(__GNUC__) +#if defined(__GNUC__) #define alias_hack __attribute__((__may_alias__)) #endif diff --git a/util/system/direct_io.cpp b/util/system/direct_io.cpp index c6328127b8..f59c54b0cb 100644 --- a/util/system/direct_io.cpp +++ b/util/system/direct_io.cpp @@ -87,7 +87,7 @@ void TDirectIOBufferedFile::SetDirectIO(bool value) { DirectIO = value; #else - DirectIO = value; + DirectIO = value; #endif } diff --git a/util/system/error.cpp b/util/system/error.cpp index a33c09badf..f778ec42cb 100644 --- a/util/system/error.cpp +++ b/util/system/error.cpp @@ -67,22 +67,22 @@ const char* LastSystemErrorText(int code) { #endif } -#ifdef _win_ -static char* Strip(char* s) { - size_t len = strlen(s); - const char* ptr = s; - Strip(ptr, len); - if (ptr != s) - memmove(s, ptr, len); - s[len] = 0; - return s; -} -#endif // _win_ - +#ifdef _win_ +static char* Strip(char* s) { + size_t len = strlen(s); + const char* ptr = s; + Strip(ptr, len); + if (ptr != s) + memmove(s, ptr, len); + s[len] = 0; + return s; +} +#endif // _win_ + void LastSystemErrorText(char* str, size_t size, int code) { #if defined(_win_) FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, code, 0, str, DWORD(size), 0); - Strip(str); + Strip(str); #elif defined(_sun_) strfcpy(str, strerror(code), size); #elif defined(_freebsd_) || defined(_darwin_) || defined(_musl_) || defined(_bionic_) diff --git a/util/system/file.cpp b/util/system/file.cpp index c971df64e2..4a261d020c 100644 --- a/util/system/file.cpp +++ b/util/system/file.cpp @@ -86,10 +86,10 @@ TFileHandle::TFileHandle(const TString& fName, EOpenMode oMode) noexcept { case OpenAlways: fcMode = OPEN_ALWAYS; break; - case CreateNew: + case CreateNew: fcMode = CREATE_NEW; break; - case CreateAlways: + case CreateAlways: fcMode = CREATE_ALWAYS; break; default: @@ -152,10 +152,10 @@ TFileHandle::TFileHandle(const TString& fName, EOpenMode oMode) noexcept { case OpenAlways: fcMode = O_CREAT; break; - case CreateNew: + case CreateNew: fcMode = O_CREAT | O_EXCL; break; - case CreateAlways: + case CreateAlways: fcMode = O_CREAT | O_TRUNC; break; default: @@ -417,7 +417,7 @@ bool TFileHandle::Flush() noexcept { return false; } #if defined(_win_) - bool ok = ::FlushFileBuffers(Fd_) != 0; + bool ok = ::FlushFileBuffers(Fd_) != 0; /* * FlushFileBuffers fails if hFile is a handle to the console output. * That is because the console output is not buffered. diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp index d22f412b37..941e6a50f3 100644 --- a/util/system/file_ut.cpp +++ b/util/system/file_ut.cpp @@ -143,7 +143,7 @@ void TFileTest::TestOpen() { UNIT_ASSERT_VALUES_EQUAL(f1.GetLength(), 0); try { - TFile f2("f1.txt", CreateNew); + TFile f2("f1.txt", CreateNew); } catch (const yexception& e) { res = e.what(); } @@ -163,7 +163,7 @@ void TFileTest::TestOpenSync() { } void TFileTest::TestRW() { - TFile f1("f1.txt", CreateNew); + TFile f1("f1.txt", CreateNew); UNIT_ASSERT(f1.IsOpen()); UNIT_ASSERT_VALUES_EQUAL(f1.GetName(), "f1.txt"); UNIT_ASSERT_VALUES_EQUAL(f1.GetLength(), 0); diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp index 41d6244e6d..7454a4cb94 100644 --- a/util/system/filemap.cpp +++ b/util/system/filemap.cpp @@ -34,7 +34,7 @@ #include <util/system/sanitizers.h> #include "filemap.h" -#undef PAGE_SIZE +#undef PAGE_SIZE #undef GRANULARITY #ifdef _win_ diff --git a/util/system/fs_win.h b/util/system/fs_win.h index b863c456ba..8086129828 100644 --- a/util/system/fs_win.h +++ b/util/system/fs_win.h @@ -3,7 +3,7 @@ #include "winint.h" #include "defaults.h" -#include <util/generic/strbuf.h> +#include <util/generic/strbuf.h> #include <util/generic/string.h> namespace NFsPrivate { diff --git a/util/system/maxlen.h b/util/system/maxlen.h index 483c7a4fb5..e1ff7f5008 100644 --- a/util/system/maxlen.h +++ b/util/system/maxlen.h @@ -1,7 +1,7 @@ #pragma once -#include <cstdlib> - +#include <cstdlib> + // http://support.microsoft.com/kb/208427 #ifndef URL_MAXLEN #define URL_MAXLEN 2083 diff --git a/util/system/shellcommand.cpp b/util/system/shellcommand.cpp index f939953bf2..b1989b5c8c 100644 --- a/util/system/shellcommand.cpp +++ b/util/system/shellcommand.cpp @@ -43,7 +43,7 @@ using TPid = HANDLE; using TWaitResult = DWORD; using TExitStatus = DWORD; #define WAIT_PROCEED WAIT_TIMEOUT - + #pragma warning(disable : 4296) // 'wait_result >= WAIT_OBJECT_0' : expression is always tru #else #error("unknown os, shell command is not implemented") @@ -618,7 +618,7 @@ void TShellCommand::TImpl::StartProcess(TShellCommand::TImpl::TPipes& pipes) { if (!res) { AtomicSet(ExecutionStatus, SHELL_ERROR); /// @todo: write to error stream if set - TStringOutput out(CollectedError); + TStringOutput out(CollectedError); out << "Process was not created: " << LastSystemErrorText() << " command text was: '" << GetAString(cmdcopy.Data()) << "'"; } Pid = process_info.hProcess; @@ -925,7 +925,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) { char* bufPos = nullptr; #endif TWaitResult waitPidResult; - TExitStatus status = 0; + TExitStatus status = 0; while (true) { { diff --git a/util/system/src_location.cpp b/util/system/src_location.cpp index def480add9..13ff1f24b3 100644 --- a/util/system/src_location.cpp +++ b/util/system/src_location.cpp @@ -2,16 +2,16 @@ #include <util/stream/output.h> -#include <algorithm> - +#include <algorithm> + template <> void Out<TSourceLocation>(IOutputStream& o, const TSourceLocation& t) { -#if defined(_win_) +#if defined(_win_) TString file(t.File); - std::replace(file.begin(), file.vend(), '\\', '/'); - o << file; -#else - o << t.File; -#endif - o << ':' << t.Line; + std::replace(file.begin(), file.vend(), '\\', '/'); + o << file; +#else + o << t.File; +#endif + o << ':' << t.Line; } diff --git a/util/system/src_root_ut.cpp b/util/system/src_root_ut.cpp index 7b65a0a36d..e9a675eb9a 100644 --- a/util/system/src_root_ut.cpp +++ b/util/system/src_root_ut.cpp @@ -1,11 +1,11 @@ #include "src_root.h" -#include <util/folder/pathsplit.h> +#include <util/folder/pathsplit.h> #include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(TestSourceRoot) { Y_UNIT_TEST(TestStrip) { - // Reconstruct() converts "\" -> "/" on Windows + // Reconstruct() converts "\" -> "/" on Windows const TString path = TPathSplit(__SOURCE_FILE_IMPL__.As<TStringBuf>()).Reconstruct(); UNIT_ASSERT_EQUAL(path, "util" LOCSLASH_S "system" LOCSLASH_S "src_root_ut.cpp"); } diff --git a/util/system/thread.cpp b/util/system/thread.cpp index d7615776b8..6236746c2d 100644 --- a/util/system/thread.cpp +++ b/util/system/thread.cpp @@ -43,7 +43,7 @@ namespace { inline void SetThrName(const TParams& p) { try { - if (p.Name) { + if (p.Name) { TThread::SetCurrentThreadName(p.Name.data()); } } catch (...) { @@ -107,7 +107,7 @@ namespace { } static ui32 __stdcall Proxy(void* ptr) { - NTls::TCleaner cleaner; + NTls::TCleaner cleaner; (void)cleaner; @@ -313,7 +313,7 @@ void TThread::Detach() { } bool TThread::Running() const noexcept { - return Impl_ && Impl_->Running(); + return Impl_ && Impl_->Running(); } TThread::TId TThread::Id() const noexcept { diff --git a/util/system/types_ut.cpp b/util/system/types_ut.cpp index 0ee71d6f03..19e40cef46 100644 --- a/util/system/types_ut.cpp +++ b/util/system/types_ut.cpp @@ -1,23 +1,23 @@ -#include "types.h" - +#include "types.h" + #include <library/cpp/testing/unittest/registar.h> - + Y_UNIT_TEST_SUITE(TestTypes) { Y_UNIT_TEST(TestScanf) { - i32 val32 = 0; - sscanf("-123", "%" SCNi32, &val32); - UNIT_ASSERT(val32 == -123); - sscanf("234", "%" SCNu32, &val32); - UNIT_ASSERT(val32 == 234); - sscanf("159", "%" SCNx32, &val32); - UNIT_ASSERT(val32 == 345); - - i64 val64 = 0; - sscanf("-123", "%" SCNi64, &val64); - UNIT_ASSERT(val64 == -123); - sscanf("234", "%" SCNu64, &val64); - UNIT_ASSERT(val64 == 234); - sscanf("159", "%" SCNx64, &val64); - UNIT_ASSERT(val64 == 345); - } -} + i32 val32 = 0; + sscanf("-123", "%" SCNi32, &val32); + UNIT_ASSERT(val32 == -123); + sscanf("234", "%" SCNu32, &val32); + UNIT_ASSERT(val32 == 234); + sscanf("159", "%" SCNx32, &val32); + UNIT_ASSERT(val32 == 345); + + i64 val64 = 0; + sscanf("-123", "%" SCNi64, &val64); + UNIT_ASSERT(val64 == -123); + sscanf("234", "%" SCNu64, &val64); + UNIT_ASSERT(val64 == 234); + sscanf("159", "%" SCNx64, &val64); + UNIT_ASSERT(val64 == 345); + } +} diff --git a/util/system/ut/ya.make b/util/system/ut/ya.make index 4871c632a8..127e7c261e 100644 --- a/util/system/ut/ya.make +++ b/util/system/ut/ya.make @@ -70,7 +70,7 @@ SRCS( system/tempfile_ut.cpp system/thread_ut.cpp system/tls_ut.cpp - system/types_ut.cpp + system/types_ut.cpp system/type_name_ut.cpp system/user_ut.cpp system/unaligned_mem_ut.cpp diff --git a/util/system/yassert.cpp b/util/system/yassert.cpp index 58a0bce2cf..0f586648b7 100644 --- a/util/system/yassert.cpp +++ b/util/system/yassert.cpp @@ -67,13 +67,13 @@ namespace NPrivate { TString r; TStringOutput o(r); - if (expr) { + if (expr) { o << "VERIFY failed (" << now << "): " << errorMsg << Endl; } else { o << "FAIL (" << now << "): " << errorMsg << Endl; } o << " " << file << ":" << line << Endl; - if (expr) { + if (expr) { o << " " << function << "(): requirement " << expr << " failed" << Endl; } else { o << " " << function << "() failed" << Endl; diff --git a/util/ysafeptr.h b/util/ysafeptr.h index 94b08e9d6b..af7dfd4bed 100644 --- a/util/ysafeptr.h +++ b/util/ysafeptr.h @@ -20,7 +20,7 @@ // for destruction of objects (because of 'delete this'). //////////////////////////////////////////////////////////////////////////////////////////////////// -#if defined(_MSC_VER) && defined(_DEBUG) +#if defined(_MSC_VER) && defined(_DEBUG) #include <util/system/winint.h> #define CHECK_YPTR2 #endif @@ -223,7 +223,7 @@ private: return dynamic_cast<classname*>(p); \ } \ Y_PRAGMA_DIAGNOSTIC_POP - + //////////////////////////////////////////////////////////////////////////////////////////////////// template <class TUserObj> IObjectBase* CastToObjectBaseImpl(TUserObj* p, void*); diff --git a/ydb/core/kqp/provider/yql_kikimr_gateway.cpp b/ydb/core/kqp/provider/yql_kikimr_gateway.cpp index 18365dc003..e49f84b5e1 100644 --- a/ydb/core/kqp/provider/yql_kikimr_gateway.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_gateway.cpp @@ -142,7 +142,7 @@ bool IKikimrGateway::TrySplitTablePath(const TString& path, std::pair<TString, T result = std::make_pair( CombinePath(parts.begin(), parts.end() - 1), - parts.back()); + parts.back()); return true; } diff --git a/ydb/core/util/interval_set_ut.cpp b/ydb/core/util/interval_set_ut.cpp index c5e152fe72..c1df7015fd 100644 --- a/ydb/core/util/interval_set_ut.cpp +++ b/ydb/core/util/interval_set_ut.cpp @@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(TIntervalSetTest) { counters[i] = 0; } - while (counters.back() < sets.size()) { + while (counters.back() < sets.size()) { ui64 added = 0; //Cerr << "set" << Endl; TIntervals b; |