diff options
author | nyamatongwe <unknown> | 2011-06-25 11:29:37 +1000 |
---|---|---|
committer | nyamatongwe <unknown> | 2011-06-25 11:29:37 +1000 |
commit | bd9c56e568d9a725896ff644214b84b095d5e0ef (patch) | |
tree | a817dd1723d9e6f27bdf746b787b84956856a8d0 /src | |
parent | f3ba280682cb414a0b9c37a6c3e6e1c11925a90f (diff) | |
download | scintilla-mirror-bd9c56e568d9a725896ff644214b84b095d5e0ef.tar.gz |
Add casts to avoid warnings from SDK 64-bit compiler.
Diffstat (limited to 'src')
-rw-r--r-- | src/Document.cxx | 16 | ||||
-rw-r--r-- | src/Editor.cxx | 48 | ||||
-rw-r--r-- | src/PerLine.cxx | 4 | ||||
-rw-r--r-- | src/PositionCache.cxx | 4 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 4 |
5 files changed, 44 insertions, 32 deletions
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) |