Tk Source Code

Check-in [797038b8]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed bug 991, ".t index end-2c"
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-1-branch-old
Files: files | file ages | folders
SHA1: 797038b84af6336230548437c0d3bbacda9fbb41
User & Date: redman 1999-03-27 02:31:39
Context
1999-03-29
23:50
Fix in tkTextIndex.c for end-2c for text widget add command. check-in: 292bd13d user: redman tags: core-8-1-branch-old
1999-03-27
02:31
Fixed bug 991, ".t index end-2c" check-in: 797038b8 user: redman tags: core-8-1-branch-old
02:16
add comment for change to generic/tkConsole.c check-in: a67e2b55 user: redman tags: core-8-1-branch-old
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.

1
2





3
4
5
6
7
8
9
1999-03-26    <[email protected]>






	* generic/tkConsole.c: Copy static strings into a Tcl_DString
	before passing to Tcl_Eval, in case the compiler puts static
	strings into read-only memory.

1999-03-26    <[email protected]>

        * unix/configure.in:

>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
1999-03-26    <[email protected]>

	* generic/tkTextIndex.c:
	* tests/testIndex.test: Avoid looking past the beginning of the
	array storing data for the text widget (.t index end-2c).  Added
	test case to check for the bug.  [Bug 991]
	
	* generic/tkConsole.c: Copy static strings into a Tcl_DString
	before passing to Tcl_Eval, in case the compiler puts static
	strings into read-only memory.

1999-03-26    <[email protected]>

        * unix/configure.in:

Changes to generic/tkTextIndex.c.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
 *
 * Copyright (c) 1992-1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkTextIndex.c,v 1.1.4.2 1998/09/30 02:17:25 stanton Exp $
 */

#include "default.h"
#include "tkPort.h"
#include "tkInt.h"
#include "tkText.h"

................................................................................
{
    TkTextSegment *segPtr;
    int numBytes, charIndex;

    numBytes = indexPtr->byteIndex;
    charIndex = 0;
    for (segPtr = indexPtr->linePtr->segPtr; ; segPtr = segPtr->nextPtr) {
	if (numBytes < segPtr->size) {
	    break;
	}
	if (segPtr->typePtr == &tkTextCharType) {
	    charIndex += Tcl_NumUtfChars(segPtr->body.chars, segPtr->size);
	} else {
	    charIndex += segPtr->size;
	}






|







 







|







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
 *
 * Copyright (c) 1992-1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkTextIndex.c,v 1.1.4.3 1999/03/27 02:31:39 redman Exp $
 */

#include "default.h"
#include "tkPort.h"
#include "tkInt.h"
#include "tkText.h"

................................................................................
{
    TkTextSegment *segPtr;
    int numBytes, charIndex;

    numBytes = indexPtr->byteIndex;
    charIndex = 0;
    for (segPtr = indexPtr->linePtr->segPtr; ; segPtr = segPtr->nextPtr) {
	if (numBytes <= segPtr->size) {
	    break;
	}
	if (segPtr->typePtr == &tkTextCharType) {
	    charIndex += Tcl_NumUtfChars(segPtr->body.chars, segPtr->size);
	} else {
	    charIndex += segPtr->size;
	}

Changes to tests/textIndex.test.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
635
636
637
638
639
640
641











642
643
644
645
646
647
648
# This file is organized in the standard fashion for Tcl tests.
#
# Copyright (c) 1994 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
# RCS: @(#) $Id: textIndex.test,v 1.1.4.5 1999/03/24 02:55:03 hershey Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    source [file join [pwd] [file dirname [info script]] defs.tcl]
}

catch {destroy .t}
text .t -font {Courier -12} -width 20 -height 10
................................................................................
} {0 2.13}
test textIndex-15.14 {StartEnd} {
    list [catch {.t index {2.12 words}} msg] $msg
} {0 2.0}
test textIndex-15.15 {StartEnd} {
    list [catch {.t index {2.12 word}} msg] $msg
} {1 {bad text index "2.12 word"}}












# cleanup
rename textimage {}
catch {destroy .t}
::tcltest::cleanupTests
return







|







 







>
>
>
>
>
>
>
>
>
>
>







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
# This file is organized in the standard fashion for Tcl tests.
#
# Copyright (c) 1994 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
# RCS: @(#) $Id: textIndex.test,v 1.1.4.6 1999/03/27 02:31:40 redman Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    source [file join [pwd] [file dirname [info script]] defs.tcl]
}

catch {destroy .t}
text .t -font {Courier -12} -width 20 -height 10
................................................................................
} {0 2.13}
test textIndex-15.14 {StartEnd} {
    list [catch {.t index {2.12 words}} msg] $msg
} {0 2.0}
test textIndex-15.15 {StartEnd} {
    list [catch {.t index {2.12 word}} msg] $msg
} {1 {bad text index "2.12 word"}}

test testIndex-16.1 {TkTextPrintIndex} {
    set t [text .t2]
    $t insert end \n
    $t window create end -window [button $t.b]
    set result [$t index end-2c]
    pack $t
    catch {destroy $t}

    set result
} 1.1

# cleanup
rename textimage {}
catch {destroy .t}
::tcltest::cleanupTests
return