diff options
author | nyamatongwe <unknown> | 2004-02-29 08:51:54 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2004-02-29 08:51:54 +0000 |
commit | 845c14b1972e448408109b30a9a9422cac092f16 (patch) | |
tree | e3491653c70c455dfe50b532cd0c025685f4e8d4 /src | |
parent | fec08d803302905ea166fb2450a130e9891e85c3 (diff) | |
download | scintilla-mirror-845c14b1972e448408109b30a9a9422cac092f16.tar.gz |
Patch from Bruce to return required allocation size when a NULL
pointer is used as a stringresult argument.
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index ba35bc5d9..3f30ba3bf 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -5407,7 +5407,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETTEXT: { if (lParam == 0) - return 0; + return pdoc->Length() + 1; if (wParam == 0) return 0; char *ptr = CharPtrFromSPtr(lParam); @@ -5475,11 +5475,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return topLine; case SCI_GETLINE: { // Risk of overwriting the end of the buffer - if (lParam == 0) { - return 0; - } int lineStart = pdoc->LineStart(wParam); int lineEnd = pdoc->LineStart(wParam + 1); + if (lParam == 0) { + return lineEnd - lineStart; + } char *ptr = CharPtrFromSPtr(lParam); int iPlace = 0; for (int iChar = lineStart; iChar < lineEnd; iChar++) { @@ -5511,8 +5511,23 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETSELTEXT: { - if (lParam == 0) - return 0; + if (lParam == 0) { + if (selType == selStream) { + return 1 + SelectionEnd() - SelectionStart(); + } else { + // TODO: why is selLines handled the slow way? + int size = 0; + int extraCharsPerLine = 0; + if (selType != selLines) + extraCharsPerLine = (pdoc->eolMode == SC_EOL_CRLF) ? 2 : 1; + SelectionLineIterator lineIterator(this); + while (lineIterator.Iterate()) { + size += lineIterator.endPos + extraCharsPerLine - lineIterator.startPos; + } + + return 1 + size; + } + } SelectionText selectedText; CopySelectionRange(&selectedText); char *ptr = CharPtrFromSPtr(lParam); @@ -5913,12 +5928,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETCURLINE: { - if (lParam == 0) { - return 0; - } int lineCurrentPos = pdoc->LineFromPosition(currentPos); int lineStart = pdoc->LineStart(lineCurrentPos); unsigned int lineEnd = pdoc->LineStart(lineCurrentPos + 1); + if (lParam == 0) { + return 1 + lineEnd - lineStart; + } char *ptr = CharPtrFromSPtr(lParam); unsigned int iPlace = 0; for (unsigned int iChar = lineStart; iChar < lineEnd && iPlace < wParam - 1; iChar++) { |