From 0f2203d8c0798038994fcb661376051a518f1190 Mon Sep 17 00:00:00 2001 From: vincentdarley Date: Wed, 9 Jun 2004 22:39:08 +0000 Subject: multiline text widget regexp search fix --- ChangeLog | 7 +++++++ generic/tkText.c | 4 ++-- tests/text.test | 31 ++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8ad0f5d..6f2e213 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-06-09 Vince Darley + + * generic/tkText.c: + * tests/text.test: fix to multi-line regexp search bugs in text + widget (reported against Alphatk editor, not on sf). + Addded 3 new tests. + 2004-06-09 Donal K. Fellows * generic/tkUndo.c (TkUndoSetDepth): Delete the unlinked element and diff --git a/generic/tkText.c b/generic/tkText.c index 01a09f9..fecbdb0 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.50 2004/06/04 10:51:18 vincentdarley Exp $ + * RCS: @(#) $Id: tkText.c,v 1.51 2004/06/09 22:39:08 vincentdarley Exp $ */ #include "default.h" @@ -4612,7 +4612,7 @@ SearchCore(interp, searchSpecPtr, patObj) */ if (!match || ((info.extendStart == info.matches[0].start) - && (info.matches[0].end == lastOffset))) { + && (info.matches[0].end == (lastOffset - firstOffset)))) { int extraLines = 1; int prevFullLine; /* diff --git a/tests/text.test b/tests/text.test index 2d0ee93..16a6083 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: text.test,v 1.29 2004/03/17 18:15:50 das Exp $ +# RCS: @(#) $Id: text.test,v 1.30 2004/06/09 22:39:08 vincentdarley Exp $ package require tcltest 2.1 eval tcltest::configure $argv @@ -2563,6 +2563,35 @@ test text-20.172 {TextSearchCmd, regexp search multi-line} {knownBug} { # Should match at 1.0 for a true greedy match } {1.0} +test text-20.173 {TextSearchCmd, regexp search multi-line} { + deleteWindows + pack [text .t2] + .t2 insert 1.0 "\naaaxxx\nyyy\n" + set res {} + lappend res [.t2 search -count c -regexp -- {x*\ny*} 2.0] $c + lappend res [.t2 search -count c -regexp -- {x*\ny*} 2.1] $c + set res +} {2.3 7 2.3 7} + +test text-20.174 {TextSearchCmd, regexp search multi-line} { + deleteWindows + pack [text .t2] + .t2 insert 1.0 "\naaa\n\n\n\n\nxxx\n" + set res {} + lappend res [.t2 search -count c -regexp -- {\n+} 2.0] $c + lappend res [.t2 search -count c -regexp -- {\n+} 2.1] $c + set res +} {2.3 5 2.3 5} + +test text-20.175 {TextSearchCmd, regexp search multi-line} { + deleteWindows + pack [text .t2] + .t2 insert 1.0 "\naaa\n\n\t \n\t\t\t \n\nxxx\n" + set res {} + lappend res [.t2 search -count c -regexp -- {(\n+(\t+ *)*)+} 2.0] $c + set res +} {2.3 13} + deleteWindows text .t2 -highlightthickness 0 -bd 0 -relief flat -padx 0 -width 100 pack .t2 -- cgit v0.12