diff options
author | xpahos <xpahos@yandex-team.ru> | 2022-02-10 16:47:21 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:21 +0300 |
commit | 52faf709473af8421da1e2ea84ae1879b16665b8 (patch) | |
tree | 2ec4264cfbc5e294ea04a7b12b9fa0b41f4d96ce | |
parent | eec632e483ae34bc211138c67434b1e0e6054ced (diff) | |
download | ydb-52faf709473af8421da1e2ea84ae1879b16665b8.tar.gz |
Restoring authorship annotation for <xpahos@yandex-team.ru>. Commit 1 of 2.
-rw-r--r-- | build/rules/go/vendor.policy | 22 | ||||
-rw-r--r-- | contrib/libs/rapidjson/include/rapidjson/reader.h | 12 | ||||
-rw-r--r-- | contrib/tools/bison/gnulib/src/vasnprintf.c | 2 | ||||
-rw-r--r-- | library/cpp/json/json_reader.cpp | 70 | ||||
-rw-r--r-- | library/cpp/json/json_reader.h | 36 | ||||
-rw-r--r-- | library/cpp/json/ut/json_reader_ut.cpp | 46 | ||||
-rw-r--r-- | util/datetime/base.cpp | 16 | ||||
-rw-r--r-- | util/datetime/base.h | 28 | ||||
-rw-r--r-- | util/datetime/base_ut.cpp | 8 | ||||
-rw-r--r-- | util/network/socket.cpp | 14 | ||||
-rw-r--r-- | util/system/fstat.cpp | 4 | ||||
-rw-r--r-- | util/system/fstat_ut.cpp | 2 |
12 files changed, 130 insertions, 130 deletions
diff --git a/build/rules/go/vendor.policy b/build/rules/go/vendor.policy index 3e9c0acada..a7bda4bed7 100644 --- a/build/rules/go/vendor.policy +++ b/build/rules/go/vendor.policy @@ -163,9 +163,9 @@ ALLOW .* -> vendor/go.etcd.io/etcd/pkg/types # logging to systemd ALLOW .* -> vendor/github.com/coreos/go-systemd/journal -# CONTRIB-2336 logging to systemd v22 -ALLOW .* -> vendor/github.com/coreos/go-systemd/v22/journal - +# CONTRIB-2336 logging to systemd v22 +ALLOW .* -> vendor/github.com/coreos/go-systemd/v22/journal + # systemd dbus ALLOW .* -> vendor/github.com/coreos/go-systemd/v22/dbus @@ -719,10 +719,10 @@ ALLOW .* -> vendor/github.com/insomniacslk/dhcp ALLOW .* -> vendor/github.com/osrg/gobgp # -# CONTRIB-2097 QUIC(HTTP/3) implementation library -# -ALLOW .* -> vendor/github.com/lucas-clemente/quic-go - +# CONTRIB-2097 QUIC(HTTP/3) implementation library +# +ALLOW .* -> vendor/github.com/lucas-clemente/quic-go + # CONTRIB-2111 distributed lock on redis ALLOW .* -> vendor/github.com/go-redsync/redsync/v4 @@ -860,7 +860,7 @@ ALLOW .* -> vendor/github.com/pkg/xattr # CONTRIB-2452 ALLOW .* -> vendor/github.com/scim2/filter-parser/v2 -# +# # Tools # @@ -1021,9 +1021,9 @@ ALLOW transfer_manager/go/pkg/source/eventhub -> vendor/github.com/Azure/azure-a ALLOW trust/psp/core/go -> vendor/github.com/gorilla/mux ALLOW trust/psp/core/handler -> vendor/github.com/gorilla/mux -# CONTRIB-2337 Cloud GPU migration: validator for structs and fields -ALLOW cloud/compute/go-common/pkg/validation -> vendor/github.com/go-playground/validator/v10 - +# CONTRIB-2337 Cloud GPU migration: validator for structs and fields +ALLOW cloud/compute/go-common/pkg/validation -> vendor/github.com/go-playground/validator/v10 + # CONTRIB-2412 ALLOW infra/infractl/.* -> vendor/github.com/google/gnostic/openapiv3 ALLOW infra/infractl/.* -> vendor/github.com/google/gnostic/compiler diff --git a/contrib/libs/rapidjson/include/rapidjson/reader.h b/contrib/libs/rapidjson/include/rapidjson/reader.h index c5c9bec58a..dfa7fd0d8a 100644 --- a/contrib/libs/rapidjson/include/rapidjson/reader.h +++ b/contrib/libs/rapidjson/include/rapidjson/reader.h @@ -153,7 +153,7 @@ enum ParseFlag { kParseNumbersAsStringsFlag = 64, //!< Parse all numbers (ints/doubles) as strings. kParseTrailingCommasFlag = 128, //!< Allow trailing commas at the end of objects and arrays. kParseNanAndInfFlag = 256, //!< Allow parsing NaN, Inf, Infinity, -Inf and -Infinity as doubles. - kParseEscapedApostropheFlag = 512, //!< Allow escaped apostrophe in strings. + kParseEscapedApostropheFlag = 512, //!< Allow escaped apostrophe in strings. kParseDefaultFlags = RAPIDJSON_PARSE_DEFAULT_FLAGS //!< Default parse flags. Can be customized by defining RAPIDJSON_PARSE_DEFAULT_FLAGS }; @@ -905,7 +905,7 @@ private: //!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN #define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 static const char escape[256] = { - Z16, Z16, 0, 0,'\"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '/', + Z16, Z16, 0, 0,'\"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '/', Z16, Z16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\', 0, 0, 0, 0, 0,'\b', 0, 0, 0,'\f', 0, 0, 0, 0, 0, 0, 0,'\n', 0, 0, 0,'\r', 0,'\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -928,10 +928,10 @@ private: is.Take(); os.Put(static_cast<typename TEncoding::Ch>(escape[static_cast<unsigned char>(e)])); } - else if ((parseFlags & kParseEscapedApostropheFlag) && RAPIDJSON_LIKELY(e == '\'')) { // Allow escaped apostrophe - is.Take(); - os.Put('\''); - } + else if ((parseFlags & kParseEscapedApostropheFlag) && RAPIDJSON_LIKELY(e == '\'')) { // Allow escaped apostrophe + is.Take(); + os.Put('\''); + } else if (RAPIDJSON_LIKELY(e == 'u')) { // Unicode is.Take(); unsigned codepoint = ParseHex4(is, escapeOffset); diff --git a/contrib/tools/bison/gnulib/src/vasnprintf.c b/contrib/tools/bison/gnulib/src/vasnprintf.c index 4de22819fa..6d256dad62 100644 --- a/contrib/tools/bison/gnulib/src/vasnprintf.c +++ b/contrib/tools/bison/gnulib/src/vasnprintf.c @@ -4870,7 +4870,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, #endif *fbp = dp->conversion; #if USE_SNPRINTF -# if !defined(__APPLE__) && !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) +# if !defined(__APPLE__) && !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) fbp[1] = '%'; fbp[2] = 'n'; fbp[3] = '\0'; diff --git a/library/cpp/json/json_reader.cpp b/library/cpp/json/json_reader.cpp index 072c8deafe..e2f1d4102f 100644 --- a/library/cpp/json/json_reader.cpp +++ b/library/cpp/json/json_reader.cpp @@ -312,37 +312,37 @@ namespace NJson { rapidjson::Reader& reader, TRapidJsonCompliantInputStream& is, THandler& handler) { - - ui8 flags = ReaderConfigToRapidJsonFlags::NOCOMMENTS_VALID_NOESCAPE; - + + ui8 flags = ReaderConfigToRapidJsonFlags::NOCOMMENTS_VALID_NOESCAPE; + if (config.AllowComments) { - flags |= ReaderConfigFlags::COMMENTS; - } - - if (config.DontValidateUtf8) { - flags &= ~(ReaderConfigFlags::VALIDATE); - } - - if (config.AllowEscapedApostrophe) { - flags |= ReaderConfigFlags::ESCAPE; - } - - switch (flags) { - case ReaderConfigToRapidJsonFlags::COMMENTS_NOVALID_NOESCAPE: + flags |= ReaderConfigFlags::COMMENTS; + } + + if (config.DontValidateUtf8) { + flags &= ~(ReaderConfigFlags::VALIDATE); + } + + if (config.AllowEscapedApostrophe) { + flags |= ReaderConfigFlags::ESCAPE; + } + + switch (flags) { + case ReaderConfigToRapidJsonFlags::COMMENTS_NOVALID_NOESCAPE: return reader.Parse<rapidjson::kParseCommentsFlag>(is, handler); - case ReaderConfigToRapidJsonFlags::COMMENTS_VALID_NOESCAPE: + case ReaderConfigToRapidJsonFlags::COMMENTS_VALID_NOESCAPE: return reader.Parse<rapidjson::kParseCommentsFlag | rapidjson::kParseValidateEncodingFlag>(is, handler); - case ReaderConfigToRapidJsonFlags::COMMENTS_VALID_ESCAPE: - return reader.Parse<rapidjson::kParseCommentsFlag | rapidjson::kParseValidateEncodingFlag | rapidjson::kParseEscapedApostropheFlag>(is, handler); - case ReaderConfigToRapidJsonFlags::COMMENTS_NOVALID_ESCAPE: - return reader.Parse<rapidjson::kParseCommentsFlag | rapidjson::kParseEscapedApostropheFlag>(is, handler); - case ReaderConfigToRapidJsonFlags::NOCOMMENTS_VALID_NOESCAPE: - return reader.Parse<rapidjson::kParseValidateEncodingFlag>(is, handler); - case ReaderConfigToRapidJsonFlags::NOCOMMENTS_VALID_ESCAPE: - return reader.Parse<rapidjson::kParseValidateEncodingFlag | rapidjson::kParseEscapedApostropheFlag>(is, handler); - case ReaderConfigToRapidJsonFlags::NOCOMMENTS_NOVALID_ESCAPE: - return reader.Parse<rapidjson::kParseEscapedApostropheFlag>(is, handler); - default: + case ReaderConfigToRapidJsonFlags::COMMENTS_VALID_ESCAPE: + return reader.Parse<rapidjson::kParseCommentsFlag | rapidjson::kParseValidateEncodingFlag | rapidjson::kParseEscapedApostropheFlag>(is, handler); + case ReaderConfigToRapidJsonFlags::COMMENTS_NOVALID_ESCAPE: + return reader.Parse<rapidjson::kParseCommentsFlag | rapidjson::kParseEscapedApostropheFlag>(is, handler); + case ReaderConfigToRapidJsonFlags::NOCOMMENTS_VALID_NOESCAPE: + return reader.Parse<rapidjson::kParseValidateEncodingFlag>(is, handler); + case ReaderConfigToRapidJsonFlags::NOCOMMENTS_VALID_ESCAPE: + return reader.Parse<rapidjson::kParseValidateEncodingFlag | rapidjson::kParseEscapedApostropheFlag>(is, handler); + case ReaderConfigToRapidJsonFlags::NOCOMMENTS_NOVALID_ESCAPE: + return reader.Parse<rapidjson::kParseEscapedApostropheFlag>(is, handler); + default: return reader.Parse<rapidjson::kParseNoFlags>(is, handler); } } @@ -523,13 +523,13 @@ namespace NJson { return ReadJson(in, &config, cbs); } - bool ReadJson(IInputStream* in, bool allowComments, bool allowEscapedApostrophe, TJsonCallbacks* cbs) { - TJsonReaderConfig config; - config.AllowComments = allowComments; - config.AllowEscapedApostrophe = allowEscapedApostrophe; - return ReadJson(in, &config, cbs); - } - + bool ReadJson(IInputStream* in, bool allowComments, bool allowEscapedApostrophe, TJsonCallbacks* cbs) { + TJsonReaderConfig config; + config.AllowComments = allowComments; + config.AllowEscapedApostrophe = allowEscapedApostrophe; + return ReadJson(in, &config, cbs); + } + bool ReadJson(IInputStream* in, const TJsonReaderConfig* config, TJsonCallbacks* cbs) { TJsonCallbacksWrapper wrapper(*cbs); TInputStreamWrapper is(*in); diff --git a/library/cpp/json/json_reader.h b/library/cpp/json/json_reader.h index b673788330..c55e251a23 100644 --- a/library/cpp/json/json_reader.h +++ b/library/cpp/json/json_reader.h @@ -18,7 +18,7 @@ namespace NJson { // js-style comments (both // and /**/) bool AllowComments = false; bool DontValidateUtf8 = false; - bool AllowEscapedApostrophe = false; + bool AllowEscapedApostrophe = false; void SetBufferSize(size_t bufferSize); size_t GetBufferSize() const; @@ -41,25 +41,25 @@ namespace NJson { bool ReadJson(IInputStream* in, TJsonCallbacks* callbacks); bool ReadJson(IInputStream* in, bool allowComments, TJsonCallbacks* callbacks); - bool ReadJson(IInputStream* in, bool allowComments, bool allowEscapedApostrophe, TJsonCallbacks* callbacks); + bool ReadJson(IInputStream* in, bool allowComments, bool allowEscapedApostrophe, TJsonCallbacks* callbacks); bool ReadJson(IInputStream* in, const TJsonReaderConfig* config, TJsonCallbacks* callbacks); - enum ReaderConfigFlags { - COMMENTS = 0b100, - VALIDATE = 0b010, - ESCAPE = 0b001, - }; - - enum ReaderConfigToRapidJsonFlags { - COMMENTS_NOVALID_NOESCAPE = 0b100, - COMMENTS_VALID_NOESCAPE = 0b110, - COMMENTS_VALID_ESCAPE = 0b111, - COMMENTS_NOVALID_ESCAPE = 0b101, - NOCOMMENTS_VALID_NOESCAPE = 0b010, - NOCOMMENTS_VALID_ESCAPE = 0b011, - NOCOMMENTS_NOVALID_ESCAPE = 0b001, - }; - + enum ReaderConfigFlags { + COMMENTS = 0b100, + VALIDATE = 0b010, + ESCAPE = 0b001, + }; + + enum ReaderConfigToRapidJsonFlags { + COMMENTS_NOVALID_NOESCAPE = 0b100, + COMMENTS_VALID_NOESCAPE = 0b110, + COMMENTS_VALID_ESCAPE = 0b111, + COMMENTS_NOVALID_ESCAPE = 0b101, + NOCOMMENTS_VALID_NOESCAPE = 0b010, + NOCOMMENTS_VALID_ESCAPE = 0b011, + NOCOMMENTS_NOVALID_ESCAPE = 0b001, + }; + inline bool ValidateJson(IInputStream* in, const TJsonReaderConfig* config, bool throwOnError = false) { TJsonCallbacks c(throwOnError); return ReadJson(in, config, &c); diff --git a/library/cpp/json/ut/json_reader_ut.cpp b/library/cpp/json/ut/json_reader_ut.cpp index cd31afa0b8..f112e111e2 100644 --- a/library/cpp/json/ut/json_reader_ut.cpp +++ b/library/cpp/json/ut/json_reader_ut.cpp @@ -96,29 +96,29 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { UNIT_ASSERT_VALUES_EQUAL(result1, result2); } - Y_UNIT_TEST(TJsonEscapedApostrophe) { - TString jsonString = "{ \"foo\" : \"bar\\'buzz\" }"; - { - TStringStream in; - in << jsonString; - TStringStream out; - TJsonWriter writer(&out, false); - TReformatCallbacks cb(writer); - UNIT_ASSERT(!ReadJson(&in, &cb)); - } - - { - TStringStream in; - in << jsonString; - TStringStream out; - TJsonWriter writer(&out, false); - TReformatCallbacks cb(writer); - UNIT_ASSERT(ReadJson(&in, false, true, &cb)); - writer.Flush(); - UNIT_ASSERT_EQUAL(out.Str(), "[\"foo\",\"bar'buzz\"]"); - } - } - + Y_UNIT_TEST(TJsonEscapedApostrophe) { + TString jsonString = "{ \"foo\" : \"bar\\'buzz\" }"; + { + TStringStream in; + in << jsonString; + TStringStream out; + TJsonWriter writer(&out, false); + TReformatCallbacks cb(writer); + UNIT_ASSERT(!ReadJson(&in, &cb)); + } + + { + TStringStream in; + in << jsonString; + TStringStream out; + TJsonWriter writer(&out, false); + TReformatCallbacks cb(writer); + UNIT_ASSERT(ReadJson(&in, false, true, &cb)); + writer.Flush(); + UNIT_ASSERT_EQUAL(out.Str(), "[\"foo\",\"bar'buzz\"]"); + } + } + Y_UNIT_TEST(TJsonTreeTest) { TString data = "{\"intkey\": 10, \"double key\": 11.11, \"null value\":null, \"string key\": \"string\", \"array\": [1,2,3,\"TString\"], \"bool key\": true}"; TStringStream in; diff --git a/util/datetime/base.cpp b/util/datetime/base.cpp index 38ecc3ab96..21489991b3 100644 --- a/util/datetime/base.cpp +++ b/util/datetime/base.cpp @@ -181,10 +181,10 @@ TString TInstant::ToString() const { return ::ToString(*this); } -TString TInstant::ToRfc822String() const { - return FormatGmTime("%a, %d %b %Y %H:%M:%S GMT"); -} - +TString TInstant::ToRfc822String() const { + return FormatGmTime("%a, %d %b %Y %H:%M:%S GMT"); +} + TString TInstant::ToStringUpToSeconds() const { char buf[64]; auto len = FormatDate8601(buf, sizeof(buf), TimeT()); @@ -202,10 +202,10 @@ TString TInstant::ToStringLocal() const { return ::ToString(FormatLocal(*this)); } -TString TInstant::ToRfc822StringLocal() const { - return FormatLocalTime("%a, %d %b %Y %H:%M:%S %Z"); -} - +TString TInstant::ToRfc822StringLocal() const { + return FormatLocalTime("%a, %d %b %Y %H:%M:%S %Z"); +} + TString TInstant::ToIsoStringLocalUpToSeconds() const { return ::ToString(FormatIsoLocalUpToSeconds(*this)); } diff --git a/util/datetime/base.h b/util/datetime/base.h index 5e902b8f63..767db27643 100644 --- a/util/datetime/base.h +++ b/util/datetime/base.h @@ -452,13 +452,13 @@ public: TString ToString() const; /** - * Formats the instant using the UTC time zone. - * - * @returns An RFC822 formatted string, e.g. 'Sun, 06 Nov 1994 08:49:37 GMT'. - */ - TString ToRfc822String() const; - - /** + * Formats the instant using the UTC time zone. + * + * @returns An RFC822 formatted string, e.g. 'Sun, 06 Nov 1994 08:49:37 GMT'. + */ + TString ToRfc822String() const; + + /** * Formats the instant using the UTC time zone, with second precision. * * @returns An ISO 8601 formatted string, e.g. '2015-11-21T23:30:27Z'. @@ -482,13 +482,13 @@ public: TString ToStringLocal() const; /** - * Formats the instant using the system time zone. - * - * @returns An RFC822 formatted string, e.g. 'Sun, 06 Nov 1994 08:49:37 MSK'. - */ - TString ToRfc822StringLocal() const; - - /** + * Formats the instant using the system time zone. + * + * @returns An RFC822 formatted string, e.g. 'Sun, 06 Nov 1994 08:49:37 MSK'. + */ + TString ToRfc822StringLocal() const; + + /** * Formats the instant using the system time zone, with second precision. * * @returns An ISO 8601 / RFC 3339 formatted string, diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp index afc3f802eb..34bab1ff00 100644 --- a/util/datetime/base_ut.cpp +++ b/util/datetime/base_ut.cpp @@ -416,10 +416,10 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06Z"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToStringUpToSeconds()); } - Y_UNIT_TEST(TestInstantToRfc822String) { - UNIT_ASSERT_VALUES_EQUAL(TString("Thu, 06 Aug 2009 15:19:06 GMT"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToRfc822String()); - } - + Y_UNIT_TEST(TestInstantToRfc822String) { + UNIT_ASSERT_VALUES_EQUAL(TString("Thu, 06 Aug 2009 15:19:06 GMT"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToRfc822String()); + } + Y_UNIT_TEST(TestInstantMath) { UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1719), TInstant::Seconds(1700) + TDuration::Seconds(19)); // overflow diff --git a/util/network/socket.cpp b/util/network/socket.cpp index 4f6e804346..619b555e4a 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -5,7 +5,7 @@ #include "iovec.h" #include <util/system/defaults.h> -#include <util/system/byteorder.h> +#include <util/system/byteorder.h> #if defined(_unix_) #include <netdb.h> @@ -957,13 +957,13 @@ namespace { } inline bool IsLocalName(const char* name) const noexcept { - struct sockaddr_in sa; - memset(&sa, 0, sizeof(sa)); - + struct sockaddr_in sa; + memset(&sa, 0, sizeof(sa)); + if (inet_pton(AF_INET, name, &(sa.sin_addr)) == 1) { - return (InetToHost(sa.sin_addr.s_addr) >> 24) == 127; - } - + return (InetToHost(sa.sin_addr.s_addr) >> 24) == 127; + } + return contains(name); } }; diff --git a/util/system/fstat.cpp b/util/system/fstat.cpp index 81e98cbc6b..5ee7930a90 100644 --- a/util/system/fstat.cpp +++ b/util/system/fstat.cpp @@ -55,7 +55,7 @@ static void MakeStat(TFileStat& st, const TSystemFStat& fs) { st.ATime = fs.st_atime; st.MTime = fs.st_mtime; st.CTime = fs.st_ctime; - st.INode = fs.st_ino; + st.INode = fs.st_ino; #else timeval tv; FileTimeToTimeval(&fs.ftCreationTime, &tv); @@ -70,7 +70,7 @@ static void MakeStat(TFileStat& st, const TSystemFStat& fs) { st.Gid = 0; st.Size = ((ui64)fs.nFileSizeHigh << 32) | fs.nFileSizeLow; st.AllocationSize = st.Size; // FIXME - st.INode = ((ui64)fs.nFileIndexHigh << 32) | fs.nFileIndexLow; + st.INode = ((ui64)fs.nFileIndexHigh << 32) | fs.nFileIndexLow; #endif } diff --git a/util/system/fstat_ut.cpp b/util/system/fstat_ut.cpp index 160ecd936e..9502d11c7d 100644 --- a/util/system/fstat_ut.cpp +++ b/util/system/fstat_ut.cpp @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TestFileStat) { UNIT_ASSERT_VALUES_EQUAL(cFs.Mode, oFs.Mode); UNIT_ASSERT_VALUES_EQUAL(cFs.Uid, oFs.Uid); UNIT_ASSERT_VALUES_EQUAL(cFs.Gid, oFs.Gid); - UNIT_ASSERT_VALUES_EQUAL(cFs.INode, oFs.INode); + UNIT_ASSERT_VALUES_EQUAL(cFs.INode, oFs.INode); UNIT_ASSERT(unlink(fileName.data()) == 0); } |