From 7a16c4ecf67b9294f4e677a5d6cfb995eb9b6cd6 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 22 Nov 2012 21:12:45 +0000 Subject: [Bug 3588824]: bug in image index handling for weird image names --- ChangeLog | 5 +++++ generic/tkTextIndex.c | 15 ++++++++++++--- tests/textIndex.test | 12 ++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b95588b..8365fc5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-11-?? Francois Vogel + + * generic/tkTextIndex.c: [Bug 3588824]: bug in image index handling + * tests/textIndex.test: for weird image names + 2012-11-13 Jan Nijtmans * win/tkWinTest.c: [Bug 3585396]: winDialog.test requires user diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 7cfeaea..714a47d 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -328,9 +328,10 @@ TkTextGetIndex(interp, textPtr, string, indexPtr) /* *--------------------------------------------------------------------- * Stage 1: check to see if the index consists of nothing but a mark - * name. We do this check now even though it's also done later, in - * order to allow mark names that include funny characters such as - * spaces or "+1c". + * name, an embedded window or an embedded image. We do this check + * now even though it's also done later, in order to allow mark names, + * embedded window names or image names that include funny characters + * such as spaces or "+1c". *--------------------------------------------------------------------- */ @@ -338,6 +339,14 @@ TkTextGetIndex(interp, textPtr, string, indexPtr) return TCL_OK; } + if (TkTextWindowIndex(textPtr, string, indexPtr) != 0) { + return TCL_OK; + } + + if (TkTextImageIndex(textPtr, string, indexPtr) != 0) { + return TCL_OK; + } + /* *------------------------------------------------ * Stage 2: start again by parsing the base index. diff --git a/tests/textIndex.test b/tests/textIndex.test index 0337fca..1837e7d 100644 --- a/tests/textIndex.test +++ b/tests/textIndex.test @@ -219,9 +219,21 @@ set weirdTag "funny . +- 22.1\n\t{" set weirdMark "asdf \n{-+ 66.2\t" .t mark set $weirdMark 4.0 .t tag config y -relief raised +set weirdImage "foo-1" +.t image create 2.0 -image [image create photo $weirdImage] test textIndex-3.1 {TkTextGetIndex, weird mark names} { list [catch {.t index $weirdMark} msg] $msg } {0 4.0} +test textIndex-3.2 {TkTextGetIndex, weird mark names} knownBug { + list [catch {.t index "$weirdMark -1char"} msg] $msg +} {0 4.0} +test textIndex-3.3 {TkTextGetIndex, weird image names} { + list [catch {.t index $weirdImage} msg] $msg +} {0 2.0} +test textIndex-3.4 {TkTextGetIndex, weird image names} knownBug { + list [catch {.t index "$weirdImage -1char"} msg] $msg +} {0 2.0} +.t delete 2.0 ; # remove the weirdImage test textIndex-4.1 {TkTextGetIndex, tags} { list [catch {.t index x.first} msg] $msg -- cgit v0.12 From 19fbc8aec9cd206f6df2611aa7a553599f3e5931 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 24 Nov 2012 08:23:27 +0000 Subject: Added tests for weird embedded windows names --- tests/textIndex.test | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/textIndex.test b/tests/textIndex.test index 1837e7d..885ed8e 100644 --- a/tests/textIndex.test +++ b/tests/textIndex.test @@ -220,20 +220,30 @@ set weirdMark "asdf \n{-+ 66.2\t" .t mark set $weirdMark 4.0 .t tag config y -relief raised set weirdImage "foo-1" -.t image create 2.0 -image [image create photo $weirdImage] +.t image create 2.1 -image [image create photo $weirdImage] +set weirdEmbWin ".t.bar-1" +entry $weirdEmbWin +.t window create 3.1 -window $weirdEmbWin test textIndex-3.1 {TkTextGetIndex, weird mark names} { list [catch {.t index $weirdMark} msg] $msg } {0 4.0} test textIndex-3.2 {TkTextGetIndex, weird mark names} knownBug { list [catch {.t index "$weirdMark -1char"} msg] $msg } {0 4.0} -test textIndex-3.3 {TkTextGetIndex, weird image names} { +test textIndex-3.3 {TkTextGetIndex, weird embedded window names} { + list [catch {.t index $weirdEmbWin} msg] $msg +} {0 3.1} +test textIndex-3.4 {TkTextGetIndex, weird embedded window names} knownBug { + list [catch {.t index "$weirdEmbWin -1char"} msg] $msg +} {0 3.0} +test textIndex-3.5 {TkTextGetIndex, weird image names} { list [catch {.t index $weirdImage} msg] $msg -} {0 2.0} -test textIndex-3.4 {TkTextGetIndex, weird image names} knownBug { +} {0 2.1} +test textIndex-3.6 {TkTextGetIndex, weird image names} knownBug { list [catch {.t index "$weirdImage -1char"} msg] $msg } {0 2.0} -.t delete 2.0 ; # remove the weirdImage +.t delete 3.1 ; # remove the weirdEmbWin +.t delete 2.1 ; # remove the weirdImage test textIndex-4.1 {TkTextGetIndex, tags} { list [catch {.t index x.first} msg] $msg -- cgit v0.12 From ebdb1af200a5bdf041a872601852a6b93ae20900 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 3 Dec 2012 01:24:12 +0000 Subject: Fixed commit date --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8365fc5..a963224 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2012-11-?? Francois Vogel +2012-12-03 Francois Vogel * generic/tkTextIndex.c: [Bug 3588824]: bug in image index handling * tests/textIndex.test: for weird image names -- cgit v0.12