Posted to tcl by mjanssen at Mon Oct 22 18:44:12 GMT 2007view pretty

# use: ./configure --disable-shared --disable-threads --disable-symbols CFLAGS="-march=i686"
# this build: 
#         real    0m12.970s
# default threaded/shared build
#         real    0m55.702s
# 
set re {^$}
fconfigure stdout -buffering full

proc my_grep {re file} {
        set f [open $file r]
        fconfigure $f -encoding ascii -translation lf
        while {[gets $f buf] >= 0} {
                if {[regexp -- $re $buf]} {puts $buf}
        }
        close $f
}
set re {^\$/}
fconfigure stdout -encoding binary -translation binary
foreach file $argv {
        my_grep $re $file
}