diff options
author | nyamatongwe <unknown> | 2002-04-21 10:20:59 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2002-04-21 10:20:59 +0000 |
commit | 5ce0189a77f46696eaa1f3cc5dd0aff2bb5cabd4 (patch) | |
tree | 39857adc7906b22cb6629149b0ee36eb91f13e04 | |
parent | 58510c0fbafdcf5ceed956a208fc34a65cb55358 (diff) | |
download | scintilla-mirror-5ce0189a77f46696eaa1f3cc5dd0aff2bb5cabd4.tar.gz |
Some Win64 compatibility and size_t correctness.
-rw-r--r-- | include/SString.h | 2 | ||||
-rw-r--r-- | include/Scintilla.h | 5 | ||||
-rw-r--r-- | src/AutoComplete.cxx | 2 | ||||
-rw-r--r-- | src/Document.cxx | 9 | ||||
-rw-r--r-- | src/Document.h | 2 | ||||
-rw-r--r-- | src/Editor.cxx | 47 | ||||
-rw-r--r-- | src/Editor.h | 6 | ||||
-rw-r--r-- | src/PropSet.cxx | 22 | ||||
-rw-r--r-- | win32/ExternalLexer.cxx | 2 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 10 |
10 files changed, 57 insertions, 50 deletions
diff --git a/include/SString.h b/include/SString.h index 8ef3ede8e..d33d4c4fa 100644 --- a/include/SString.h +++ b/include/SString.h @@ -10,7 +10,7 @@ // These functions are implemented because each platform calls them something different. int CompareCaseInsensitive(const char *a, const char *b); -int CompareNCaseInsensitive(const char *a, const char *b, int len); +int CompareNCaseInsensitive(const char *a, const char *b, size_t len); bool EqualCaseInsensitive(const char *a, const char *b); // Define another string class. diff --git a/include/Scintilla.h b/include/Scintilla.h index 1d11642e1..4a043b5ff 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -21,8 +21,13 @@ int Scintilla_LinkLexers(); // Here should be placed typedefs for uptr_t, an unsigned integer type large enough to // hold a pointer and sptr_t, a signed integer large enough to hold a pointer. // May need to be changed for 64 bit platforms. +#ifdef __int3264 +typedef ULONG_PTR uptr_t; +typedef LONG_PTR sptr_t; +#else typedef unsigned long uptr_t; typedef long sptr_t; +#endif typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam); diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx index 48aaee38a..d971fa12a 100644 --- a/src/AutoComplete.cxx +++ b/src/AutoComplete.cxx @@ -118,7 +118,7 @@ void AutoComplete::Move(int delta) { } void AutoComplete::Select(const char *word) { - int lenWord = strlen(word); + size_t lenWord = strlen(word); int location = -1; const int maxItemLen=1000; char item[maxItemLen]; diff --git a/src/Document.cxx b/src/Document.cxx index def80c49c..22cb0c2b0 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -512,15 +512,16 @@ bool Document::InsertString(int position, const char *s) { } // Insert a string with a length -bool Document::InsertString(int position, const char *s, int insertLength) { +bool Document::InsertString(int position, const char *s, size_t insertLength) { bool changed = false; char *sWithStyle = new char[insertLength * 2]; if (sWithStyle) { - for (int i = 0; i < insertLength; i++) { + for (size_t i = 0; i < insertLength; i++) { sWithStyle[i*2] = s[i]; sWithStyle[i*2 + 1] = 0; } - changed = InsertStyledString(position*2, sWithStyle, insertLength*2); + changed = InsertStyledString(position*2, sWithStyle, + static_cast<int>(insertLength*2)); delete []sWithStyle; } return changed; @@ -928,7 +929,7 @@ long Document::FindText(int minPos, int maxPos, const char *s, // Compute actual search ranges needed int lengthFind = *length; if (lengthFind == -1) - lengthFind = strlen(s); + lengthFind = static_cast<int>(strlen(s)); int endSearch = endPos; if (startPos <= endPos) { endSearch = endPos - lengthFind + 1; diff --git a/src/Document.h b/src/Document.h index 9743583fe..34c49a5a6 100644 --- a/src/Document.h +++ b/src/Document.h @@ -160,7 +160,7 @@ public: bool InsertChar(int pos, char ch); bool InsertString(int position, const char *s); - bool InsertString(int position, const char *s, int insertLength); + bool InsertString(int position, const char *s, size_t insertLength); void ChangeChar(int pos, char ch); void DelChar(int pos); void DelCharBack(int pos); diff --git a/src/Editor.cxx b/src/Editor.cxx index 133e62b40..ef813fc05 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2468,7 +2468,7 @@ void Editor::NotifyChar(int ch) { char txt[2]; txt[0] = static_cast<char>(ch); txt[1] = '\0'; - NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<long>(txt)); + NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(txt)); } } @@ -3260,9 +3260,9 @@ void Editor::Indent(bool forwards) { * @return The position of the found text, -1 if not found. */ long Editor::FindText( - unsigned long wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, + uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, ///< @c SCFIND_WORDSTART or @c SCFIND_REGEXP. - long lParam) { ///< @c TextToFind structure: The text to search for in the given range. + sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range. TextToFind *ft = reinterpret_cast<TextToFind *>(lParam); int lengthFound = strlen(ft->lpstrText); @@ -3301,9 +3301,9 @@ void Editor::SearchAnchor() { */ long Editor::SearchText( unsigned int iMessage, ///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV. - unsigned long wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, + uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, ///< @c SCFIND_WORDSTART or @c SCFIND_REGEXP. - long lParam) { ///< The text to search for. + sptr_t lParam) { ///< The text to search for. const char *txt = reinterpret_cast<char *>(lParam); int pos; @@ -4116,6 +4116,10 @@ static bool ValidMargin(unsigned long wParam) { return wParam < ViewStyle::margins; } +static char *CharPtrFromSPtr(sptr_t lParam) { + return reinterpret_cast<char *>(lParam); +} + sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { //Platform::DebugPrintf("S start wnd proc %d %d %d\n",iMessage, wParam, lParam); @@ -4129,7 +4133,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { { if (lParam == 0) return 0; - char *ptr = reinterpret_cast<char *>(lParam); + char *ptr = CharPtrFromSPtr(lParam); unsigned int iChar = 0; for (; iChar < wParam - 1; iChar++) ptr[iChar] = pdoc->CharAt(iChar); @@ -4143,7 +4147,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return 0; pdoc->DeleteChars(0, pdoc->Length()); SetEmptySelection(0); - pdoc->InsertString(0, reinterpret_cast<char *>(lParam)); + pdoc->InsertString(0, CharPtrFromSPtr(lParam)); return 1; } @@ -4191,7 +4195,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { } int lineStart = pdoc->LineStart(wParam); int lineEnd = pdoc->LineStart(wParam + 1); - char *ptr = reinterpret_cast<char *>(lParam); + char *ptr = CharPtrFromSPtr(lParam); int iPlace = 0; for (int iChar = lineStart; iChar < lineEnd; iChar++) { ptr[iPlace++] = pdoc->CharAt(iChar); @@ -4226,7 +4230,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return 0; SelectionText selectedText; CopySelectionRange(&selectedText); - char *ptr = reinterpret_cast<char *>(lParam); + char *ptr = CharPtrFromSPtr(lParam); int iChar = 0; if (selectedText.len) { for (; iChar < selectedText.len; iChar++) @@ -4266,7 +4270,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return 0; pdoc->BeginUndoAction(); ClearSelection(); - char *replacement = reinterpret_cast<char *>(lParam); + char *replacement = CharPtrFromSPtr(lParam); pdoc->InsertString(currentPos, replacement); pdoc->EndUndoAction(); SetEmptySelection(currentPos + strlen(replacement)); @@ -4290,15 +4294,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_REPLACETARGET: PLATFORM_ASSERT(lParam); - return ReplaceTarget(false, reinterpret_cast<char *>(lParam), wParam); + return ReplaceTarget(false, CharPtrFromSPtr(lParam), wParam); case SCI_REPLACETARGETRE: PLATFORM_ASSERT(lParam); - return ReplaceTarget(true, reinterpret_cast<char *>(lParam), wParam); + return ReplaceTarget(true, CharPtrFromSPtr(lParam), wParam); case SCI_SEARCHINTARGET: PLATFORM_ASSERT(lParam); - return SearchInTarget(reinterpret_cast<char *>(lParam), wParam); + return SearchInTarget(CharPtrFromSPtr(lParam), wParam); case SCI_SETSEARCHFLAGS: searchFlags = wParam; @@ -4398,7 +4402,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_ADDTEXT: { if (lParam == 0) return 0; - pdoc->InsertString(CurrentPosition(), reinterpret_cast<char *>(lParam), wParam); + pdoc->InsertString(CurrentPosition(), CharPtrFromSPtr(lParam), wParam); SetEmptySelection(currentPos + wParam); return 0; } @@ -4406,7 +4410,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_ADDSTYLEDTEXT: { if (lParam == 0) return 0; - pdoc->InsertStyledString(CurrentPosition() * 2, reinterpret_cast<char *>(lParam), wParam); + pdoc->InsertStyledString(CurrentPosition() * 2, CharPtrFromSPtr(lParam), wParam); SetEmptySelection(currentPos + wParam / 2); return 0; } @@ -4418,13 +4422,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (static_cast<short>(wParam) == -1) insertPos = CurrentPosition(); int newCurrent = CurrentPosition(); - int newAnchor = anchor; - char *sz = reinterpret_cast<char *>(lParam); + char *sz = CharPtrFromSPtr(lParam); pdoc->InsertString(insertPos, sz); if (newCurrent > insertPos) newCurrent += strlen(sz); - if (newAnchor > insertPos) - newAnchor += strlen(sz); SetEmptySelection(newCurrent); return 0; } @@ -4587,7 +4588,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { int lineCurrentPos = pdoc->LineFromPosition(currentPos); int lineStart = pdoc->LineStart(lineCurrentPos); unsigned int lineEnd = pdoc->LineStart(lineCurrentPos + 1); - char *ptr = reinterpret_cast<char *>(lParam); + char *ptr = CharPtrFromSPtr(lParam); unsigned int iPlace = 0; for (unsigned int iChar = lineStart; iChar < lineEnd && iPlace < wParam - 1; iChar++) { ptr[iPlace++] = pdoc->CharAt(iChar); @@ -4617,7 +4618,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETSTYLINGEX: // Specify a complete styling buffer if (lParam == 0) return 0; - pdoc->SetStyles(wParam, reinterpret_cast<char *>(lParam)); + pdoc->SetStyles(wParam, CharPtrFromSPtr(lParam)); break; case SCI_SETBUFFEREDDRAW: @@ -4722,7 +4723,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_TEXTWIDTH: PLATFORM_ASSERT((wParam >= 0) && (wParam <= STYLE_MAX)); PLATFORM_ASSERT(lParam); - return TextWidth(wParam, reinterpret_cast<char *>(lParam)); + return TextWidth(wParam, CharPtrFromSPtr(lParam)); case SCI_SETENDATLASTLINE: PLATFORM_ASSERT((wParam == 0) || (wParam ==1)); @@ -4935,7 +4936,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (lParam == 0) return 0; if (wParam <= STYLE_MAX) { - vs.SetStyleFontName(wParam, reinterpret_cast<const char *>(lParam)); + vs.SetStyleFontName(wParam, CharPtrFromSPtr(lParam)); InvalidateStyleRedraw(); } break; diff --git a/src/Editor.h b/src/Editor.h index a86008456..9eba943a6 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -394,7 +394,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void NotifyModified(Document *document, DocModification mh, void *userData); void NotifyDeleted(Document *document, void *userData); void NotifyStyleNeeded(Document *doc, void *userData, int endPos); - void NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long lParam); + void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam); void PageMove(int direction, bool extend=false); void ChangeCaseOfSelection(bool makeUpperCase); @@ -411,9 +411,9 @@ protected: // ScintillaBase subclass needs access to much of Editor void Indent(bool forwards); - long FindText(unsigned long wParam, long lParam); + long FindText(uptr_t wParam, sptr_t lParam); void SearchAnchor(); - long SearchText(unsigned int iMessage, unsigned long wParam, long lParam); + long SearchText(unsigned int iMessage, uptr_t wParam, sptr_t lParam); long SearchInTarget(const char *text, int length); void GoToLine(int lineNo); diff --git a/src/PropSet.cxx b/src/PropSet.cxx index ba938947f..fe80c1210 100644 --- a/src/PropSet.cxx +++ b/src/PropSet.cxx @@ -45,7 +45,7 @@ int CompareCaseInsensitive(const char *a, const char *b) { return *a - *b; } -int CompareNCaseInsensitive(const char *a, const char *b, int len) { +int CompareNCaseInsensitive(const char *a, const char *b, size_t len) { while (*a && *b && len) { if (*a != *b) { char upperA = MakeUpperCase(*a); @@ -68,7 +68,7 @@ bool EqualCaseInsensitive(const char *a, const char *b) { return 0 == CompareCaseInsensitive(a, b); } -inline unsigned int HashString(const char *s, int len) { +inline unsigned int HashString(const char *s, size_t len) { unsigned int ret = 0; while (len--) { ret <<= 4; @@ -93,9 +93,9 @@ void PropSet::Set(const char *key, const char *val, int lenKey, int lenVal) { if (!*key) // Empty keys are not supported return; if (lenKey == -1) - lenKey = strlen(key); + lenKey = static_cast<int>(strlen(key)); if (lenVal == -1) - lenVal = strlen(val); + lenVal = static_cast<int>(strlen(val)); unsigned int hash = HashString(key, lenKey); for (Property *p = props[hash % hashRoots]; p; p = p->next) { if ((hash == p->hash) && @@ -187,7 +187,7 @@ SString PropSet::Expand(const char *withVars) { int lenvar = cpendvar - cpvar - 2; // Subtract the $() char *var = StringDup(cpvar + 2, lenvar); SString val = GetExpanded(var); - int newlenbase = strlen(base) + val.length() - lenvar; + size_t newlenbase = strlen(base) + val.length() - lenvar; char *newbase = new char[newlenbase]; strncpy(newbase, base, cpvar - base); strcpy(newbase + (cpvar - base), val.c_str()); @@ -224,8 +224,8 @@ bool isprefix(const char *target, const char *prefix) { } static bool IsSuffixCaseInsensitive(const char *target, const char *suffix) { - int lentarget = strlen(target); - int lensuffix = strlen(suffix); + size_t lentarget = strlen(target); + size_t lensuffix = strlen(suffix); if (lensuffix > lentarget) return false; for (int i = lensuffix - 1; i >= 0; i--) { @@ -306,7 +306,7 @@ SString PropSet::GetNewExpand(const char *keybase, const char *filename) { int lenvar = cpendvar - cpvar - 2; // Subtract the $() char *var = StringDup(cpvar + 2, lenvar); SString val = GetWild(var, filename); - int newlenbase = strlen(base) + val.length() - lenvar; + size_t newlenbase = strlen(base) + val.length() - lenvar; char *newbase = new char[newlenbase]; strncpy(newbase, base, cpvar - base); strcpy(newbase + (cpvar - base), val.c_str()); @@ -340,7 +340,7 @@ void PropSet::Clear() { } char *PropSet::ToString() { - unsigned int len=0; + size_t len=0; for (int r = 0; r < hashRoots; r++) { for (Property *p = props[r]; p; p = p->next) { len += strlen(p->key) + 1; @@ -435,8 +435,8 @@ static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = fa if (keywords) { words = 0; prev = '\0'; - int slen = strlen(wordlist); - for (int k = 0; k < slen; k++) { + size_t slen = strlen(wordlist); + for (size_t k = 0; k < slen; k++) { if (!iswordsep(wordlist[k], onlyLineEnds)) { if (!prev) { keywords[words] = &wordlist[k]; diff --git a/win32/ExternalLexer.cxx b/win32/ExternalLexer.cxx index b93cca8f4..593bb315a 100644 --- a/win32/ExternalLexer.cxx +++ b/win32/ExternalLexer.cxx @@ -230,7 +230,7 @@ void LexerManager::EnumerateLexers() { int i = FindLastSlash(path); if (i == -1) - i = strlen(path); + i = static_cast<int>(strlen(path)); SString sPath(path, 0, i); diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 9cf7ac991..184bfb2bc 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -174,7 +174,7 @@ class ScintillaWin : HWND hWnd, UINT iMessage, WPARAM wParam, sptr_t lParam); virtual void StartDrag(); - sptr_t WndPaint(unsigned long wParam); + sptr_t WndPaint(uptr_t wParam); sptr_t HandleComposition(uptr_t wParam, sptr_t lParam); virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); @@ -356,14 +356,14 @@ static int KeyTranslate(int keyIn) { } } -LRESULT ScintillaWin::WndPaint(unsigned long wParam) { +LRESULT ScintillaWin::WndPaint(uptr_t wParam) { //ElapsedTime et; // Redirect assertions to debug output and save current state bool assertsPopup = Platform::ShowAssertionPopUps(false); paintState = painting; PAINTSTRUCT ps; - PAINTSTRUCT* pps; + PAINTSTRUCT *pps; bool IsOcxCtrl = (wParam != 0); // if wParam != 0, it contains // a PAINSTRUCT* from the OCX @@ -677,7 +677,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam break; case WM_PALETTECHANGED: - if (wParam != reinterpret_cast<unsigned int>(MainHWND())) { + if (wParam != reinterpret_cast<uptr_t>(MainHWND())) { //Platform::DebugPrintf("** Palette Changed\n"); RealizeWindowPalette(true); } @@ -838,7 +838,7 @@ void ScintillaWin::SetTicking(bool on) { if (timer.ticking) { timer.tickerID = reinterpret_cast<TickerID>(::SetTimer(MainHWND(), 1, timer.tickSize, NULL)); } else { - ::KillTimer(MainHWND(), reinterpret_cast<UINT>(timer.tickerID)); + ::KillTimer(MainHWND(), reinterpret_cast<uptr_t>(timer.tickerID)); timer.tickerID = 0; } } |