Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 8f8f26d0fdf4658338da90d9880aff93304d9b50
Ticket: 1943546fffffffffffffffffffffffffffffffff
Strangely failing [puts]
User & Date: nobody on 2008-08-16 09:24:48
Changes

  1. icomment:
    Logged In: NO 
    
    With the current Tcl/Tk HEAD as of today:
    
    There may be 2 bugs here.  1 seems to be that the TkTextIndex (both of them for the [.t get]) ->linePtr are the same for every iteration, and the other is that the byteIndex advances when it's supposed to be a display line advancement.
    
    I added this to just before the TextGetText() call in the TEXT_GET path:
    printf("index1Ptr->linePtr %p index1Ptr->byteIndex %d\n", (void *)index1Ptr->linePtr, index1Ptr->byteIndex);
    printf("index2Ptr->linePtr %p index2Ptr->byteIndex %d\n", (void *)index2Ptr->linePtr, index2Ptr->byteIndex); 
    
    ...
    Tcl_Obj *get = TextGetText(textPtr, index1Ptr, index2Ptr, visible);
    
    Then I added this bit of code:  
     {
     char *p;
     int len;
     p = Tcl_GetStringFromObj(get, &len);
     printf("length %d\n%s\n", len, p);
     printf("p[0] = %x\n", p[0] & 0xff);
     } 
    
     index1Ptr->linePtr 0x820aca0 index1Ptr->byteIndex 63
     index2Ptr->linePtr 0x820aca0 index2Ptr->byteIndex 63
    
     index1Ptr->linePtr 0x820aca0 index1Ptr->byteIndex 64
     index2Ptr->linePtr 0x820aca0 index2Ptr->byteIndex 65 
     length 1 
    
     p[0] = c3 
    
    That's the only point that it has a byteIndex > 0, and that's when it produces the error in the puts path.  From what I've read 0xc3 is not a valid UTF-8 character.  0xC3,0x83 on the other hand might be.  I'm not sure whether the bug is in GetIndex of the text widget (which returns the invalid byteIndex) or TextGetText -- they both may have bugs.
    
    
    
  2. login: "[email protected]"
  3. mimetype: "text/plain"
  4. username: "[email protected]"