aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
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
commit407889bc0fd381b1ff48c62f8b0d579b81f068b5 (patch)
tree4ea92b6ab48018b988f329593ad06b23155899ad /src
parenta402d41e20e8fa48ee20bc4a4b5f866ace0c5d32 (diff)
downloadscintilla-mirror-407889bc0fd381b1ff48c62f8b0d579b81f068b5.tar.gz
Backport: 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. Backport of changeset 7188:c836128fa848.
Diffstat (limited to 'src')
-rw-r--r--src/Document.cxx4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index b6b1ce294..ad0ec80e7 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -930,8 +930,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
@@ -959,7 +959,7 @@ int SCI_METHOD Document::GetCharacterAndWidth(Sci_Position position, Sci_Positio
}
}
} else {
- character = cb.CharAt(position);
+ character = leadByte;
}
if (pWidth) {
*pWidth = bytesInCharacter;