Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d8c39b9a4ec98f4c16feeab22a996d9e669d82a1
Ticket: 219082ffffffffffffffffffffffffffffffffff
Simple conceptual error in code for Tcl_GetIndexFromObjStruc
User & Date: sheltond on 2000-11-24 16:43:51
Changes

  1. icomment:
    Unfortunately, this fix breaks the code which returns the cached value from a previous lookup using the same object. The code at the top of Tcl_GetIndexFromObjStruct simply returns the value from the ptr2 field of the structure. Due to the change above, this now contains (in the above example) 3. In fact, the value which should be returned is 1.
    
    >if ((objPtr->typePtr == &tclIndexType) &&
    >    (objPtr->internalRep.twoPtrValue.ptr1
    >    == (VOID *) tablePtr)) {
    >*indexPtr = (int)objPtr->internalRep.twoPtrValue.ptr2;
    >return TCL_OK;
    >}
    
    I would suggest a fix along the lines of this (sorry about the abysmal formatting here, the input box it too small to see what one is doing):
    
    >if ((objPtr->typePtr == &tclIndexType) &&
    >    (objPtr->internalRep.twoPtrValue.ptr1
    >    == (VOID *) tablePtr)) {
    >*indexPtr = (int)objPtr->internalRep.twoPtrValue.ptr2 /
    >           (offset/sizeof(char*));
    >return TCL_OK;
    >}
    
    This will cause the cached value to be returned correctly.
    
    
    
  2. login: "sheltond"
  3. mimetype: "text/plain"
  4. username: "sheltond"