diff options
author | iseg <iseg@yandex-team.ru> | 2022-02-10 16:49:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:39 +0300 |
commit | f828a15ab90e9ca8e848f83caf95c95f06be46e7 (patch) | |
tree | de25241f7ec727b05ff1e5b9e1336f567f788a44 /library/cpp/charset | |
parent | 8124e2bb214b063687e0d77c900150c727e16782 (diff) | |
download | ydb-f828a15ab90e9ca8e848f83caf95c95f06be46e7.tar.gz |
Restoring authorship annotation for <iseg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/charset')
-rw-r--r-- | library/cpp/charset/codepage.cpp | 38 | ||||
-rw-r--r-- | library/cpp/charset/codepage.h | 58 | ||||
-rw-r--r-- | library/cpp/charset/recyr.hh | 2 |
3 files changed, 49 insertions, 49 deletions
diff --git a/library/cpp/charset/codepage.cpp b/library/cpp/charset/codepage.cpp index 0431bef31bc..8e2df10531c 100644 --- a/library/cpp/charset/codepage.cpp +++ b/library/cpp/charset/codepage.cpp @@ -64,26 +64,26 @@ char* CodePage::ToUpper(const char* b, char* to) const { } int CodePage::stricmp(const char* dst, const char* src) const { - unsigned char f, l; - do { + unsigned char f, l; + do { f = ToLower(*dst++); l = ToLower(*src++); - } while (f && (f == l)); - return f - l; -} - + } while (f && (f == l)); + return f - l; +} + int CodePage::strnicmp(const char* dst, const char* src, size_t len) const { - unsigned char f, l; - if (len) { - do { + unsigned char f, l; + if (len) { + do { f = ToLower(*dst++); l = ToLower(*src++); - } while (--len && f && (f == l)); - return f - l; - } - return 0; -} - + } while (--len && f && (f == l)); + return f - l; + } + return 0; +} + static const CodePage UNSUPPORTED_CODEPAGE = { CODES_UNSUPPORTED, { @@ -179,7 +179,7 @@ public: } } } - + inline ECharset CharsetByName(TStringBuf name) { if (!name) return CODES_UNKNOWN; @@ -187,15 +187,15 @@ public: TData::const_iterator it = Data.find(name); if (it == Data.end()) return CODES_UNKNOWN; - + return it->second; } }; ECharset CharsetByName(TStringBuf name) { return Singleton<TCodePageHash>()->CharsetByName(name); -} - +} + ECharset CharsetByNameOrDie(TStringBuf name) { ECharset result = CharsetByName(name); if (result == CODES_UNKNOWN) diff --git a/library/cpp/charset/codepage.h b/library/cpp/charset/codepage.h index 30a02a46106..22d555b1586 100644 --- a/library/cpp/charset/codepage.h +++ b/library/cpp/charset/codepage.h @@ -13,19 +13,19 @@ #include <cctype> -struct CodePage; -struct Recoder; -struct Encoder; - +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 wchar32 unicode[256]; const char* DefaultChar; //[CCL_NUM] - + bool IsLower(unsigned char ch) const { return ::IsLower(unicode[ch]); } @@ -77,12 +77,12 @@ struct CodePage { inline unsigned char ToUpper(unsigned char ch) const; inline unsigned char ToLower(unsigned char ch) const; inline unsigned char ToTitle(unsigned char ch) const; - + inline int ToDigit(unsigned char ch) const { return ::ToDigit(unicode[ch]); } - static void Initialize(); + static void Initialize(); inline bool SingleByteCodepage() const { return DefaultChar != nullptr; @@ -90,7 +90,7 @@ struct CodePage { inline bool NativeCodepage() const { return SingleByteCodepage() || CPEnum == CODES_UTF8; } -}; +}; class TCodePageHash; @@ -151,7 +151,7 @@ inline bool ValidCodepage(ECharset e) { inline const CodePage* CodePageByCharset(ECharset e) { return ::NCodepagePrivate::TCodepagesMap::Instance().Get(e); -} +} ECharset CharsetByName(TStringBuf name); @@ -176,7 +176,7 @@ inline const char* NameByCharsetSafe(ECharset e) { inline const char* NameByCodePage(const CodePage* CP) { return CP->Names[0]; } - + inline const CodePage* CodePageByName(const char* name) { ECharset code = CharsetByName(name); if (code == CODES_UNKNOWN) @@ -190,7 +190,7 @@ ECharset EncodingHintByName(const char* name); /*****************************************************************\ * struct Encoder * \*****************************************************************/ -struct Encoder { +struct Encoder { char* Table[256]; const char* DefaultChar; @@ -198,7 +198,7 @@ struct Encoder { if (ch > 0xFFFF) return 0; return (unsigned char)Table[(ch >> 8) & 255][ch & 255]; - } + } inline char Tr(wchar32 ch) const { char code = Code(ch); @@ -206,11 +206,11 @@ struct Encoder { code = DefaultChar[NUnicode::CharType(ch)]; Y_ASSERT(code != 0 || ch == 0); return code; - } + } inline unsigned char operator[](wchar32 ch) const { - return Tr(ch); - } + return Tr(ch); + } void Tr(const wchar32* in, char* out, size_t len) const; void Tr(const wchar32* in, char* out) const; @@ -220,27 +220,27 @@ struct Encoder { /*****************************************************************\ * struct Recoder * \*****************************************************************/ -struct Recoder { +struct Recoder { 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]; - } + return Table[c]; + } inline unsigned char operator[](unsigned char c) const { - return Table[c]; - } + return Table[c]; + } void Tr(const char* in, char* out, size_t len) const; void Tr(const char* in, char* out) const; void Tr(char* in_out, size_t len) const; void Tr(char* in_out) const; -}; - +}; + extern const struct Encoder& WideCharToYandex; const Encoder& EncoderByCharset(ECharset enc); @@ -276,16 +276,16 @@ inline const Encoder& EncoderByCharset(ECharset enc) { inline unsigned char CodePage::ToUpper(unsigned char ch) const { return NCodepagePrivate::TCodePageData::rcdr_to_upper[CPEnum].Table[ch]; -} +} inline unsigned char CodePage::ToLower(unsigned char ch) const { return NCodepagePrivate::TCodePageData::rcdr_to_lower[CPEnum].Table[ch]; -} +} inline unsigned char CodePage::ToTitle(unsigned char ch) const { return NCodepagePrivate::TCodePageData::rcdr_to_title[CPEnum].Table[ch]; -} - +} + extern const CodePage& csYandex; - + /// these functions change (lowers) [end] position in case of utf-8 /// null character is NOT assumed or written at [*end] void DecodeUnknownPlane(wchar16* start, wchar16*& end, const ECharset enc4unk); diff --git a/library/cpp/charset/recyr.hh b/library/cpp/charset/recyr.hh index 5ec8734bcfb..e22ec3b9bcc 100644 --- a/library/cpp/charset/recyr.hh +++ b/library/cpp/charset/recyr.hh @@ -10,7 +10,7 @@ #include "doccodes.h" #include "iconv.h" #include "recyr_int.hh" - + /////////////////////////////////////////////////////////////////////////////////////// // input buf -> output buf // /////////////////////////////////////////////////////////////////////////////////////// |