Skip to content
Tcl Source Code History Of Ticket 1490503fffffffffffffffffffffffffffffffff
Login

History Of Ticket 1490503fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 1490503fffffffffffffffffffffffffffffffff

  1. Ticket change [dbbf977409] (rid 108014) by sachulka on 2006-05-17 20:30:07:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      I recently upgraded from Tcl8.3 to Tcl8.4.13 on 
      solaris and discovered this difference which does not 
      seem right. 
      
      here is my little program:
      
      proc send_user { x } { puts $x }
      set alarmRecord [list "abc: def" "ALARM 1: blah" "ghi: 
      jkl" "ALARM 2: fjdasl"]
      foreach record $alarmRecord {
         if [regexp {(ALARM)[^:]+([0-9]+)} $record match key 
      value] {
            send_user ">KEY $key VALUE $value\n"
         } elseif [regexp {([^:]+):(.*)} $record match key 
      value]  {
            send_user "KEY2 $key VALUE $value\n"
         }
      } 
      
      Here are the results, the key and value are different 
      for different Tcl versions:
      sapphire:~/thuyscripts {ewuthle_eusbd00250}> tclsh8.3
      KEY2 abc VALUE  def
       
      >KEY ALARM VALUE 1
       
      KEY2 ghi VALUE  jkl
       
      >KEY ALARM VALUE 2
      
      sapphire:~/thuyscripts {ewuthle_eusbd00250}> tclsh
      % info tclversion
      8.4
      KEY2 abc VALUE  def
       
      >KEY ALARM 1 VALUE  blah
       
      KEY2 ghi VALUE  jkl
       
      >KEY ALARM 2 VALUE  fjdasl
      
      So if regexp is in the foreach loop and the same 
      variables (key/value) are used inside if - regexp does 
      not match correctly.
      
      
      
    4. foundin initialized to: "obsolete: 8.4.13"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "sachulka"
    9. subsystem initialized to: "16. Commands A-H"
    10. title initialized to: "regexp within foreach loop matches wrong"
    11. type initialized to: "Bug"
  2. Ticket change [86e42145a1] (rid 131594) by msofer on 2006-05-18 03:59:37:

    1. assignee changed to: "msofer"
    2. closedate changed to: "2006-05-17T20:59:37"
    3. closer changed to: "msofer"
    4. icomment:
      Logged In: YES 
      user_id=148712
      
      The bug is actually in Tcl8.3 (although I did not confirm
      the behaviour there), the behaviour in 8.4 is correct.
      
      Your script is missing some braces in order to perform
      according to your expectation: it should be
      
        if {[regexp ...]} {
            send_user ">KEY $key VALUE $value\n"
        } elseif {[regexp ...] {
            send_user "KEY2 $key VALUE $value\n"
        }
      
      Please note that the conditions to 'if ... elseif' are
      enclosed in braces. This means that they are passed to 'if'
      as strings; when 'if' evals the first condition and finds it
      is true, it never evaluates the second.
      
      In your script as posted, both regexp's are evaluated
      *before* they are passed as arguments to 'if'; so, even when
      the first regexp matches, the values $key and $value are set
      by the second regexp.
      
      
    5. login: "msofer"
    6. mimetype: "text/plain"
    7. resolution changed to: "Invalid"
    8. status changed to: "Closed"
    9. username: "msofer"
  3. Ticket change [edd7e54bea] (rid 103969) by nobody on 2006-05-18 14:57:49:

    1. icomment:
      Logged In: NO 
      
      See also bug 219166, it was fixed in 8.4a4
      
      
      
    2. login: "nobody"
    3. mimetype: "text/plain"
    4. username: "nobody"
  4. Ticket change [ed10dfe592] (rid 103817) by dkf on 2006-05-18 15:06:22:

    1. subsystem changed to: "47. Bytecode Compiler"