Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9f3d9987aa7c06a7ef163341f36907739e1f9620
Ticket: 3106532fffffffffffffffffffffffffffffffff
"switch -regexp -indexvar" gives invalid range
User & Date: martinlemburg on 2010-11-10 08:27:35
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    In TIP #75 is told, that the new -indexvar option, related to the -regexp option of switch, should behave like in the -indices option in the regexp command to return the range of the found matche and the ranges of the sub matches for any sub expression.
    The man page points to "regexp -indices", too, but tells the index variable contains range(s) from the first matching character to the next after the last matching character.
    
    So - TIP #75 is not realized and the behavior of "switch -regexp -indexvar" is not comparable to "regexp -indices".
    
    An example:
    
        % switch -regexp -indexvar i -matchvar m "abcdef" {
            ^abc {
                puts "matchvar = '$m'";
                puts "indexvar = [list $i]";
                puts "string range = '[string range "abcdef" {*}[lindex $i 0]]'";
            }
        }
        matchvar = 'abc'
        indexvar = {{0 3}}
        string range = 'abcd'
        % string range "abcdef" {*}[lindex [regexp -indices -inline {^abc} "abcdef"] 0]
        abc
    
    This behavior should be consistent and be corrected for the switch option -indexvar!
    
  4. foundin changed to: "obsolete: 8.5.9"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "martinlemburg"
  10. subsystem changed to: "18. Commands M-Z"
  11. title changed to: ""switch -regexp -indexvar" gives invalid range"
  12. type changed to: "Bug"