summaryrefslogtreecommitdiffstats
path: root/generic/tkText.c
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2004-09-23 14:56:35 (GMT)
committervincentdarley <vincentdarley>2004-09-23 14:56:35 (GMT)
commit48109a72bd6e37cbc948f52c0b9e1c222b8c25b7 (patch)
tree988d0d18dbc1fa77612fcdb7e3ca8fb110c77785 /generic/tkText.c
parent9cb039ee07a2ebc764e1a616b17a34f9ea6283f0 (diff)
downloadtk-48109a72bd6e37cbc948f52c0b9e1c222b8c25b7.zip
tk-48109a72bd6e37cbc948f52c0b9e1c222b8c25b7.tar.gz
tk-48109a72bd6e37cbc948f52c0b9e1c222b8c25b7.tar.bz2
text widget search fix
Diffstat (limited to 'generic/tkText.c')
-rw-r--r--generic/tkText.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index f8a1abd..eb7beb7 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkText.c,v 1.53 2004/09/10 13:42:45 rmax Exp $
+ * RCS: @(#) $Id: tkText.c,v 1.54 2004/09/23 14:57:03 vincentdarley Exp $
*/
#include "default.h"
@@ -4923,6 +4923,25 @@ SearchPerform(interp, searchSpecPtr, patObj, fromPtr, toPtr)
* Find the optional end location, similarly.
*/
if (toPtr != NULL) {
+ CONST TkTextIndex *indexToPtr, *indexFromPtr;
+ TkText *textPtr = (TkText*)(searchSpecPtr->clientData);
+
+ indexToPtr = TkTextGetIndexFromObj(interp, textPtr, toPtr);
+ if (indexToPtr == NULL) {
+ return TCL_ERROR;
+ }
+ indexFromPtr = TkTextGetIndexFromObj(interp, textPtr, fromPtr);
+ /*
+ * Check for any empty search range here. It might be better
+ * in the future to embed that in SearchCore (whose default
+ * behaviour is to wrap when given a negative search range).
+ */
+ if (searchSpecPtr->backwards) {
+ if (TkTextIndexCmp(indexFromPtr, indexToPtr) == -1) return TCL_OK;
+ } else {
+ if (TkTextIndexCmp(indexFromPtr, indexToPtr) == 1) return TCL_OK;
+ }
+
if ((*searchSpecPtr->lineIndexProc)(interp, toPtr, searchSpecPtr,
&searchSpecPtr->stopLine,
&searchSpecPtr->stopOffset) != TCL_OK) {