aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2018-05-03 07:44:07 +1000
committerNeil <nyamatongwe@gmail.com>2018-05-03 07:44:07 +1000
commita89c20b95b80e21061ed34289e043616221320fb (patch)
treefb59505f5df4e582bbb9fe9ab384bb8e2ed7c5d7
parent62ac2fcca76ba15f69ad050b9959088100481096 (diff)
downloadscintilla-mirror-a89c20b95b80e21061ed34289e043616221320fb.tar.gz
Backport: Avoid casts.
Backport of changeset 6787:b690b9e1e111.
-rw-r--r--lexlib/LexAccessor.h5
-rw-r--r--src/Editor.cxx8
-rw-r--r--src/RESearch.cxx9
3 files changed, 12 insertions, 10 deletions
diff --git a/lexlib/LexAccessor.h b/lexlib/LexAccessor.h
index 48097e279..822c81dfb 100644
--- a/lexlib/LexAccessor.h
+++ b/lexlib/LexAccessor.h
@@ -170,13 +170,14 @@ public:
if (validLen + (pos - startSeg + 1) >= bufferSize)
Flush();
+ char attr = static_cast<char>(chAttr);
if (validLen + (pos - startSeg + 1) >= bufferSize) {
// Too big for buffer so send directly
- pAccess->SetStyleFor(pos - startSeg + 1, static_cast<char>(chAttr));
+ pAccess->SetStyleFor(pos - startSeg + 1, attr);
} else {
for (Sci_PositionU i = startSeg; i <= pos; i++) {
assert((startPosStyling + validLen) < Length());
- styleBuf[validLen++] = static_cast<char>(chAttr);
+ styleBuf[validLen++] = attr;
}
}
}
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 356282882..f30c08a59 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -4228,10 +4228,10 @@ void Editor::DisplayCursor(Window::Cursor c) {
}
bool Editor::DragThreshold(Point ptStart, Point ptNow) {
- const int xMove = static_cast<int>(ptStart.x - ptNow.x);
- const int yMove = static_cast<int>(ptStart.y - ptNow.y);
- const int distanceSquared = xMove * xMove + yMove * yMove;
- return distanceSquared > 16;
+ const XYPOSITION xMove = ptStart.x - ptNow.x;
+ const XYPOSITION yMove = ptStart.y - ptNow.y;
+ const XYPOSITION distanceSquared = xMove * xMove + yMove * yMove;
+ return distanceSquared > 16.0f;
}
void Editor::StartDrag() {
diff --git a/src/RESearch.cxx b/src/RESearch.cxx
index 6d558281b..d29549ac2 100644
--- a/src/RESearch.cxx
+++ b/src/RESearch.cxx
@@ -256,7 +256,8 @@ RESearch::RESearch(CharClassify *charClassTable) {
charClass = charClassTable;
sta = NOP; /* status of lastpat */
bol = 0;
- std::fill(bittab, std::end(bittab), static_cast<unsigned char>(0));
+ const unsigned char nul=0;
+ std::fill(bittab, std::end(bittab), nul);
std::fill(tagstk, std::end(tagstk), 0);
std::fill(nfa, std::end(nfa), '\0');
Clear();
@@ -643,7 +644,7 @@ const char *RESearch::Compile(const char *pattern, Sci::Position length, bool ca
if (tagi > 0 && tagstk[tagi] == n)
return badpat("Cyclical reference");
if (tagc > n) {
- *mp++ = static_cast<char>(REF);
+ *mp++ = REF;
*mp++ = static_cast<char>(n);
} else {
return badpat("Undetermined reference");
@@ -662,7 +663,7 @@ const char *RESearch::Compile(const char *pattern, Sci::Position length, bool ca
if (*sp == BOT)
return badpat("Null pattern inside \\(\\)");
if (tagi > 0) {
- *mp++ = static_cast<char>(EOT);
+ *mp++ = EOT;
*mp++ = static_cast<char>(tagstk[tagi--]);
} else {
return badpat("Unmatched \\)");
@@ -698,7 +699,7 @@ const char *RESearch::Compile(const char *pattern, Sci::Position length, bool ca
if (*sp == BOT)
return badpat("Null pattern inside ()");
if (tagi > 0) {
- *mp++ = static_cast<char>(EOT);
+ *mp++ = EOT;
*mp++ = static_cast<char>(tagstk[tagi--]);
} else {
return badpat("Unmatched )");