aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasavin <asavin@yandex-team.ru>2022-02-10 16:49:56 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:56 +0300
commit0cbe97538e6c240dfb7424ac5c2173cd6a489734 (patch)
treebeb11b35e2fe1b919a7a1d6c4e4277790533c0b0
parent1cefd0c80e17cf625858624e103f07eb08f7b1b2 (diff)
downloadydb-0cbe97538e6c240dfb7424ac5c2173cd6a489734.tar.gz
Restoring authorship annotation for <asavin@yandex-team.ru>. Commit 1 of 2.
-rw-r--r--library/cpp/string_utils/quote/quote.cpp68
-rw-r--r--library/cpp/string_utils/quote/quote_ut.cpp126
-rw-r--r--util/generic/strbuf_ut.cpp18
3 files changed, 106 insertions, 106 deletions
diff --git a/library/cpp/string_utils/quote/quote.cpp b/library/cpp/string_utils/quote/quote.cpp
index e523350b80..9f6d8d5c9d 100644
--- a/library/cpp/string_utils/quote/quote.cpp
+++ b/library/cpp/string_utils/quote/quote.cpp
@@ -22,18 +22,18 @@
} while (0)
-namespace {
- class TFromHexZeroTerm {
- public:
+namespace {
+ class TFromHexZeroTerm {
+ public:
static inline char x2c(const char*& x) {
if (!IsAsciiHex((ui8)x[0]) || !IsAsciiHex((ui8)x[1]))
- return '%';
- ui8 c = 0;
+ return '%';
+ ui8 c = 0;
GETXC;
GETXC;
- return c;
- }
+ return c;
+ }
static inline char x2c(TStringBuf& x) {
if (!IsAsciiHex((ui8)x[0]) || !IsAsciiHex((ui8)x[1]))
@@ -44,24 +44,24 @@ namespace {
GETSBXC;
return c;
}
- };
-
- class TFromHexLenLimited {
- public:
- TFromHexLenLimited(const char* end)
- : End(end)
- {
- }
-
+ };
+
+ class TFromHexLenLimited {
+ public:
+ TFromHexLenLimited(const char* end)
+ : End(end)
+ {
+ }
+
inline char x2c(const char*& x) {
- if (x + 2 > End)
- return '%';
- return TFromHexZeroTerm::x2c(x);
- }
-
- private:
- const char* End;
- };
+ if (x + 2 > End)
+ return '%';
+ return TFromHexZeroTerm::x2c(x);
+ }
+
+ private:
+ const char* End;
+ };
}
static inline char d2x(unsigned x) {
@@ -122,12 +122,12 @@ static inline It1 Escape(It1 to, It2 from, It3 end, const bool* escape_map = cha
return to;
}
-template <class It1, class It2, class It3, class FromHex>
+template <class It1, class It2, class It3, class FromHex>
static inline It1 Unescape(It1 to, It2 from, It3 end, FromHex fromHex) {
(void)fromHex;
- while (from != end) {
- switch (*from) {
+ while (from != end) {
+ switch (*from) {
case '%':
++from;
*to++ = fromHex.x2c(from);
@@ -138,12 +138,12 @@ static inline It1 Unescape(It1 to, It2 from, It3 end, FromHex fromHex) {
break;
default:
*to++ = *from++;
- }
- }
- *to = 0;
- return to;
-}
-
+ }
+ }
+ *to = 0;
+ return to;
+}
+
// CGIEscape returns pointer to the end of the result string
// so as it could be possible to populate single long buffer
// with several calls to CGIEscape in a row.
@@ -216,7 +216,7 @@ void Quote(TString& url, const char* safe) {
char* CGIUnescape(char* to, const char* from) {
return Unescape(to, FixZero(from), TCStringEndIterator(), TFromHexZeroTerm());
-}
+}
char* CGIUnescape(char* to, const char* from, size_t len) {
return Unescape(to, from, from + len, TFromHexLenLimited(from + len));
diff --git a/library/cpp/string_utils/quote/quote_ut.cpp b/library/cpp/string_utils/quote/quote_ut.cpp
index 6c552b279e..829bdfd166 100644
--- a/library/cpp/string_utils/quote/quote_ut.cpp
+++ b/library/cpp/string_utils/quote/quote_ut.cpp
@@ -55,74 +55,74 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) {
}
Y_UNIT_TEST(TestValidZeroTerm) {
- char r[10];
-
- CGIUnescape(r, "1234");
- UNIT_ASSERT_VALUES_EQUAL(r, "1234");
-
- CGIUnescape(r, "%3d");
- UNIT_ASSERT_VALUES_EQUAL(r, "=");
-
- CGIUnescape(r, "12%3D34");
- UNIT_ASSERT_VALUES_EQUAL(r, "12=34");
- }
-
+ char r[10];
+
+ CGIUnescape(r, "1234");
+ UNIT_ASSERT_VALUES_EQUAL(r, "1234");
+
+ CGIUnescape(r, "%3d");
+ UNIT_ASSERT_VALUES_EQUAL(r, "=");
+
+ CGIUnescape(r, "12%3D34");
+ UNIT_ASSERT_VALUES_EQUAL(r, "12=34");
+ }
+
Y_UNIT_TEST(TestInvalidZeroTerm) {
- char r[10];
-
- CGIUnescape(r, "%");
- UNIT_ASSERT_VALUES_EQUAL(r, "%");
-
- CGIUnescape(r, "%3");
- UNIT_ASSERT_VALUES_EQUAL(r, "%3");
-
- CGIUnescape(r, "%3g");
- UNIT_ASSERT_VALUES_EQUAL(r, "%3g");
-
- CGIUnescape(r, "12%3g34");
- UNIT_ASSERT_VALUES_EQUAL(r, "12%3g34");
-
+ char r[10];
+
+ CGIUnescape(r, "%");
+ UNIT_ASSERT_VALUES_EQUAL(r, "%");
+
+ CGIUnescape(r, "%3");
+ UNIT_ASSERT_VALUES_EQUAL(r, "%3");
+
+ CGIUnescape(r, "%3g");
+ UNIT_ASSERT_VALUES_EQUAL(r, "%3g");
+
+ CGIUnescape(r, "12%3g34");
+ UNIT_ASSERT_VALUES_EQUAL(r, "12%3g34");
+
CGIUnescape(r, "%3u123");
- UNIT_ASSERT_VALUES_EQUAL(r, "%3u123");
- }
-
+ UNIT_ASSERT_VALUES_EQUAL(r, "%3u123");
+ }
+
Y_UNIT_TEST(TestValidNotZeroTerm) {
- char r[10];
-
- CGIUnescape(r, "123456789", 4);
- UNIT_ASSERT_VALUES_EQUAL(r, "1234");
-
- CGIUnescape(r, "%3d1234", 3);
- UNIT_ASSERT_VALUES_EQUAL(r, "=");
-
- CGIUnescape(r, "12%3D345678", 7);
- UNIT_ASSERT_VALUES_EQUAL(r, "12=34");
- }
-
+ char r[10];
+
+ CGIUnescape(r, "123456789", 4);
+ UNIT_ASSERT_VALUES_EQUAL(r, "1234");
+
+ CGIUnescape(r, "%3d1234", 3);
+ UNIT_ASSERT_VALUES_EQUAL(r, "=");
+
+ CGIUnescape(r, "12%3D345678", 7);
+ UNIT_ASSERT_VALUES_EQUAL(r, "12=34");
+ }
+
Y_UNIT_TEST(TestInvalidNotZeroTerm) {
- char r[10];
-
- CGIUnescape(r, "%3d", 1);
- UNIT_ASSERT_VALUES_EQUAL(r, "%");
-
- CGIUnescape(r, "%3d", 2);
- UNIT_ASSERT_VALUES_EQUAL(r, "%3");
-
- CGIUnescape(r, "%3g1234", 3);
- UNIT_ASSERT_VALUES_EQUAL(r, "%3g");
-
- CGIUnescape(r, "12%3g345678", 7);
- UNIT_ASSERT_VALUES_EQUAL(r, "12%3g34");
-
+ char r[10];
+
+ CGIUnescape(r, "%3d", 1);
+ UNIT_ASSERT_VALUES_EQUAL(r, "%");
+
+ CGIUnescape(r, "%3d", 2);
+ UNIT_ASSERT_VALUES_EQUAL(r, "%3");
+
+ CGIUnescape(r, "%3g1234", 3);
+ UNIT_ASSERT_VALUES_EQUAL(r, "%3g");
+
+ CGIUnescape(r, "12%3g345678", 7);
+ UNIT_ASSERT_VALUES_EQUAL(r, "12%3g34");
+
CGIUnescape(r, "%3u1234", 2);
- UNIT_ASSERT_VALUES_EQUAL(r, "%3");
-
+ UNIT_ASSERT_VALUES_EQUAL(r, "%3");
+
CGIUnescape(r, "%3u1234", 3);
- UNIT_ASSERT_VALUES_EQUAL(r, "%3u");
-
+ UNIT_ASSERT_VALUES_EQUAL(r, "%3u");
+
CGIUnescape(r, "%3u1234", 4);
- UNIT_ASSERT_VALUES_EQUAL(r, "%3u1");
- }
+ UNIT_ASSERT_VALUES_EQUAL(r, "%3u1");
+ }
Y_UNIT_TEST(StrokaOutParameterInplace) {
TString s;
@@ -176,8 +176,8 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) {
CGIUnescape(s);
UNIT_ASSERT_VALUES_EQUAL(s, "");
}
-}
-
+}
+
Y_UNIT_TEST_SUITE(TUrlEscapeTest) {
Y_UNIT_TEST(EscapeEscaped) {
TString s;
diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp
index 69cde785af..512acafaa1 100644
--- a/util/generic/strbuf_ut.cpp
+++ b/util/generic/strbuf_ut.cpp
@@ -227,18 +227,18 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(buf1.rfind('3'), 5);
UNIT_ASSERT_EQUAL(buf1.rfind('4'), 6);
UNIT_ASSERT_EQUAL(buf1.rfind('7'), TStringBuf::npos);
-
- TStringBuf buf2;
+
+ TStringBuf buf2;
UNIT_ASSERT_EQUAL(buf2.rfind('3'), TStringBuf::npos);
-
- TStringBuf buf3 = TStringBuf("123123456", 6);
- UNIT_ASSERT_EQUAL(buf3.rfind('3'), 5);
+
+ TStringBuf buf3 = TStringBuf("123123456", 6);
+ UNIT_ASSERT_EQUAL(buf3.rfind('3'), 5);
UNIT_ASSERT_EQUAL(buf3.rfind('4'), TStringBuf::npos);
UNIT_ASSERT_EQUAL(buf3.rfind('7'), TStringBuf::npos);
-
- TStringBuf buf4 = TStringBuf("123123456", 5);
- UNIT_ASSERT_EQUAL(buf4.rfind('3'), 2);
- }
+
+ TStringBuf buf4 = TStringBuf("123123456", 5);
+ UNIT_ASSERT_EQUAL(buf4.rfind('3'), 2);
+ }
Y_UNIT_TEST(TestRNextTok) {
TStringBuf buf1("a.b.c");