Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: dbbf9774097c64254b94c21ec9dc5ba9cb0e030a
Ticket: 1490503fffffffffffffffffffffffffffffffff
regexp within foreach loop matches wrong
User & Date: sachulka on 2006-05-17 20:30:07
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed 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 changed to: "obsolete: 8.4.13"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "sachulka"
  9. subsystem changed to: "16. Commands A-H"
  10. title changed to: "regexp within foreach loop matches wrong"
  11. type changed to: "Bug"