aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2019-01-03 07:50:19 +1100
committerZufu Liu <unknown>2019-01-03 07:50:19 +1100
commit227d033a42d4c2c823b2dc792554a229112711a5 (patch)
treee44abb911d840531f3c11375dbf0e10bb67bc6f8
parent6f94ed773596f4675685ee0cad7ddeaee9d53767 (diff)
downloadscintilla-mirror-227d033a42d4c2c823b2dc792554a229112711a5.tar.gz
Bug [#2073]. Stop GetCharacterAndWidth returning negative character value.
This occurred for single-byte encodings and was never hit as GetCharacterAndWidth is only called for multi-byte encodings.
-rw-r--r--src/Document.cxx4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index b5f1091c8..54a358f0b 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -927,8 +927,8 @@ Sci::Position Document::GetRelativePositionUTF16(Sci::Position positionStart, Sc
int SCI_METHOD Document::GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const {
int character;
int bytesInCharacter = 1;
+ const unsigned char leadByte = cb.UCharAt(position);
if (dbcsCodePage) {
- const unsigned char leadByte = cb.UCharAt(position);
if (SC_CP_UTF8 == dbcsCodePage) {
if (UTF8IsAscii(leadByte)) {
// Single byte character or invalid
@@ -956,7 +956,7 @@ int SCI_METHOD Document::GetCharacterAndWidth(Sci_Position position, Sci_Positio
}
}
} else {
- character = cb.CharAt(position);
+ character = leadByte;
}
if (pWidth) {
*pWidth = bytesInCharacter;