Skip to content
Tcl Source Code History Of Ticket 3513146fffffffff
Login

History Of Ticket 3513146fffffffff

Artifacts Associated With Ticket 3513146fffffffff

  1. Ticket change [a24bf49341] (rid 109869) by blacksqr on 2012-03-30 08:54:19:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      % set x a
      a
      % set val [string index $x end]]
      a]
      
      Note the extra close bracket at the end of the last statement.  Instead of throwing an error for imbalanced brackets, the extra bracket is strangely passed through to the result.
      
      Tested on Tcl 8.5.8 and 8.6b2 (Ubuntu)
      
    4. foundin initialized to: "obsolete: 8.6b2"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "blacksqr"
    10. subsystem initialized to: "18. Commands M-Z"
    11. title initialized to: "string index permits invalid charIndex"
    12. type initialized to: "Bug"
  2. Ticket change [b1ffedfb19] (rid 98261) by dkf on 2012-03-30 15:59:26:

    1. closedate changed to: "2012-03-30T08:59:26"
    2. closer changed to: "dkf"
    3. icomment:
      
      
      allow_comments - 1
      
      The [string index] runs to the first balanced bracket. The second is just an ordinary character. Tcl concatenates strings by default. Here's the proof: a disassembly of that command:
      
      % tcl::unsupported::disassemble script {set val [string index $x end]]}
      ByteCode 0x0x4dd10, refCt 1, epoch 3, interp 0x0x31c10 (epoch 3)
        Source "set val [string index $x end]]"
        Cmds 2, src 30, inst 23, litObjs 4, aux 0, stkDepth 3, code/src 0.00
        Commands 2:
            1: pc 0-21, src 0-29      2: pc 2-16, src 9-27
        Command 1: "set val [string index $x end]]"
          (0) push1 0 # "val"
        Command 2: "string index $x end"
          (2) startCommand +15 1 # next cmd at pc 17
          (11) push1 1 # "x"
          (13) loadScalarStk 
          (14) push1 2 # "end"
          (16) strindex 
          (17) push1 3 # "]"
          (19) concat1 2 
          (21) storeScalarStk 
          (22) done 
      
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Invalid"
    7. status changed to: "Closed"
    8. username: "dkf"