diff options
author | kerzum <kerzum@yandex-team.ru> | 2022-02-10 16:49:33 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:33 +0300 |
commit | 47a7e7b29636bfb2deb1df5f92363b3c75229c95 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/string | |
parent | 9a7232babfd763ccfe827bc70e82e0f50cfd8276 (diff) | |
download | ydb-47a7e7b29636bfb2deb1df5f92363b3c75229c95.tar.gz |
Restoring authorship annotation for <kerzum@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/string')
-rw-r--r-- | util/string/escape.cpp | 20 | ||||
-rw-r--r-- | util/string/escape_ut.cpp | 8 | ||||
-rw-r--r-- | util/string/util.cpp | 2 |
3 files changed, 15 insertions, 15 deletions
diff --git a/util/string/escape.cpp b/util/string/escape.cpp index 3378a14a17..cd09a7dbd0 100644 --- a/util/string/escape.cpp +++ b/util/string/escape.cpp @@ -5,8 +5,8 @@ #include <util/charset/utf8.h> #include <util/charset/wide.h> -/// @todo: escape trigraphs (eg "??/" is "\") - +/// @todo: escape trigraphs (eg "??/" is "\") + /* REFEREBCES FOR ESCAPE SEQUENCE INTERPRETATION: * C99 p. 6.4.3 Universal character names. * C99 p. 6.4.4.4 Character constants. @@ -31,14 +31,14 @@ * - Hexadecimal escape sequence spans until rightmost non-hexadecimal-digit character. * - Universal character name consists of exactly 4 or 8 hexadecimal digit. * - * by kerzum@ - * It is also required to escape trigraphs that are enabled in compilers by default and - * are also processed inside string literals - * The nine trigraphs and their replacements are - * - * Trigraph: ??( ??) ??< ??> ??= ??/ ??' ??! ??- - * Replacement: [ ] { } # \ ^ | ~ - * + * by kerzum@ + * It is also required to escape trigraphs that are enabled in compilers by default and + * are also processed inside string literals + * The nine trigraphs and their replacements are + * + * Trigraph: ??( ??) ??< ??> ??= ??/ ??' ??! ??- + * Replacement: [ ] { } # \ ^ | ~ + * */ namespace { template <typename TChar> diff --git a/util/string/escape_ut.cpp b/util/string/escape_ut.cpp index 49fb122972..cd38ecffd3 100644 --- a/util/string/escape_ut.cpp +++ b/util/string/escape_ut.cpp @@ -41,7 +41,7 @@ static const TExample CommonTestData[] = { {"Slash\\\\dash!", "Slash\\dash!"}, {R"(There\nare\r\nnewlines.)", "There\nare\r\nnewlines."}, {"There\\tare\\ttabs.", "There\tare\ttabs."}, - + {"There are questions \\x3F\\x3F?", "There are questions ???"}, {"There are questions \\x3F?", "There are questions ??"}, }; @@ -94,15 +94,15 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) { UNIT_ASSERT_VALUES_EQUAL(u"h", EscapeC(u'h')); UNIT_ASSERT_VALUES_EQUAL(u"\\xFF", EscapeC(wchar16(255))); } - + Y_UNIT_TEST(TestEscapeTrigraphs) { UNIT_ASSERT_VALUES_EQUAL("?", EscapeC(TString("?"))); UNIT_ASSERT_VALUES_EQUAL("\\x3F?", EscapeC(TString("??"))); UNIT_ASSERT_VALUES_EQUAL("\\x3F\\x3F?", EscapeC(TString("???"))); - // ok but may cause warning about trigraphs + // ok but may cause warning about trigraphs // UNIT_ASSERT_VALUES_EQUAL("[x]?z", EscapeC(TString("??(x??)?z"))); UNIT_ASSERT_VALUES_EQUAL("\\x3F?x\\x3F\\x3F?z", EscapeC(TString("??x???z"))); - } + } Y_UNIT_TEST(TestUnescapeCCharLen) { auto test = [](const char* str, size_t len) { diff --git a/util/string/util.cpp b/util/string/util.cpp index 4e2cc82437..b14f20bf75 100644 --- a/util/string/util.cpp +++ b/util/string/util.cpp @@ -48,7 +48,7 @@ Tr::Tr(const char* from, const char* to) { Map[(ui8)*from] = *to; } } - + size_t Tr::FindFirstChangePosition(const TString& str) const { for (auto it = str.begin(); it != str.end(); ++it) { if (ConvertChar(*it) != *it) { |