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 | f7cab317b777bb8fedb4bd8f4eeb7e68bf712989 (patch) | |
tree | a80432017efd0e8b427bb7b2e3cd6eedf48de57d /src | |
parent | dc7c28cfcf21c18f96a49f2cc0818d4f676bd301 (diff) | |
download | scintilla-mirror-f7cab317b777bb8fedb4bd8f4eeb7e68bf712989.tar.gz |
Remove casts between char and unsigned char where possible.
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 58ab3b3f4..52259031c 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 127b6872a..e576c5db3 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -604,10 +604,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; @@ -705,10 +705,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 @@ -940,7 +940,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 @@ -988,7 +988,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; @@ -2609,7 +2609,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 fb50b9277..c17e85d3a 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]; } } |