diff options
author | Mikhail Borisov <[email protected]> | 2022-02-10 16:45:40 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:40 +0300 |
commit | 5d50718e66d9c037dc587a0211110b7d25a66185 (patch) | |
tree | e98df59de24d2ef7c77baed9f41e4875a2fef972 /library/cpp/yson_pull/detail/cescape_encode.h | |
parent | a6a92afe03e02795227d2641b49819b687f088f8 (diff) |
Restoring authorship annotation for Mikhail Borisov <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yson_pull/detail/cescape_encode.h')
-rw-r--r-- | library/cpp/yson_pull/detail/cescape_encode.h | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/library/cpp/yson_pull/detail/cescape_encode.h b/library/cpp/yson_pull/detail/cescape_encode.h index bf9a44ba5fb..bf5765f1d94 100644 --- a/library/cpp/yson_pull/detail/cescape_encode.h +++ b/library/cpp/yson_pull/detail/cescape_encode.h @@ -1,11 +1,11 @@ -#pragma once - +#pragma once + #include <util/system/types.h> - -// Whether to ensure strict ASCII compatibility -// Turns UTF-8 strings into unreadable garbage for no known reason -//#define CESCAPE_STRICT_ASCII - + +// Whether to ensure strict ASCII compatibility +// Turns UTF-8 strings into unreadable garbage for no known reason +//#define CESCAPE_STRICT_ASCII + namespace NYsonPull { namespace NDetail { namespace NCEscape { @@ -14,29 +14,29 @@ namespace NYsonPull { constexpr ui8 hex_digits[] = "0123456789ABCDEF"; return hex_digits[value]; } - + inline ui8 oct_digit(ui8 value) { return '0' + value; } - + inline bool is_printable(ui8 c) { -#ifdef CESCAPE_STRICT_ASCII +#ifdef CESCAPE_STRICT_ASCII return c >= 32 && c <= 126; -#else +#else return c >= 32; -#endif +#endif } - + inline bool is_hex_digit(ui8 c) { return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); } - + inline bool is_oct_digit(ui8 c) { return c >= '0' && c <= '7'; } - + constexpr size_t ESCAPE_C_BUFFER_SIZE = 4; - + inline size_t escape_char( ui8 c, ui8 next, @@ -85,16 +85,16 @@ namespace NYsonPull { return 4; } } - + template <typename T> inline void escape_impl(const ui8* str, size_t len, T&& consume) { ui8 buffer[ESCAPE_C_BUFFER_SIZE]; - + size_t i, j; for (i = 0, j = 0; i < len; ++i) { auto next_char = i + 1 < len ? str[i + 1] : 0; size_t rlen = escape_char(str[i], next_char, buffer); - + if (rlen > 1) { consume(str + j, i - j); j = i + 1; |