diff options
author | f0b0s <f0b0s@yandex-team.ru> | 2022-02-10 16:46:51 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:51 +0300 |
commit | cdae02d225fb5b3afbb28990e79a7ac6c9125327 (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /util/generic/guid.cpp | |
parent | deabc5260ac2e17b8f5152ee060bec1740613540 (diff) | |
download | ydb-cdae02d225fb5b3afbb28990e79a7ac6c9125327.tar.gz |
Restoring authorship annotation for <f0b0s@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic/guid.cpp')
-rw-r--r-- | util/generic/guid.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/util/generic/guid.cpp b/util/generic/guid.cpp index 39feb5b3e1..8b907457bc 100644 --- a/util/generic/guid.cpp +++ b/util/generic/guid.cpp @@ -88,42 +88,42 @@ static bool GetDigit(const char c, ui32& digit) { } bool GetGuid(const TStringBuf s, TGUID& result) { - size_t partId = 0; - ui64 partValue = 0; - bool isEmptyPart = true; - - for (size_t i = 0; i != s.size(); ++i) { - const char c = s[i]; - - if (c == '-') { + size_t partId = 0; + ui64 partValue = 0; + bool isEmptyPart = true; + + for (size_t i = 0; i != s.size(); ++i) { + const char c = s[i]; + + if (c == '-') { if (isEmptyPart || partId == 3) { // x-y--z, -x-y-z or x-y-z-m-... return false; - } - result.dw[partId] = static_cast<ui32>(partValue); - ++partId; - partValue = 0; - isEmptyPart = true; - continue; - } - - ui32 digit = 0; + } + result.dw[partId] = static_cast<ui32>(partValue); + ++partId; + partValue = 0; + isEmptyPart = true; + continue; + } + + ui32 digit = 0; if (!GetDigit(c, digit)) { return false; - } - - partValue = partValue * 16 + digit; - isEmptyPart = false; - - // overflow check + } + + partValue = partValue * 16 + digit; + isEmptyPart = false; + + // overflow check if (partValue > Max<ui32>()) { return false; - } - } - + } + } + if (partId != 3 || isEmptyPart) { // x-y or x-y-z- return false; - } - result.dw[partId] = static_cast<ui32>(partValue); + } + result.dw[partId] = static_cast<ui32>(partValue); return true; } |