Tk Source Code

View Ticket
Login
Ticket UUID: 977c61ea081c9b4e80ad014adf873ce13b9778d9
Title: text widget test suite errors with Tcl9
Type: Bug Version: revised_text
Submitter: fvogel Created on: 2021-04-21 18:50:49
Subsystem: 18. [text] Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2021-04-24 13:32:19
Resolution: Fixed Closed By: fvogel
    Closed on: 2021-04-24 13:32:19
Description:

With Tcl 9 ('main' branch), but not with Tcl 8.7, the test suite for branch 'revised_text' in Tk outputs three errors that do not happen in other environments:

==== text-22.126 TextSearchCmd, wrapping and limits FAILED
==== Contents of test case:

    pack [text .t]
    .t insert end "if (stringPtr->uallocated > 0) \{x"
    .t search -backwards -regexp -- "\[\]\")\}\[(\{\]" "1.32" 1.0

---- Result was:
1.3
---- Result should have been (exact matching):
1.31
==== text-22.126 FAILED

==== text-22.128 TextSearchCmd, wrapping and limits FAILED
==== Contents of test case:

    pack [text .t]
    .t insert end "if (stringPtr->uallocated > 0) \{x"
    .t search -backwards -all -regexp -- "\[\]\")\}\[(\{\]" "1.32" 1.0

---- Result was:
1.3
---- Result should have been (exact matching):
1.31 1.29 1.3
==== text-22.128 FAILED

==== text-22.129 TextSearchCmd, wrapping and limits FAILED
==== Contents of test case:

    pack [text .t]
    .t insert end "if (stringPtr->uallocated > 0) \{x"
    .t search -all -regexp -- "\[\]\")\}\[(\{\]" 1.0 "1.0 lineend"

---- Result was:
1.3
---- Result should have been (exact matching):
1.3 1.29 1.31
==== text-22.129 FAILED

This does not happen when Tk 'revised_text' branch is linked to Tcl 8.7 ('core-8-branch' branch).

I can see this on Window 10 and this is also demonstrated on Linux on GitHub Actions.

User Comments: fvogel added on 2021-04-24 13:32:19:

> build now fails for Windows on gcc for a different reason, see https://github.com/tcltk/tk/runs/2425614537?check_suite_focus=true

Also addressed, see [870e2d29].


fvogel added on 2021-04-24 12:45:52:

> generic\tkTextBTree.c(7152): error C2065: 'prevPtr' undeclared identifier

Fixed by [2338b04507].


fvogel added on 2021-04-24 08:28:04:

This problem ('prevPtr' undeclared identifier) is also revealed by GitHub for Linux with clang, see https://github.com/tcltk/tk/runs/2425614655?check_suite_focus=true

Also, the build now fails for Windows on gcc for a different reason, see https://github.com/tcltk/tk/runs/2425614537?check_suite_focus=true


fvogel added on 2021-04-23 18:12:41:

Your commit [e48e7578] results in:

\..\generic\tkTextBTree.c(7152): error C2065: 'prevPtr' undeclared identifier

for me (MSVC), sorry.


jan.nijtmans added on 2021-04-23 15:40:11:

Merged into the branch, so closing.


fvogel added on 2021-04-21 19:23:25:

Using the short script below, debug shows that the two expected matches are correctly found here by Tcl_RegExpExecObj(). The 'info' structure at line 10796 has the correct information filled in by Tcl_RegExpGetInfo().

The problem is that this test evaluates to false for the second match while we expect it to evaluate to true in order for the second match to be recorded.

And this is because (matchOffset + matchLength - firstOffset + 1) evaluates to -1, which is then cast into (TkSizeT), which is 'int' in Tcl 8 (therefore this if fine) but which is a 'size_t' in Tcl9 and this is... unsigned!

The fix consists in reverting [626b0932]. This commit does not seem to be needed (or not anymore). See [686682a46c].


fvogel added on 2021-04-21 18:54:46:

This problem can be shown by the following small script to be run with the revised_text branch and either Tcl 8.7 (core-8-branch) or Tcl 9 (main branch):

package require Tk
pack [text .t]
.t insert end "(a(\n( a("
# correct result expected on next line: 1.0 1.2  (obtained)
.t search -all -regexp -- {\(} 1.0 "1.0 lineend"
# correct result expected on next line: 2.0 2.3  (obtained with Tcl8.7)
#   but wrong with Tcl9  : 2.0
.t search -all -regexp -- {\(} 2.0 "2.0 lineend"