aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2011-06-25 11:29:37 +1000
committernyamatongwe <unknown>2011-06-25 11:29:37 +1000
commitbd9c56e568d9a725896ff644214b84b095d5e0ef (patch)
treea817dd1723d9e6f27bdf746b787b84956856a8d0
parentf3ba280682cb414a0b9c37a6c3e6e1c11925a90f (diff)
downloadscintilla-mirror-bd9c56e568d9a725896ff644214b84b095d5e0ef.tar.gz
Add casts to avoid warnings from SDK 64-bit compiler.
-rw-r--r--lexlib/PropSetSimple.cxx7
-rw-r--r--src/Document.cxx16
-rw-r--r--src/Editor.cxx48
-rw-r--r--src/PerLine.cxx4
-rw-r--r--src/PositionCache.cxx4
-rw-r--r--src/ScintillaBase.cxx4
-rw-r--r--win32/PlatWin.cxx8
-rw-r--r--win32/ScintillaWin.cxx46
8 files changed, 81 insertions, 56 deletions
diff --git a/lexlib/PropSetSimple.cxx b/lexlib/PropSetSimple.cxx
index 6942f6e71..ce2031f8d 100644
--- a/lexlib/PropSetSimple.cxx
+++ b/lexlib/PropSetSimple.cxx
@@ -61,9 +61,10 @@ void PropSetSimple::Set(const char *keyVal) {
endVal++;
const char *eqAt = strchr(keyVal, '=');
if (eqAt) {
- Set(keyVal, eqAt + 1, eqAt-keyVal, endVal - eqAt - 1);
+ Set(keyVal, eqAt + 1, static_cast<int>(eqAt-keyVal),
+ static_cast<int>(endVal - eqAt - 1));
} else if (*keyVal) { // No '=' so assume '=1'
- Set(keyVal, "1", endVal-keyVal, 1);
+ Set(keyVal, "1", static_cast<int>(endVal-keyVal), 1);
}
}
@@ -150,7 +151,7 @@ char *PropSetSimple::Expanded(const char *key) const {
int PropSetSimple::GetExpanded(const char *key, char *result) const {
char *val = Expanded(key);
- const int n = strlen(val);
+ const int n = static_cast<int>(strlen(val));
if (result) {
strcpy(result, val);
}
diff --git a/src/Document.cxx b/src/Document.cxx
index dde9c4b6b..85bb98135 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -986,7 +986,7 @@ bool Document::InsertChar(int pos, char ch) {
* Insert a null terminated string.
*/
bool Document::InsertCString(int position, const char *s) {
- return InsertString(position, s, strlen(s));
+ return InsertString(position, s, static_cast<int>(strlen(s)));
}
void Document::ChangeChar(int pos, char ch) {
@@ -1385,7 +1385,7 @@ size_t Document::ExtractChar(int pos, char *bytes) {
size_t widthChar = UTF8CharLength(ch);
bytes[0] = ch;
for (size_t i=1; i<widthChar; i++) {
- bytes[i] = cb.CharAt(pos+i);
+ bytes[i] = cb.CharAt(static_cast<int>(pos+i));
if (!GoodTrailByte(static_cast<unsigned char>(bytes[i]))) { // Bad byte
widthChar = 1;
}
@@ -1483,7 +1483,8 @@ long Document::FindText(int minPos, int maxPos, const char *search,
const size_t maxBytesCharacter = 4;
const size_t maxFoldingExpansion = 4;
std::vector<char> searchThing(lengthFind * maxBytesCharacter * maxFoldingExpansion + 1);
- const int lenSearch = pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind);
+ const int lenSearch = static_cast<int>(
+ pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind));
while (forward ? (pos < endSearch) : (pos >= endSearch)) {
int widthFirstCharacter = 0;
int indexDocument = 0;
@@ -1494,11 +1495,11 @@ long Document::FindText(int minPos, int maxPos, const char *search,
(indexSearch < lenSearch)) {
char bytes[maxBytesCharacter + 1];
bytes[maxBytesCharacter] = 0;
- const int widthChar = ExtractChar(pos + indexDocument, bytes);
+ const int widthChar = static_cast<int>(ExtractChar(pos + indexDocument, bytes));
if (!widthFirstCharacter)
widthFirstCharacter = widthChar;
char folded[maxBytesCharacter * maxFoldingExpansion + 1];
- const int lenFlat = pcf->Fold(folded, sizeof(folded), bytes, widthChar);
+ const int lenFlat = static_cast<int>(pcf->Fold(folded, sizeof(folded), bytes, widthChar));
folded[lenFlat] = 0;
// Does folded match the buffer
characterMatches = 0 == memcmp(folded, &searchThing[0] + indexSearch, lenFlat);
@@ -1522,7 +1523,8 @@ long Document::FindText(int minPos, int maxPos, const char *search,
const size_t maxBytesCharacter = 2;
const size_t maxFoldingExpansion = 4;
std::vector<char> searchThing(lengthFind * maxBytesCharacter * maxFoldingExpansion + 1);
- const int lenSearch = pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind);
+ const int lenSearch = static_cast<int>(
+ pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind));
while (forward ? (pos < endSearch) : (pos >= endSearch)) {
int indexDocument = 0;
int indexSearch = 0;
@@ -1536,7 +1538,7 @@ long Document::FindText(int minPos, int maxPos, const char *search,
if (widthChar == 2)
bytes[1] = cb.CharAt(pos + indexDocument + 1);
char folded[maxBytesCharacter * maxFoldingExpansion + 1];
- const int lenFlat = pcf->Fold(folded, sizeof(folded), bytes, widthChar);
+ const int lenFlat = static_cast<int>(pcf->Fold(folded, sizeof(folded), bytes, widthChar));
folded[lenFlat] = 0;
// Does folded match the buffer
characterMatches = 0 == memcmp(folded, &searchThing[0] + indexSearch, lenFlat);
diff --git a/src/Editor.cxx b/src/Editor.cxx
index ff9872e58..4cc32eb44 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1612,8 +1612,10 @@ void Editor::LinesSplit(int pixelWidth) {
unsigned int posLineStart = pdoc->LineStart(line);
LayoutLine(line, surface, vs, ll, pixelWidth);
for (int subLine = 1; subLine < ll->lines; subLine++) {
- pdoc->InsertCString(posLineStart + (subLine - 1) * strlen(eol) +
- ll->LineStart(subLine), eol);
+ pdoc->InsertCString(
+ static_cast<int>(posLineStart + (subLine - 1) * strlen(eol) +
+ ll->LineStart(subLine)),
+ eol);
targetEnd += static_cast<int>(strlen(eol));
}
}
@@ -1656,7 +1658,8 @@ static int WidthStyledText(Surface *surface, ViewStyle &vs, int styleOffset,
size_t endSegment = start;
while ((endSegment+1 < len) && (static_cast<size_t>(styles[endSegment+1]) == style))
endSegment++;
- width += surface->WidthText(vs.styles[style+styleOffset].font, text + start, endSegment - start + 1);
+ width += surface->WidthText(vs.styles[style+styleOffset].font, text + start,
+ static_cast<int>(endSegment - start + 1));
start = endSegment + 1;
}
return width;
@@ -1671,7 +1674,8 @@ static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, con
if (st.multipleStyles) {
widthSubLine = WidthStyledText(surface, vs, styleOffset, st.text + start, st.styles + start, lenLine);
} else {
- widthSubLine = surface->WidthText(vs.styles[styleOffset + st.style].font, st.text + start, lenLine);
+ widthSubLine = surface->WidthText(vs.styles[styleOffset + st.style].font,
+ st.text + start, static_cast<int>(lenLine));
}
if (widthSubLine > widthMax)
widthMax = widthSubLine;
@@ -1692,21 +1696,24 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle
while (end < length-1 && st.styles[start+end+1] == style)
end++;
style += styleOffset;
- int width = surface->WidthText(vs.styles[style].font, st.text + start + i, end - i + 1);
+ int width = surface->WidthText(vs.styles[style].font,
+ st.text + start + i, static_cast<int>(end - i + 1));
PRectangle rcSegment = rcText;
rcSegment.left = x;
rcSegment.right = x + width + 1;
surface->DrawTextNoClip(rcSegment, vs.styles[style].font,
- ascent, st.text + start + i, end - i + 1,
+ ascent, st.text + start + i,
+ static_cast<int>(end - i + 1),
vs.styles[style].fore.allocated,
vs.styles[style].back.allocated);
x += width;
i = end + 1;
}
} else {
- int style = st.style + styleOffset;
+ size_t style = st.style + styleOffset;
surface->DrawTextNoClip(rcText, vs.styles[style].font,
- rcText.top + vs.maxAscent, st.text + start, length,
+ rcText.top + vs.maxAscent, st.text + start,
+ static_cast<int>(length),
vs.styles[style].fore.allocated,
vs.styles[style].back.allocated);
}
@@ -4870,10 +4877,13 @@ void Editor::ChangeCaseOfSelection(int caseMapping) {
while (sMapped[lastDifference] == sText[lastDifference])
lastDifference--;
size_t endSame = sMapped.size() - 1 - lastDifference;
- pdoc->DeleteChars(currentNoVS.Start().Position() + firstDifference,
- rangeBytes - firstDifference - endSame);
- pdoc->InsertString(currentNoVS.Start().Position() + firstDifference,
- sMapped.c_str() + firstDifference, lastDifference - firstDifference + 1);
+ pdoc->DeleteChars(
+ static_cast<int>(currentNoVS.Start().Position() + firstDifference),
+ static_cast<int>(rangeBytes - firstDifference - endSame));
+ pdoc->InsertString(
+ static_cast<int>(currentNoVS.Start().Position() + firstDifference),
+ sMapped.c_str() + firstDifference,
+ static_cast<int>(lastDifference - firstDifference + 1));
// Automatic movement changes selection so reset to exactly the same as it was.
sel.Range(r) = current;
}
@@ -5814,7 +5824,7 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
int end = pdoc->LineEnd(currentLine);
char *text = CopyRange(start, end);
- int textLen = text ? strlen(text) : 0;
+ size_t textLen = text ? strlen(text) : 0;
// include room for \r\n\0
textLen += 3;
char *textWithEndl = new char[textLen];
@@ -5825,7 +5835,7 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
strncat(textWithEndl, "\r", textLen);
if (pdoc->eolMode != SC_EOL_CR)
strncat(textWithEndl, "\n", textLen);
- ss->Set(textWithEndl, strlen(textWithEndl) + 1,
+ ss->Set(textWithEndl, static_cast<int>(strlen(textWithEndl) + 1),
pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, true);
delete []text;
}
@@ -5838,7 +5848,7 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
delimiterLength = 1;
}
}
- int size = sel.Length() + delimiterLength * sel.Count();
+ size_t size = sel.Length() + delimiterLength * sel.Count();
char *text = new char[size + 1];
int j = 0;
std::vector<SelectionRange> rangesInOrder = sel.RangesCopy();
@@ -5861,7 +5871,7 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
}
}
text[size] = '\0';
- ss->Set(text, size + 1, pdoc->dbcsCodePage,
+ ss->Set(text, static_cast<int>(size + 1), pdoc->dbcsCodePage,
vs.styles[STYLE_DEFAULT].characterSet, sel.IsRectangular(), sel.selType == Selection::selLines);
}
}
@@ -6908,9 +6918,9 @@ int Editor::WrapCount(int line) {
void Editor::AddStyledText(char *buffer, int appendLength) {
// The buffer consists of alternating character bytes and style bytes
- size_t textLength = appendLength / 2;
+ int textLength = appendLength / 2;
char *text = new char[textLength];
- size_t i;
+ int i;
for (i = 0; i < textLength; i++) {
text[i] = buffer[i*2];
}
@@ -7018,7 +7028,7 @@ sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPar
}
sptr_t Editor::StringResult(sptr_t lParam, const char *val) {
- const int n = strlen(val);
+ const size_t n = strlen(val);
if (lParam != 0) {
char *ptr = reinterpret_cast<char *>(lParam);
strcpy(ptr, val);
diff --git a/src/PerLine.cxx b/src/PerLine.cxx
index 8fc6e2531..7d961a886 100644
--- a/src/PerLine.cxx
+++ b/src/PerLine.cxx
@@ -425,10 +425,10 @@ void LineAnnotation::SetText(int line, const char *text) {
if (annotations[line]) {
delete []annotations[line];
}
- annotations[line] = AllocateAnnotation(strlen(text), style);
+ annotations[line] = AllocateAnnotation(static_cast<int>(strlen(text)), style);
AnnotationHeader *pah = reinterpret_cast<AnnotationHeader *>(annotations[line]);
pah->style = static_cast<short>(style);
- pah->length = strlen(text);
+ pah->length = static_cast<int>(strlen(text));
pah->lines = static_cast<short>(NumberLines(text));
memcpy(annotations[line]+sizeof(AnnotationHeader), text, pah->length);
} else {
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 5f3ce81b3..8a195caac 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -605,11 +605,11 @@ void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned
// Two way associative: try two probe positions.
int hashValue = PositionCacheEntry::Hash(styleNumber, s, len);
- probe = hashValue % size;
+ probe = static_cast<int>(hashValue % size);
if (pces[probe].Retrieve(styleNumber, s, len, positions)) {
return;
}
- int probe2 = (hashValue * 37) % size;
+ int probe2 = static_cast<int>((hashValue * 37) % size);
if (pces[probe2].Retrieve(styleNumber, s, len, positions)) {
return;
}
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 380ed2424..fa5d836eb 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -205,7 +205,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
if (ac.chooseSingle && (listType == 0)) {
if (list && !strchr(list, ac.GetSeparator())) {
const char *typeSep = strchr(list, ac.GetTypesep());
- size_t lenInsert = (typeSep) ? (typeSep-list) : strlen(list);
+ int lenInsert = static_cast<int>((typeSep) ? (typeSep-list) : strlen(list));
if (ac.ignoreCase) {
SetEmptySelection(sel.MainCaret() - lenEntered);
pdoc->DeleteChars(sel.MainCaret(), lenEntered);
@@ -394,7 +394,7 @@ int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) {
ac.lb->GetValue(item, selected, sizeof(selected));
if (buffer != NULL)
strcpy(buffer, selected);
- return strlen(selected);
+ return static_cast<int>(strlen(selected));
}
}
if (buffer != NULL)
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 35d66030f..6a2f103ba 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -1315,7 +1315,7 @@ public:
};
char *LineToItem::AllocWord(const char *text) {
- int chars = strlen(text) + 1;
+ int chars = static_cast<int>(strlen(text) + 1);
int newCount = wordsCount + chars;
if (newCount > wordsSize) {
wordsSize = _ROUND2(newCount * 2, 8192);
@@ -1513,7 +1513,7 @@ PRectangle ListBoxX::GetDesiredRect() {
HDC hdc = ::GetDC(lb);
HFONT oldFont = SelectFont(hdc, fontCopy);
SIZE textSize = {0, 0};
- int len = widestItem ? strlen(widestItem) : 0;
+ int len = static_cast<int>(widestItem ? strlen(widestItem) : 0);
if (unicodeMode) {
const TextWide tbuf(widestItem, len, unicodeMode);
::GetTextExtentPoint32W(hdc, tbuf.buffer, tbuf.tlen, &textSize);
@@ -1631,7 +1631,7 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) {
ListItemData item = lti.Get(pDrawItem->itemID);
int pixId = item.pixId;
const char *text = item.text;
- int len = strlen(text);
+ int len = static_cast<int>(strlen(text));
RECT rcText = rcBox;
::InsetRect(&rcText, TextInset.x, TextInset.y);
@@ -1690,7 +1690,7 @@ void ListBoxX::SetList(const char *list, char separator, char typesep) {
// the listbox is not visible.
SetRedraw(false);
Clear();
- int size = strlen(list) + 1;
+ size_t size = strlen(list) + 1;
char *words = new char[size];
lti.SetWords(words);
memcpy(words, list, size);
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index f86d649c7..9925a64bb 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -1345,8 +1345,10 @@ public:
if (lenMixed > utf16Mixed.size()) {
utf16Mixed.resize(lenMixed + 8);
}
- size_t nUtf16Mixed = ::MultiByteToWideChar(65001, 0, mixed, lenMixed,
- &utf16Mixed[0], utf16Mixed.size());
+ size_t nUtf16Mixed = ::MultiByteToWideChar(65001, 0, mixed,
+ static_cast<int>(lenMixed),
+ &utf16Mixed[0],
+ static_cast<int>(utf16Mixed.size()));
if (nUtf16Mixed == 0) {
// Failed to convert -> bad UTF-8
@@ -1359,11 +1361,14 @@ public:
}
int lenFlat = ::LCMapStringW(LOCALE_SYSTEM_DEFAULT,
LCMAP_LINGUISTIC_CASING | LCMAP_LOWERCASE,
- &utf16Mixed[0], nUtf16Mixed, &utf16Folded[0], utf16Folded.size());
+ &utf16Mixed[0],
+ static_cast<int>(nUtf16Mixed),
+ &utf16Folded[0],
+ static_cast<int>(utf16Folded.size()));
size_t lenOut = UTF8Length(&utf16Folded[0], lenFlat);
if (lenOut < sizeFolded) {
- UTF8FromUTF16(&utf16Folded[0], lenFlat, folded, lenOut);
+ UTF8FromUTF16(&utf16Folded[0], lenFlat, folded, static_cast<int>(lenOut));
return lenOut;
} else {
return 0;
@@ -1390,8 +1395,10 @@ public:
if (lenMixed > utf16Mixed.size()) {
utf16Mixed.resize(lenMixed + 8);
}
- size_t nUtf16Mixed = ::MultiByteToWideChar(cp, 0, mixed, lenMixed,
- &utf16Mixed[0], utf16Mixed.size());
+ size_t nUtf16Mixed = ::MultiByteToWideChar(cp, 0, mixed,
+ static_cast<int>(lenMixed),
+ &utf16Mixed[0],
+ static_cast<int>(utf16Mixed.size()));
if (nUtf16Mixed == 0) {
// Failed to convert -> bad input
@@ -1404,7 +1411,10 @@ public:
}
int lenFlat = ::LCMapStringW(LOCALE_SYSTEM_DEFAULT,
LCMAP_LINGUISTIC_CASING | LCMAP_LOWERCASE,
- &utf16Mixed[0], nUtf16Mixed, &utf16Folded[0], utf16Folded.size());
+ &utf16Mixed[0],
+ static_cast<int>(nUtf16Mixed),
+ &utf16Folded[0],
+ static_cast<int>(utf16Folded.size()));
size_t lenOut = ::WideCharToMultiByte(cp, 0,
&utf16Folded[0], lenFlat,
@@ -1413,7 +1423,7 @@ public:
if (lenOut < sizeFolded) {
::WideCharToMultiByte(cp, 0,
&utf16Folded[0], lenFlat,
- folded, lenOut, NULL, 0);
+ folded, static_cast<int>(lenOut), NULL, 0);
return lenOut;
} else {
return 0;
@@ -1468,7 +1478,8 @@ std::string ScintillaWin::CaseMapString(const std::string &s, int caseMapping) {
UINT cpDoc = CodePageOfDocument();
- unsigned int lengthUTF16 = ::MultiByteToWideChar(cpDoc, 0, s.c_str(), s.size(), NULL, 0);
+ unsigned int lengthUTF16 = ::MultiByteToWideChar(cpDoc, 0, s.c_str(),
+ static_cast<int>(s.size()), NULL, 0);
if (lengthUTF16 == 0) // Failed to convert
return s;
@@ -1483,7 +1494,7 @@ std::string ScintillaWin::CaseMapString(const std::string &s, int caseMapping) {
// Change text to UTF-16
std::vector<wchar_t> vwcText(lengthUTF16);
- ::MultiByteToWideChar(cpDoc, 0, s.c_str(), s.size(), &vwcText[0], lengthUTF16);
+ ::MultiByteToWideChar(cpDoc, 0, s.c_str(), static_cast<int>(s.size()), &vwcText[0], lengthUTF16);
// Change case
int charsConverted = ::LCMapStringW(LOCALE_SYSTEM_DEFAULT, mapFlags,
@@ -1494,12 +1505,12 @@ std::string ScintillaWin::CaseMapString(const std::string &s, int caseMapping) {
// Change back to document encoding
unsigned int lengthConverted = ::WideCharToMultiByte(cpDoc, 0,
- &vwcConverted[0], vwcConverted.size(),
+ &vwcConverted[0], static_cast<int>(vwcConverted.size()),
NULL, 0, NULL, 0);
std::vector<char> vcConverted(lengthConverted);
::WideCharToMultiByte(cpDoc, 0,
- &vwcConverted[0], vwcConverted.size(),
- &vcConverted[0], vcConverted.size(), NULL, 0);
+ &vwcConverted[0], static_cast<int>(vwcConverted.size()),
+ &vcConverted[0], static_cast<int>(vcConverted.size()), NULL, 0);
return std::string(&vcConverted[0], vcConverted.size());
@@ -1509,7 +1520,8 @@ std::string ScintillaWin::CaseMapString(const std::string &s, int caseMapping) {
// Change text to UTF-16
wchar_t vwcText[shortSize];
- ::MultiByteToWideChar(cpDoc, 0, s.c_str(), s.size(), vwcText, lengthUTF16);
+ ::MultiByteToWideChar(cpDoc, 0, s.c_str(), static_cast<int>(s.size()),
+ vwcText, lengthUTF16);
// Change case
int charsConverted = ::LCMapStringW(LOCALE_SYSTEM_DEFAULT, mapFlags,
@@ -1613,8 +1625,8 @@ void ScintillaWin::InsertPasteText(const char *text, int len, SelectionPosition
// add the newline if necessary
if ((len > 0) && (text[len-1] != '\n' && text[len-1] != '\r')) {
const char *endline = StringFromEOLMode(pdoc->eolMode);
- pdoc->InsertString(insertPos + len, endline, strlen(endline));
- len += strlen(endline);
+ pdoc->InsertString(insertPos + len, endline, static_cast<int>(strlen(endline)));
+ len += static_cast<int>(strlen(endline));
}
if (sel.MainCaret() == insertPos) {
SetEmptySelection(sel.MainCaret() + len);
@@ -2472,7 +2484,7 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
if (data && convertPastes) {
// Convert line endings of the drop into our local line-endings mode
- int len = strlen(data);
+ int len = static_cast<int>(strlen(data));
char *convertedText = Document::TransformLineEnds(&len, data, len, pdoc->eolMode);
if (dataAllocated)
delete []data;