Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 559862a85bf5e3ba2bdfb932e7d4795b865179b5
Ticket: 1464039fffffffffffffffffffffffffffffffff
Tcl_GetIndexFromObj doesn't like zero length strings
User & Date: vincentdarley on 2006-04-04 07:56:10
Changes

  1. assignee changed to: "dgp"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    See Tk bug 1463233 for more details:
    
    https://sourceforge.net/tracker/?func=detail&atid=112997&aid=1463233&group_id=12997
    
    Basically, Tk's text widget tag option configuration
    allows (naturally) the empty string as a valid
    configuration value (to indicate that the tag does not
    override the text widget for that item).  This works
    for all other configuration types, but not for indices
    from string lists.  The root cause of the problem is
    that Tcl_GetIndexFromObj throws an error in this case,
    even though there is an exact match available (and
    nowhere in the documentation is it stated that an exact
    match will not be found for the special case of an
    empty string).
    
    An apparent fix would be:
    
         /*
          * The key should not be empty, otherwise it's not a
    match.
          */
         
         if (key[0] == '\0') {
    +
    +        /*
    +         * Check for special case of "" in string
    table.
    +         */
    +        for (entryPtr = tablePtr, i = 0; *entryPtr !=
    NULL; 
    +           entryPtr = NEXT_ENTRY(entryPtr, offset), i++) {
    +            if (**entryPtr == '\0') {
    +               index = i;
    +               goto done;
    +            }
    +        }
    +
            goto error;
         }
         
         /*
          * Scan the table looking for one of:
    
    Note that this does NOT give the empty string any
    special treatment - it simply equalises the treatment
    with what happens with any other prefix string.  If
    there is an exact match to any prefix string it is
    accepted, even if there are longer strings which could
    also match.
    
    Vince.
    
    
    
    
  4. foundin changed to: "obsolete: 8.5a4"
  5. priority changed to: "7 High"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "vincentdarley"
  9. subsystem changed to: "13. Index Object"
  10. title changed to:
    Tcl_GetIndexFromObj doesn't like zero length strings
    
  11. type changed to: "Bug"