Posted to tcl by kbk at Mon Jan 04 22:08:24 GMT 2010view raw
- set f [open [lindex $argv 0] r]
- set script [read $f]
- close $f
- set patStart {\[('|(?:(?:::)?msgcat::)?mc)\s}
- set patEnd {[\];\n]}
- set pos 0
- while {[regexp -indices -start $pos -- $patStart $script where]} {
- foreach {start end} $where break
- set pos2 [expr {$start+1}]
- while {[regexp -indices -start $pos2 -- $patEnd $script where]} {
- set end [lindex $where 0]
- set command [string range $script $pos2 [expr {$end - 1}]]
- if {[info complete $command]} {
- puts $command
- break
- } else {
- set pos2 [expr {$end + 1}]
- }
- }
- set pos [expr {$end + 1}]
- }