diff options
author | agalakhov <agalakhov@yandex-team.ru> | 2022-02-10 16:49:51 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:51 +0300 |
commit | 61a83e458f803c69f5d9d74e5d716cb95b3f2225 (patch) | |
tree | c63ac6b8d61f5c83d025f4b0863f3a2235c6fa39 /util | |
parent | 9622b1b611a91d945eb942671e7ad62d44878b66 (diff) | |
download | ydb-61a83e458f803c69f5d9d74e5d716cb95b3f2225.tar.gz |
Restoring authorship annotation for <agalakhov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r-- | util/datetime/base.h | 8 | ||||
-rw-r--r-- | util/datetime/parser.h | 36 | ||||
-rw-r--r-- | util/datetime/parser.rl6 | 12 | ||||
-rw-r--r-- | util/datetime/parser_ut.cpp | 44 | ||||
-rw-r--r-- | util/generic/strfcpy.h | 22 | ||||
-rw-r--r-- | util/network/pollerimpl.h | 12 |
6 files changed, 67 insertions, 67 deletions
diff --git a/util/datetime/base.h b/util/datetime/base.h index 5e902b8f63..5f66e6bc7f 100644 --- a/util/datetime/base.h +++ b/util/datetime/base.h @@ -69,10 +69,10 @@ bool ParseHTTPDateTimeDeprecated(const char* date, size_t dateLen, time_t& utcTi bool ParseX509ValidityDateTimeDeprecated(const char* date, time_t& utcTime); bool ParseX509ValidityDateTimeDeprecated(const char* date, size_t dateLen, time_t& utcTime); -bool ParseISO8601DateTime(const char* date, time_t& utcTime); -bool ParseISO8601DateTime(const char* date, size_t dateLen, time_t& utcTime); -bool ParseRFC822DateTime(const char* date, time_t& utcTime); -bool ParseRFC822DateTime(const char* date, size_t dateLen, time_t& utcTime); +bool ParseISO8601DateTime(const char* date, time_t& utcTime); +bool ParseISO8601DateTime(const char* date, size_t dateLen, time_t& utcTime); +bool ParseRFC822DateTime(const char* date, time_t& utcTime); +bool ParseRFC822DateTime(const char* date, size_t dateLen, time_t& utcTime); bool ParseHTTPDateTime(const char* date, time_t& utcTime); bool ParseHTTPDateTime(const char* date, size_t dateLen, time_t& utcTime); bool ParseX509ValidityDateTime(const char* date, time_t& utcTime); diff --git a/util/datetime/parser.h b/util/datetime/parser.h index f0c1b4a0c7..3a8290084e 100644 --- a/util/datetime/parser.h +++ b/util/datetime/parser.h @@ -61,22 +61,22 @@ struct TDateTimeFields { if (MicroSecond > 999999) return false; - if (Year == 1970 && Month == 1 && Day == 1) { - if ((i64)(3600 * Hour + 60 * Minute + Second) < (60 * ZoneOffsetMinutes)) - return false; - } - + if (Year == 1970 && Month == 1 && Day == 1) { + if ((i64)(3600 * Hour + 60 * Minute + Second) < (60 * ZoneOffsetMinutes)) + return false; + } + return true; } - TInstant ToInstant(TInstant defaultValue) const { + TInstant ToInstant(TInstant defaultValue) const { time_t tt = ToTimeT(-1); if (tt == -1) return defaultValue; return TInstant::Seconds(tt) + TDuration::MicroSeconds(MicroSecond); } - time_t ToTimeT(time_t defaultValue) const { + time_t ToTimeT(time_t defaultValue) const { if (!IsOk()) return defaultValue; struct tm tm; @@ -107,28 +107,28 @@ protected: int I; int Dc; -protected: +protected: TDateTimeParserBase() - : DateTimeFields() - , cs(0) + : DateTimeFields() + , cs(0) , Sign(0) , I(0xDEADBEEF) // to guarantee unittest break if ragel code is incorrect - , Dc(0xDEADBEEF) + , Dc(0xDEADBEEF) { } - - inline TInstant GetResult(int firstFinalState, TInstant defaultValue) const { - if (cs < firstFinalState) - return defaultValue; - return DateTimeFields.ToInstant(defaultValue); - } + + inline TInstant GetResult(int firstFinalState, TInstant defaultValue) const { + if (cs < firstFinalState) + return defaultValue; + return DateTimeFields.ToInstant(defaultValue); + } }; #define DECLARE_PARSER(CLASS) \ struct CLASS: public TDateTimeParserBase { \ CLASS(); \ bool ParsePart(const char* input, size_t len); \ - TInstant GetResult(TInstant defaultValue) const; \ + TInstant GetResult(TInstant defaultValue) const; \ }; DECLARE_PARSER(TIso8601DateTimeParser) diff --git a/util/datetime/parser.rl6 b/util/datetime/parser.rl6 index 931f09eae1..7bb1f69cb5 100644 --- a/util/datetime/parser.rl6 +++ b/util/datetime/parser.rl6 @@ -659,10 +659,10 @@ bool ParseX509ValidityDateTimeDeprecated(const char* input, size_t inputLen, tim return true; } -bool ParseRFC822DateTime(const char* input, time_t& utcTime) { - return ParseRFC822DateTime(input, strlen(input), utcTime); -} - +bool ParseRFC822DateTime(const char* input, time_t& utcTime) { + return ParseRFC822DateTime(input, strlen(input), utcTime); +} + bool ParseISO8601DateTime(const char* input, time_t& utcTime) { return ParseISO8601DateTime(input, strlen(input), utcTime); } @@ -675,7 +675,7 @@ bool ParseX509ValidityDateTime(const char* input, time_t& utcTime) { return ParseX509ValidityDateTime(input, strlen(input), utcTime); } -bool ParseRFC822DateTime(const char* input, size_t inputLen, time_t& utcTime) { +bool ParseRFC822DateTime(const char* input, size_t inputLen, time_t& utcTime) { try { utcTime = ParseUnsafe<TRfc822DateTimeParser, TInstant>(input, inputLen).TimeT(); return true; @@ -684,7 +684,7 @@ bool ParseRFC822DateTime(const char* input, size_t inputLen, time_t& utcTime) { } } -bool ParseISO8601DateTime(const char* input, size_t inputLen, time_t& utcTime) { +bool ParseISO8601DateTime(const char* input, size_t inputLen, time_t& utcTime) { try { utcTime = ParseUnsafe<TIso8601DateTimeParser, TInstant>(input, inputLen).TimeT(); return true; diff --git a/util/datetime/parser_ut.cpp b/util/datetime/parser_ut.cpp index 61364af997..6e8193d9d0 100644 --- a/util/datetime/parser_ut.cpp +++ b/util/datetime/parser_ut.cpp @@ -170,20 +170,20 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { bool r = true; time_t t = 0; - t = 12345; + t = 12345; r = ParseRFC822DateTime("", t); - UNIT_ASSERT(!r); - UNIT_ASSERT_EQUAL(t, (time_t)12345); - - t = 223344; + UNIT_ASSERT(!r); + UNIT_ASSERT_EQUAL(t, (time_t)12345); + + t = 223344; r = ParseRFC822DateTime("Fri, some junk", t); - UNIT_ASSERT(!r); - UNIT_ASSERT_EQUAL(t, (time_t)223344); - - t = 54321; + UNIT_ASSERT(!r); + UNIT_ASSERT_EQUAL(t, (time_t)223344); + + t = 54321; r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 UTC", t); UNIT_ASSERT(!r); - UNIT_ASSERT_EQUAL(t, (time_t)54321); + UNIT_ASSERT_EQUAL(t, (time_t)54321); // TODO: check semantic validity of parsed date (30 Feb, 88:90 etc.). // The following tests MUST fail (they don't now) @@ -263,8 +263,8 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT(p.ParsePart(part2, strlen(part2))); UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1109954085), p.GetResult(TInstant::Max())); p = TRfc822DateTimeParser(); - const char* part3 = "Fri, 4 Mar 05 19:34:46 +0300"; - UNIT_ASSERT(p.ParsePart(part3, strlen(part3))); + const char* part3 = "Fri, 4 Mar 05 19:34:46 +0300"; + UNIT_ASSERT(p.ParsePart(part3, strlen(part3))); UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1109954086), p.GetResult(TInstant::Zero())); } @@ -276,8 +276,8 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT(p.ParsePart(part2, strlen(part2))); UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(637487057), p.GetResult(TInstant::Max())); p = TIso8601DateTimeParser(); - const char* part3 = "1990-03-15T15:16:18+0732"; - UNIT_ASSERT(p.ParsePart(part3, strlen(part3))); + const char* part3 = "1990-03-15T15:16:18+0732"; + UNIT_ASSERT(p.ParsePart(part3, strlen(part3))); UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(637487058), p.GetResult(TInstant::Zero())); } @@ -376,20 +376,20 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { bool ret; time_t t; - t = 12345; + t = 12345; ret = ParseISO8601DateTime("", t); - UNIT_ASSERT(!ret); - UNIT_ASSERT_EQUAL(t, (time_t)12345); - + UNIT_ASSERT(!ret); + UNIT_ASSERT_EQUAL(t, (time_t)12345); + // some bad dates - t = 54321; + t = 54321; ret = ParseISO8601DateTime("a990-01-15", t); UNIT_ASSERT(!ret); - UNIT_ASSERT_EQUAL(t, (time_t)54321); + UNIT_ASSERT_EQUAL(t, (time_t)54321); ret = ParseISO8601DateTime("1970-01-01T03:00:00+04:00", t); // this is 1969 GMT - UNIT_ASSERT(!ret); - + UNIT_ASSERT(!ret); + ret = ParseISO8601DateTime("1987-13-16", t); UNIT_ASSERT(!ret); diff --git a/util/generic/strfcpy.h b/util/generic/strfcpy.h index 8a95bc3df2..c71ea10898 100644 --- a/util/generic/strfcpy.h +++ b/util/generic/strfcpy.h @@ -1,17 +1,17 @@ #pragma once - -/* + +/* * strfcpy is a faster version of strlcpy(). * It returns void thus does not wastes time computing * (most likely, unneeded) strlen(str) - * + * * Comparison with other copying functions: - * strcpy() - buffer overflow ready - * strncpy() - wastes time filling exactly n bytes with 0 - * strlcpy() - wastes time searching for the length of src - * memcpy() - wastes time copying exactly n bytes even if the string is shorter - */ - -#include <stddef.h> - + * strcpy() - buffer overflow ready + * strncpy() - wastes time filling exactly n bytes with 0 + * strlcpy() - wastes time searching for the length of src + * memcpy() - wastes time copying exactly n bytes even if the string is shorter + */ + +#include <stddef.h> + void strfcpy(char* dst, const char* src, size_t n); diff --git a/util/network/pollerimpl.h b/util/network/pollerimpl.h index e8c7e40fba..b4d44fcc7b 100644 --- a/util/network/pollerimpl.h +++ b/util/network/pollerimpl.h @@ -190,15 +190,15 @@ private: #if defined(HAVE_EPOLL_POLLER) static inline int ContEpollWait(int epfd, struct epoll_event* events, int maxevents, int timeout) noexcept { - int ret; + int ret; - do { + do { ret = epoll_wait(epfd, events, maxevents, Min<int>(timeout, 35 * 60 * 1000)); - } while (ret == -1 && errno == EINTR); - - return ret; -} + } while (ret == -1 && errno == EINTR); + return ret; +} + template <class TLockPolicy> class TEpollPoller { public: |