diff options
author | uht <uht@yandex-team.ru> | 2022-02-10 16:49:56 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:56 +0300 |
commit | 1191d1e479d83a18a813a5107573ce22a2f0bbb4 (patch) | |
tree | 6cbbb7e1c6309393dde43830532c7c7b633b1e4b | |
parent | fa977fb6c7b468a86cf33f948fdae8e0c83d3cad (diff) | |
download | ydb-1191d1e479d83a18a813a5107573ce22a2f0bbb4.tar.gz |
Restoring authorship annotation for <uht@yandex-team.ru>. Commit 1 of 2.
-rw-r--r-- | library/cpp/cgiparam/cgiparam_ut.cpp | 8 | ||||
-rw-r--r-- | library/cpp/charset/codepage.cpp | 10 | ||||
-rw-r--r-- | library/cpp/charset/codepage.h | 40 | ||||
-rw-r--r-- | library/cpp/charset/cp_encrec.cpp | 74 | ||||
-rw-r--r-- | library/cpp/charset/recyr.hh | 40 | ||||
-rw-r--r-- | library/cpp/charset/recyr_int.hh | 54 | ||||
-rw-r--r-- | library/cpp/string_utils/quote/quote.cpp | 6 | ||||
-rw-r--r-- | util/charset/unidata.h | 2 | ||||
-rw-r--r-- | util/string/vector.h | 2 |
9 files changed, 118 insertions, 118 deletions
diff --git a/library/cpp/cgiparam/cgiparam_ut.cpp b/library/cpp/cgiparam/cgiparam_ut.cpp index a562342084..4a516d0710 100644 --- a/library/cpp/cgiparam/cgiparam_ut.cpp +++ b/library/cpp/cgiparam/cgiparam_ut.cpp @@ -186,10 +186,10 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { } Y_UNIT_TEST(TestUnscape) { - TCgiParameters c("f=1&t=%84R%84%7C%84%80%84%7E&reqenc=SHIFT_JIS&p=0"); - UNIT_ASSERT_VALUES_EQUAL(c.Get("t"), "\x84R\x84\x7C\x84\x80\x84\x7E"); - } - + TCgiParameters c("f=1&t=%84R%84%7C%84%80%84%7E&reqenc=SHIFT_JIS&p=0"); + UNIT_ASSERT_VALUES_EQUAL(c.Get("t"), "\x84R\x84\x7C\x84\x80\x84\x7E"); + } + Y_UNIT_TEST(TestEmpty) { UNIT_ASSERT(TCgiParameters().Print().empty()); } diff --git a/library/cpp/charset/codepage.cpp b/library/cpp/charset/codepage.cpp index 0431bef31b..6f8825c935 100644 --- a/library/cpp/charset/codepage.cpp +++ b/library/cpp/charset/codepage.cpp @@ -24,13 +24,13 @@ using namespace NCodepagePrivate; void Recoder::Create(const CodePage& source, const CodePage& target) { const Encoder* wideTarget = &EncoderByCharset(target.CPEnum); - Create(source, wideTarget); -} + Create(source, wideTarget); +} void Recoder::Create(const CodePage& page, wchar32 (*mapfunc)(wchar32)) { const Encoder* widePage = &EncoderByCharset(page.CPEnum); - Create(page, widePage, mapfunc); -} - + Create(page, widePage, mapfunc); +} + template <class T, class T1> static inline T1 Apply(T b, T e, T1 to, const Recoder& mapper) { while (b != e) { diff --git a/library/cpp/charset/codepage.h b/library/cpp/charset/codepage.h index 30a02a4610..273a5e1a5d 100644 --- a/library/cpp/charset/codepage.h +++ b/library/cpp/charset/codepage.h @@ -17,9 +17,9 @@ struct CodePage; struct Recoder; struct Encoder; -/*****************************************************************\ -* struct CodePage * -\*****************************************************************/ +/*****************************************************************\ +* struct CodePage * +\*****************************************************************/ struct CodePage { ECharset CPEnum; // int MIBEnum; const char* Names[30]; // name[0] -- preferred mime-name @@ -186,26 +186,26 @@ inline const CodePage* CodePageByName(const char* name) { } ECharset EncodingHintByName(const char* name); - -/*****************************************************************\ -* struct Encoder * -\*****************************************************************/ + +/*****************************************************************\ +* struct Encoder * +\*****************************************************************/ struct Encoder { char* Table[256]; const char* DefaultChar; inline char Code(wchar32 ch) const { - if (ch > 0xFFFF) - return 0; + if (ch > 0xFFFF) + return 0; return (unsigned char)Table[(ch >> 8) & 255][ch & 255]; } inline char Tr(wchar32 ch) const { - char code = Code(ch); - if (code == 0 && ch != 0) + char code = Code(ch); + if (code == 0 && ch != 0) code = DefaultChar[NUnicode::CharType(ch)]; Y_ASSERT(code != 0 || ch == 0); - return code; + return code; } inline unsigned char operator[](wchar32 ch) const { @@ -217,18 +217,18 @@ struct Encoder { char* DefaultPlane; }; -/*****************************************************************\ -* struct Recoder * -\*****************************************************************/ +/*****************************************************************\ +* struct Recoder * +\*****************************************************************/ struct Recoder { - unsigned char Table[257]; + unsigned char Table[257]; void Create(const CodePage& source, const CodePage& target); void Create(const CodePage& source, const Encoder* wideTarget); void Create(const CodePage& page, wchar32 (*mapper)(wchar32)); void Create(const CodePage& page, const Encoder* widePage, wchar32 (*mapper)(wchar32)); - + inline unsigned char Tr(unsigned char c) const { return Table[c]; } @@ -242,9 +242,9 @@ struct Recoder { }; extern const struct Encoder& WideCharToYandex; - + const Encoder& EncoderByCharset(ECharset enc); - + namespace NCodepagePrivate { class TCodePageData { private: @@ -265,7 +265,7 @@ namespace NCodepagePrivate { friend const Encoder& ::EncoderByCharset(ECharset enc); }; } - + inline const Encoder& EncoderByCharset(ECharset enc) { if (!SingleByteCodepage(enc)) { ythrow yexception() << "Encoder structure can only be used for single byte encodings"; diff --git a/library/cpp/charset/cp_encrec.cpp b/library/cpp/charset/cp_encrec.cpp index e4570cd628..33f46722a4 100644 --- a/library/cpp/charset/cp_encrec.cpp +++ b/library/cpp/charset/cp_encrec.cpp @@ -4,50 +4,50 @@ void Encoder::Tr(const wchar32* in, char* out, size_t len) const { while (len--) - *out++ = Tr(*in++); -} - + *out++ = Tr(*in++); +} + void Encoder::Tr(const wchar32* in, char* out) const { - do { - *out++ = Tr(*in); - } while (*in++); -} - + do { + *out++ = Tr(*in); + } while (*in++); +} + void Recoder::Create(const CodePage& source, const Encoder* wideTarget) { for (size_t i = 0; i != 256; ++i) { - Table[i] = wideTarget->Tr(source.unicode[i]); + Table[i] = wideTarget->Tr(source.unicode[i]); Y_ASSERT(Table[i] != 0 || i == 0); - } -} - + } +} + void Recoder::Create(const CodePage& page, const Encoder* widePage, wchar32 (*mapfunc)(wchar32)) { for (size_t i = 0; i != 256; ++i) { - char c = widePage->Code((*mapfunc)(page.unicode[i])); - Table[i] = (c == 0 && i != 0) ? (unsigned char)i : (unsigned char)c; - } -} - + char c = widePage->Code((*mapfunc)(page.unicode[i])); + Table[i] = (c == 0 && i != 0) ? (unsigned char)i : (unsigned char)c; + } +} + void Recoder::Tr(const char* in, char* out, size_t len) const { - while (len--) - *out++ = Table[(unsigned char)*in++]; -} - + while (len--) + *out++ = Table[(unsigned char)*in++]; +} + void Recoder::Tr(const char* in, char* out) const { - do { - *out++ = Table[(unsigned char)*in]; - } while (*in++); -} - + do { + *out++ = Table[(unsigned char)*in]; + } while (*in++); +} + void Recoder::Tr(char* in_out, size_t len) const { - while (len--) { - *in_out = Table[(unsigned char)*in_out]; - in_out++; - } -} - + while (len--) { + *in_out = Table[(unsigned char)*in_out]; + in_out++; + } +} + void Recoder::Tr(char* in_out) const { - // assuming that '\0' <--> '\0' - do { - *in_out = Table[(unsigned char)*in_out]; - } while (*in_out++); -} + // assuming that '\0' <--> '\0' + do { + *in_out = Table[(unsigned char)*in_out]; + } while (*in_out++); +} diff --git a/library/cpp/charset/recyr.hh b/library/cpp/charset/recyr.hh index 5ec8734bcf..ee2bed9dc3 100644 --- a/library/cpp/charset/recyr.hh +++ b/library/cpp/charset/recyr.hh @@ -9,25 +9,25 @@ #include "codepage.h" #include "doccodes.h" #include "iconv.h" -#include "recyr_int.hh" +#include "recyr_int.hh" -/////////////////////////////////////////////////////////////////////////////////////// -// input buf -> output buf // -/////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////// +// input buf -> output buf // +/////////////////////////////////////////////////////////////////////////////////////// template <class TCharType> inline RECODE_RESULT RecodeToUnicode(ECharset from, const char* in, TCharType* out, size_t inSize, size_t outSize, size_t& inRead, size_t& outWritten) { static_assert(sizeof(TCharType) > 1, "expect wide character type"); return NCodepagePrivate::_recodeToUnicode(from, in, out, inSize, outSize, inRead, outWritten); -} - +} + template <class TCharType> inline RECODE_RESULT RecodeFromUnicode(ECharset to, const TCharType* in, char* out, size_t inSize, size_t outSize, size_t& inRead, size_t& outWritten) { static_assert(sizeof(TCharType) > 1, "expect wide character type"); return NCodepagePrivate::_recodeFromUnicode(to, in, out, inSize, outSize, inRead, outWritten); -} - +} + inline RECODE_RESULT RecodeFromUnicode(ECharset to, wchar32 rune, char* out, size_t outSize, size_t& outWritten) { return NCodepagePrivate::_recodeFromUnicode(to, rune, out, outSize, outWritten); } @@ -66,7 +66,7 @@ inline RECODE_RESULT Recode(ECharset from, ECharset to, const char* in, char* ou if (to == from) return NCodepagePrivate::_recodeCopy(in, out, inSize, outSize, inRead, outWritten); - + if (NCodepagePrivate::NativeCodepage(from) && NCodepagePrivate::NativeCodepage(to)) { if (from == CODES_UTF8) return NCodepagePrivate::_recodeFromUTF8(to, in, out, inSize, outSize, inRead, outWritten); @@ -79,7 +79,7 @@ inline RECODE_RESULT Recode(ECharset from, ECharset to, const char* in, char* ou } else if (NICONVPrivate::CanConvert(from, to)) { return NICONVPrivate::RecodeNoThrow(from, to, in, out, inSize, outSize, inRead, outWritten); } - + size_t wideSize = inSize * 3; TArrayHolder<wchar16> wide(new wchar16[wideSize]); @@ -131,22 +131,22 @@ inline bool Recode(ECharset from, ECharset to, const TStringBuf& in, TString& ou return true; } -/////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////// // TString -> TString // -/////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////// inline TString Recode(ECharset from, ECharset to, const TString& in) { TString out; return to != from && Recode(from, to, in, out) ? out : in; -} +} inline TString RecodeToYandex(ECharset from, const TString& in) { return Recode(from, CODES_YANDEX, in); -} +} inline TString RecodeFromYandex(ECharset to, const TString& in) { return Recode(CODES_YANDEX, to, in); -} - +} + inline TString RecodeToHTMLEntities(ECharset from, const TString& in) { - RECODE_RESULT res; + RECODE_RESULT res; size_t outWritten, inRead; TString out; out.resize(in.length() * (4 + 4)); @@ -154,11 +154,11 @@ inline TString RecodeToHTMLEntities(ECharset from, const TString& in) { if (res == RECODE_EOOUTPUT) { //input contains many 8-byte characters? out.resize(in.length() * (4 + 8)); res = NCodepagePrivate::_recodeToHTMLEntities(from, in.c_str(), out.begin(), in.length(), out.length(), inRead, outWritten); - } + } if (res != RECODE_OK) { ythrow yexception() << "Recode to HTML entities failed"; } out.resize(outWritten - 1); - return out; -} + return out; +} diff --git a/library/cpp/charset/recyr_int.hh b/library/cpp/charset/recyr_int.hh index 353af53305..ccf94a80cf 100644 --- a/library/cpp/charset/recyr_int.hh +++ b/library/cpp/charset/recyr_int.hh @@ -1,5 +1,5 @@ #pragma once - + #include <util/charset/recode_result.h> #include <util/charset/utf8.h> #include <util/generic/ptr.h> @@ -7,10 +7,10 @@ #include <util/system/defaults.h> #include "codepage.h" -#include "doccodes.h" +#include "doccodes.h" #include "iconv.h" #include "wide.h" - + namespace NCodepagePrivate { inline RECODE_RESULT _recodeCopy(const char* in, char* out, size_t in_size, size_t out_size, size_t& in_readed, size_t& out_writed) { in_readed = in_size; @@ -23,18 +23,18 @@ namespace NCodepagePrivate { memcpy(out, in, in_readed); out_writed = in_readed; return res; - } - + } + inline RECODE_RESULT _recodeToUTF8(ECharset From, const char* in, char* out, size_t in_size, size_t out_size, size_t& in_readed, size_t& out_writed) { if (From == CODES_UTF8) return _recodeCopy(in, out, in_size, out_size, in_readed, out_writed); const CodePage* cp = CodePageByCharset(From); - + const unsigned char* in_start = (const unsigned char*)in; const unsigned char* in_end = in_start + in_size; const unsigned char* out_start = (unsigned char*)out; const unsigned char* out_end = out_start + out_size; - + size_t rune_len; RECODE_RESULT res = RECODE_OK; while ((unsigned char*)in < in_end && res == RECODE_OK) { @@ -44,7 +44,7 @@ namespace NCodepagePrivate { in_readed = (unsigned char*)in - in_start; out_writed = (unsigned char*)out - out_start; return res; - } + } inline RECODE_RESULT _recodeFromUTF8(ECharset to, const char* in, char* out, size_t in_size, size_t out_size, size_t& in_readed, size_t& out_writed) { if (to == CODES_UTF8) @@ -56,7 +56,7 @@ namespace NCodepagePrivate { const unsigned char* in_end = in_start + in_size; const unsigned char* out_start = (unsigned char*)out; const unsigned char* out_end = out_start + out_size; - + wchar32 rune; size_t rune_len; RECODE_RESULT res = RECODE_OK; @@ -73,8 +73,8 @@ namespace NCodepagePrivate { in_readed = (unsigned char*)in - in_start; out_writed = (unsigned char*)out - out_start; return res; - } - + } + inline RECODE_RESULT _recodeToYandex(ECharset From, const char* in, char* out, size_t in_size, size_t out_size, size_t& in_readed, size_t& out_writed) { if (From == CODES_YANDEX) return _recodeCopy(in, out, in_size, out_size, in_readed, out_writed); @@ -101,7 +101,7 @@ namespace NCodepagePrivate { return RECODE_EOOUTPUT; return RECODE_OK; } - + template <class TCharType> inline RECODE_RESULT _recodeUTF8ToUnicode(const char* in, TCharType* out, size_t in_size, size_t out_size, size_t& in_readed, size_t& out_writed) { const unsigned char* inp = (const unsigned char*)in; @@ -121,7 +121,7 @@ namespace NCodepagePrivate { } inp += rune_len; } - } + } in_readed = inp - (const unsigned char*)in; out_writed = outp - out; @@ -130,7 +130,7 @@ namespace NCodepagePrivate { return res; } - + template <class TCharType> inline RECODE_RESULT _recodeSBToUnicode(ECharset From, const char* in, TCharType* out, size_t in_size, size_t out_size, size_t& in_readed, size_t& out_writed) { const CodePage* cp = CodePageByCharset(From); @@ -146,7 +146,7 @@ namespace NCodepagePrivate { return RECODE_EOOUTPUT; return RECODE_OK; } - + template <class TCharType> inline RECODE_RESULT _recodeUnicodeToUTF8Impl(const TCharType* in, char* out, size_t in_size, size_t out_size, size_t& in_readed, size_t& out_writed) { const TCharType* inp = in; @@ -167,8 +167,8 @@ namespace NCodepagePrivate { in_readed = inp - in; out_writed = outp - (const unsigned char*)out; return res; - } - + } + inline RECODE_RESULT _recodeUnicodeToUTF8(wchar32 rune, char* out, size_t out_size, size_t& nwritten) { return SafeWriteUTF8Char(rune, nwritten, (unsigned char*)out, out_size); } @@ -215,7 +215,7 @@ namespace NCodepagePrivate { return RECODE_OK; } - + inline RECODE_RESULT _recodeUnicodeToSB(ECharset To, wchar32 rune, char* out, size_t out_size, size_t& nwritten) { if (0 == out_size) return RECODE_EOOUTPUT; @@ -236,17 +236,17 @@ namespace NCodepagePrivate { break; } out[out_writed++] = hex_digs[h]; - } - } + } + } return res; - } - + } + inline RECODE_RESULT _recodeUnicodeToHTMLEntities(const wchar32* in, char* out, size_t in_size, size_t out_size, size_t& in_readed, size_t& out_writed) { const wchar32* in_end = in + in_size; const char* out_beg = out; const wchar32* in_beg = in; RECODE_RESULT res = RECODE_OK; - + const char* out_end = out + out_size - 1; while (in < in_end && out < out_end) { if (*in < 0x80 && *in != '<' && *in != '&' && *in != '>') { //ascii @@ -266,15 +266,15 @@ namespace NCodepagePrivate { ent += ent_writed; *ent++ = ';'; out = ent; - } + } in++; - } + } *out++ = '\x00'; out_writed = out - out_beg; in_readed = in - in_beg; return res; - } - + } + template <class TCharType> inline RECODE_RESULT _recodeToUnicode(ECharset From, const char* in, TCharType* out, size_t in_size, size_t out_size, size_t& in_readed, size_t& out_writed) { if (!ValidCodepage(From)) diff --git a/library/cpp/string_utils/quote/quote.cpp b/library/cpp/string_utils/quote/quote.cpp index e523350b80..c0a4b64c61 100644 --- a/library/cpp/string_utils/quote/quote.cpp +++ b/library/cpp/string_utils/quote/quote.cpp @@ -29,7 +29,7 @@ namespace { if (!IsAsciiHex((ui8)x[0]) || !IsAsciiHex((ui8)x[1])) return '%'; ui8 c = 0; - + GETXC; GETXC; return c; @@ -160,7 +160,7 @@ void CGIEscape(TString& url) { char* to = tempBuf.Data(); url.AssignNoAlias(to, CGIEscape(to, url.data(), url.size())); -} +} TString CGIEscapeRet(const TStringBuf url) { TString to; @@ -233,7 +233,7 @@ void CGIUnescape(TString& url) { } else { url = CGIUnescapeRet(url); } -} +} TString CGIUnescapeRet(const TStringBuf from) { TString to; diff --git a/util/charset/unidata.h b/util/charset/unidata.h index 400d314186..55aa6daeea 100644 --- a/util/charset/unidata.h +++ b/util/charset/unidata.h @@ -54,7 +54,7 @@ enum WC_TYPE { // TODO move no NUnicode Pe_QUOTE = 38, // '"' Pi_QUOTE = 39, // '"' Pf_QUOTE = 40, // '"' - Pc_CONNECTOR = 41, // '_' [_] LOW LINE + Pc_CONNECTOR = 41, // '_' [_] LOW LINE Po_OTHER = 42, // '*' [#%&*/@\] NUMBER SIGN ... REVERSE SOLIDUS Po_QUOTE = 43, // '"' ["] QUOTATION MARK Po_TERMINAL = 44, // '.' [!,.:;?] EXCLAMATION MARK ... QUESTION MARK diff --git a/util/string/vector.h b/util/string/vector.h index e36c348bbe..1ef5f22644 100644 --- a/util/string/vector.h +++ b/util/string/vector.h @@ -9,7 +9,7 @@ #include <util/generic/vector.h> #include <util/string/cast.h> #include <util/system/yassert.h> - + #define KEEP_EMPTY_TOKENS 0x01 // |