Posted to tcl by aku at Fri Nov 03 17:53:47 GMT 2017view pretty
#!/usr/bin/env tclsh # -*- tcl -*- # Check list of files and dirs for files containing the eliminated functions. proc funcs {} { return { Tcl_AppendResultVA Tcl_AppendStringsToObjVA Tcl_SetErrorCodeVA Tcl_PanicVA } } proc main {} { process-paths [cmdline] } proc cmdline {} { global argv if {![llength $argv]} usage return $argv } proc usage {} { global argv0 puts stderr "Usage: $argv0 path path..." exit 1 } proc process-paths {pathlist} { foreach path $pathlist { process-one $path } } proc process-one {path} { switch -exact -- [file type $path] { file { check-file $path } directory { process-paths [glob -directory $path *] } } } proc check-file {path} { set linenumber 0 set lines [split [get $path] \n] foreach line $lines { foreach f [funcs] { if {[string match "*${f}*" $line]} { puts "$path : $linenumber : $f" } } incr linenumber } } proc get {path} { set chan [open $path r] set contents [read $chan] close $chan return $contents } main
Comments
Posted by aku at Fri Nov 03 17:59:18 GMT 2017 [text] [code]
Oops. The [glob -directory ...] needs a -nocomplain to handle empty dirs.