From e1a93f46d5d7851a90764844059b286ca738dcd6 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 24 Jan 2002 22:47:42 +0000 Subject: [PATCH] Ensure that endPos > startPos in a couple methods git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13785 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/stc/gen_iface.py | 15 +++++++++++++++ contrib/src/stc/stc.cpp | 15 +++++++++++++++ src/stc/gen_iface.py | 15 +++++++++++++++ src/stc/stc.cpp | 15 +++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/contrib/src/stc/gen_iface.py b/contrib/src/stc/gen_iface.py index 04303b8202..4c7d15bcca 100644 --- a/contrib/src/stc/gen_iface.py +++ b/contrib/src/stc/gen_iface.py @@ -86,6 +86,11 @@ methodOverrideMap = { '''wxString %s(int startPos, int endPos) { wxString text; + if (endPos < startPos) { + int temp = startPos; + startPos = endPos; + endPos = temp; + } int len = endPos - startPos; if (!len) return ""; TextRange tr; @@ -266,6 +271,11 @@ methodOverrideMap = { wxRect pageRect) { RangeToFormat fr; + if (endPos < startPos) { + int temp = startPos; + startPos = endPos; + endPos = temp; + } fr.hdc = draw; fr.hdcTarget = target; fr.rc.top = renderRect.GetTop(); @@ -324,6 +334,11 @@ methodOverrideMap = { '''wxString %s(int startPos, int endPos) { wxString text; + if (endPos < startPos) { + int temp = startPos; + startPos = endPos; + endPos = temp; + } int len = endPos - startPos; if (!len) return ""; char* buff = text.GetWriteBuf(len); diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index b2da830400..520ebd5cb9 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -276,6 +276,11 @@ void wxStyledTextCtrl::SetSavePoint() { // Retrieve a buffer of cells. wxString wxStyledTextCtrl::GetStyledText(int startPos, int endPos) { wxString text; + if (endPos < startPos) { + int temp = startPos; + startPos = endPos; + endPos = temp; + } int len = endPos - startPos; if (!len) return ""; TextRange tr; @@ -973,6 +978,11 @@ int wxStyledTextCtrl::FindText(int minPos, int maxPos, wxRect pageRect) { RangeToFormat fr; + if (endPos < startPos) { + int temp = startPos; + startPos = endPos; + endPos = temp; + } fr.hdc = draw; fr.hdcTarget = target; fr.rc.top = renderRect.GetTop(); @@ -1061,6 +1071,11 @@ wxString wxStyledTextCtrl::GetSelectedText() { // Retrieve a range of text. wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) { wxString text; + if (endPos < startPos) { + int temp = startPos; + startPos = endPos; + endPos = temp; + } int len = endPos - startPos; if (!len) return ""; char* buff = text.GetWriteBuf(len); diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 04303b8202..4c7d15bcca 100644 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -86,6 +86,11 @@ methodOverrideMap = { '''wxString %s(int startPos, int endPos) { wxString text; + if (endPos < startPos) { + int temp = startPos; + startPos = endPos; + endPos = temp; + } int len = endPos - startPos; if (!len) return ""; TextRange tr; @@ -266,6 +271,11 @@ methodOverrideMap = { wxRect pageRect) { RangeToFormat fr; + if (endPos < startPos) { + int temp = startPos; + startPos = endPos; + endPos = temp; + } fr.hdc = draw; fr.hdcTarget = target; fr.rc.top = renderRect.GetTop(); @@ -324,6 +334,11 @@ methodOverrideMap = { '''wxString %s(int startPos, int endPos) { wxString text; + if (endPos < startPos) { + int temp = startPos; + startPos = endPos; + endPos = temp; + } int len = endPos - startPos; if (!len) return ""; char* buff = text.GetWriteBuf(len); diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index b2da830400..520ebd5cb9 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -276,6 +276,11 @@ void wxStyledTextCtrl::SetSavePoint() { // Retrieve a buffer of cells. wxString wxStyledTextCtrl::GetStyledText(int startPos, int endPos) { wxString text; + if (endPos < startPos) { + int temp = startPos; + startPos = endPos; + endPos = temp; + } int len = endPos - startPos; if (!len) return ""; TextRange tr; @@ -973,6 +978,11 @@ int wxStyledTextCtrl::FindText(int minPos, int maxPos, wxRect pageRect) { RangeToFormat fr; + if (endPos < startPos) { + int temp = startPos; + startPos = endPos; + endPos = temp; + } fr.hdc = draw; fr.hdcTarget = target; fr.rc.top = renderRect.GetTop(); @@ -1061,6 +1071,11 @@ wxString wxStyledTextCtrl::GetSelectedText() { // Retrieve a range of text. wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) { wxString text; + if (endPos < startPos) { + int temp = startPos; + startPos = endPos; + endPos = temp; + } int len = endPos - startPos; if (!len) return ""; char* buff = text.GetWriteBuf(len); -- 2.45.2