diff options
author | antonovvk <antonovvk@yandex-team.ru> | 2022-02-10 16:47:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:52 +0300 |
commit | 37de222addabbef336dcaaea5f7c7645a629fc6d (patch) | |
tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp/uri | |
parent | 37a63debdc21e372d99e1808cdd31aecf75018c3 (diff) | |
download | ydb-37de222addabbef336dcaaea5f7c7645a629fc6d.tar.gz |
Restoring authorship annotation for <antonovvk@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/uri')
-rw-r--r-- | library/cpp/uri/common.h | 10 | ||||
-rw-r--r-- | library/cpp/uri/other.cpp | 84 | ||||
-rw-r--r-- | library/cpp/uri/other.h | 28 | ||||
-rw-r--r-- | library/cpp/uri/uri_ut.cpp | 2 |
4 files changed, 62 insertions, 62 deletions
diff --git a/library/cpp/uri/common.h b/library/cpp/uri/common.h index feb9bf6148..8025357763 100644 --- a/library/cpp/uri/common.h +++ b/library/cpp/uri/common.h @@ -492,15 +492,15 @@ namespace NUri { Y_DECLARE_OUT_SPEC(inline, NUri::TField::EField, out, t) { out << NUri::FieldToString(t); -} - +} + Y_DECLARE_OUT_SPEC(inline, NUri::TScheme::EKind, out, t) { out << NUri::SchemeKindToString(t); -} - +} + Y_DECLARE_OUT_SPEC(inline, NUri::TState::EParsed, out, t) { out << NUri::ParsedStateToString(t); -} +} static inline ui16 DefaultPort(NUri::TScheme::EKind scheme) { return NUri::TSchemeInfo::GetDefaultPort(scheme); diff --git a/library/cpp/uri/other.cpp b/library/cpp/uri/other.cpp index 5f1ff30b25..b23a5b68a9 100644 --- a/library/cpp/uri/other.cpp +++ b/library/cpp/uri/other.cpp @@ -6,34 +6,34 @@ /********************************************************/ /********************************************************/ -static const Tr InvertTr(".:/?#", "\005\004\003\002\001"); -static const Tr RevertTr("\005\004\003\002\001", ".:/?#"); - +static const Tr InvertTr(".:/?#", "\005\004\003\002\001"); +static const Tr RevertTr("\005\004\003\002\001", ".:/?#"); + void TrspChars(char* s) { - InvertTr.Do(s); -} - + InvertTr.Do(s); +} + void UnTrspChars(char* s) { - RevertTr.Do(s); -} - + RevertTr.Do(s); +} + void TrspChars(char* s, size_t l) { - InvertTr.Do(s, l); -} - + InvertTr.Do(s, l); +} + void UnTrspChars(char* s, size_t l) { - RevertTr.Do(s, l); -} - + RevertTr.Do(s, l); +} + void TrspChars(const char* s, char* d) { - InvertTr.Do(s, d); -} - + InvertTr.Do(s, d); +} + void UnTrspChars(const char* s, char* d) { - RevertTr.Do(s, d); -} - -void InvertDomain(char* begin, char* end) { + RevertTr.Do(s, d); +} + +void InvertDomain(char* begin, char* end) { // skip schema if it is present const auto dotPos = TStringBuf{begin, end}.find('.'); if (dotPos == TStringBuf::npos) @@ -41,27 +41,27 @@ void InvertDomain(char* begin, char* end) { const auto schemaendPos = TStringBuf{begin, end}.find("://", 3); if (schemaendPos < dotPos) begin += schemaendPos + 3; - char* sl = (char*)memchr(begin, '/', end - begin); - char* cl = (char*)memchr(begin, ':', sl ? sl - begin : end - begin); - end = cl ? cl : (sl ? sl : end); - - // invert string - for (size_t i = 0, n = end - begin; i < n / 2; ++i) - DoSwap(begin[i], begin[n - i - 1]); - - // invert back each host name segment - char* b = begin; - while (true) { - char* e = (char*)memchr(b, '.', end - b); - if (!e) - e = end; - for (size_t i = 0, n = e - b; i < n / 2; ++i) - DoSwap(b[i], b[n - i - 1]); + char* sl = (char*)memchr(begin, '/', end - begin); + char* cl = (char*)memchr(begin, ':', sl ? sl - begin : end - begin); + end = cl ? cl : (sl ? sl : end); + + // invert string + for (size_t i = 0, n = end - begin; i < n / 2; ++i) + DoSwap(begin[i], begin[n - i - 1]); + + // invert back each host name segment + char* b = begin; + while (true) { + char* e = (char*)memchr(b, '.', end - b); + if (!e) + e = end; + for (size_t i = 0, n = e - b; i < n / 2; ++i) + DoSwap(b[i], b[n - i - 1]); if (e == end) - break; - b = e + 1; - } -} + break; + b = e + 1; + } +} void InvertUrl(char* begin, char* end) { char* slash = strchr(begin, '/'); diff --git a/library/cpp/uri/other.h b/library/cpp/uri/other.h index e4fd48842a..7aec22e77b 100644 --- a/library/cpp/uri/other.h +++ b/library/cpp/uri/other.h @@ -2,23 +2,23 @@ #include <util/generic/string.h> -// Some functions for inverted url representation -// No scheme cut-off, no 80th port normalization - +// Some functions for inverted url representation +// No scheme cut-off, no 80th port normalization + void TrspChars(char* s); void UnTrspChars(char* s); void TrspChars(char* s, size_t l); void UnTrspChars(char* s, size_t l); void TrspChars(const char* s, char* d); void UnTrspChars(const char* s, char* d); - -void InvertDomain(char* begin, char* end); - + +void InvertDomain(char* begin, char* end); + inline TString& InvertDomain(TString& url) { InvertDomain(url.begin(), url.begin() + url.size()); - return url; -} - + return url; +} + void InvertUrl(char* begin, char* end); inline void InvertUrl(char* url) { @@ -27,9 +27,9 @@ inline void InvertUrl(char* url) { inline TString& InvertUrl(TString& url) { InvertUrl(url.begin(), url.begin() + url.size()); - return url; -} - + return url; +} + void RevertUrl(char* begin, char* end); inline void RevertUrl(char* url) { @@ -38,5 +38,5 @@ inline void RevertUrl(char* url) { inline TString& RevertUrl(TString& url) { RevertUrl(url.begin(), url.begin() + url.size()); - return url; -} + return url; +} diff --git a/library/cpp/uri/uri_ut.cpp b/library/cpp/uri/uri_ut.cpp index 0885defd20..2ebd83fc93 100644 --- a/library/cpp/uri/uri_ut.cpp +++ b/library/cpp/uri/uri_ut.cpp @@ -941,7 +941,7 @@ namespace NUri { TString r; ProcessQargs(url, r); return r; - } + } bool QueryArgsFilter(const TQueryArg& arg, void* filterData) { const char* skipName = static_cast<const char*>(filterData); |