diff options
author | Neil <nyamatongwe@gmail.com> | 2018-04-22 08:35:01 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2018-04-22 08:35:01 +1000 |
commit | 8f9a43df028d13c1bc6654aa6dcf66dd542843d2 (patch) | |
tree | 677c3aae65caee744f4ce00478f40dcfec7147bc /src | |
parent | afcd6f1fa748f2ade19010b3307c341b382818de (diff) | |
download | scintilla-mirror-8f9a43df028d13c1bc6654aa6dcf66dd542843d2.tar.gz |
Backport: Remove casts between char and unsigned char where possible.
Backport of changeset 6731:8e06234817c0.
Diffstat (limited to 'src')
-rw-r--r-- | src/CellBuffer.cxx | 2 | ||||
-rw-r--r-- | src/DBCS.cxx | 2 | ||||
-rw-r--r-- | src/Document.cxx | 14 | ||||
-rw-r--r-- | src/UniConversion.cxx | 3 | ||||
-rw-r--r-- | src/XPM.cxx | 2 |
5 files changed, 11 insertions, 12 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 2928edcb4..a0873c986 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -382,7 +382,7 @@ char CellBuffer::CharAt(Sci::Position position) const noexcept { } unsigned char CellBuffer::UCharAt(Sci::Position position) const noexcept { - return static_cast<unsigned char>(substance.ValueAt(position)); + return substance.ValueAt(position); } void CellBuffer::GetCharRange(char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const { diff --git a/src/DBCS.cxx b/src/DBCS.cxx index 644cad04d..148c9818e 100644 --- a/src/DBCS.cxx +++ b/src/DBCS.cxx @@ -13,7 +13,7 @@ namespace Scintilla { bool DBCSIsLeadByte(int codePage, char ch) noexcept { // Byte ranges found in Wikipedia articles with relevant search strings in each case - const unsigned char uch = static_cast<unsigned char>(ch); + const unsigned char uch = ch; switch (codePage) { case 932: // Shift_jis diff --git a/src/Document.cxx b/src/Document.cxx index 107c94b3c..ca3c6ea17 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -608,10 +608,10 @@ bool Document::InGoodUTF8(Sci::Position pos, Sci::Position &start, Sci::Position if (len > trailBytes) // pos too far from lead return false; - char charBytes[UTF8MaxBytes] = {static_cast<char>(leadByte),0,0,0}; + unsigned char charBytes[UTF8MaxBytes] = {leadByte,0,0,0}; for (Sci::Position b=1; b<widthCharBytes && ((start+b) < Length()); b++) charBytes[b] = cb.CharAt(start+b); - const int utf8status = UTF8Classify(reinterpret_cast<const unsigned char *>(charBytes), widthCharBytes); + const int utf8status = UTF8Classify(charBytes, widthCharBytes); if (utf8status & UTF8MaskInvalid) return false; end = start + widthCharBytes; @@ -709,10 +709,10 @@ Sci::Position Document::NextPosition(Sci::Position pos, int moveDir) const noexc pos++; } else { const int widthCharBytes = UTF8BytesOfLead[leadByte]; - char charBytes[UTF8MaxBytes] = {static_cast<char>(leadByte),0,0,0}; + unsigned char charBytes[UTF8MaxBytes] = {leadByte,0,0,0}; for (int b=1; b<widthCharBytes; b++) charBytes[b] = cb.CharAt(pos+b); - const int utf8status = UTF8Classify(reinterpret_cast<const unsigned char *>(charBytes), widthCharBytes); + const int utf8status = UTF8Classify(charBytes, widthCharBytes); if (utf8status & UTF8MaskInvalid) pos++; else @@ -944,7 +944,7 @@ bool SCI_METHOD Document::IsDBCSLeadByte(char ch) const { bool Document::IsDBCSLeadByteNoExcept(char ch) const noexcept { // Used inside core Scintilla // Byte ranges found in Wikipedia articles with relevant search strings in each case - const unsigned char uch = static_cast<unsigned char>(ch); + const unsigned char uch = ch; switch (dbcsCodePage) { case 932: // Shift_jis @@ -992,7 +992,7 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) const int lastPunctuationBreak = -1; int lastEncodingAllowedBreak = 0; for (int j=0; j < lengthSegment;) { - const unsigned char ch = static_cast<unsigned char>(text[j]); + const unsigned char ch = text[j]; if (j > 0) { if (IsSpaceOrTab(text[j - 1]) && !IsSpaceOrTab(text[j])) { lastSpaceBreak = j; @@ -2613,7 +2613,7 @@ public: const Document *doc; Sci::Position position; - ByteIterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept : + ByteIterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept : doc(doc_), position(position_) { } ByteIterator(const ByteIterator &other) noexcept { diff --git a/src/UniConversion.cxx b/src/UniConversion.cxx index 04b8891cb..64599afaf 100644 --- a/src/UniConversion.cxx +++ b/src/UniConversion.cxx @@ -87,9 +87,8 @@ void UTF8FromUTF32Character(int uch, char *putf) { size_t UTF16Length(const char *s, size_t len) { size_t ulen = 0; - const unsigned char *us = reinterpret_cast<const unsigned char *>(s); for (size_t i = 0; i < len;) { - const unsigned char ch = us[i]; + const unsigned char ch = s[i]; const unsigned int byteCount = UTF8BytesOfLead[ch]; const unsigned int utf16Len = UTF16LengthFromUTF8ByteCount(byteCount); i += byteCount; diff --git a/src/XPM.cxx b/src/XPM.cxx index 04dc530bf..0d57873ac 100644 --- a/src/XPM.cxx +++ b/src/XPM.cxx @@ -120,7 +120,7 @@ void XPM::Init(const char *const *linesForm) { const char *lform = linesForm[y+nColours+1]; const size_t len = MeasureLength(lform); for (size_t x = 0; x<len; x++) - pixels[y * width + x] = static_cast<unsigned char>(lform[x]); + pixels[y * width + x] = lform[x]; } } |