Posted to tcl by mjanssen at Mon Oct 22 18:44:09 GMT 2007view raw

  1. # use: ./configure --disable-shared --disable-threads --disable-symbols CFLAGS="-march=i686"
  2. # this build:
  3. # real 0m12.970s
  4. # default threaded/shared build
  5. # real 0m55.702s
  6. #
  7. set re {^$}
  8. fconfigure stdout -buffering full
  9.  
  10. proc my_grep {re file} {
  11. set f [open $file r]
  12. fconfigure $f -encoding ascii -translation lf
  13. while {[gets $f buf] >= 0} {
  14. if {[regexp -- $re $buf]} {puts $buf}
  15. }
  16. close $f
  17. }
  18. set re {^\$/}
  19. fconfigure stdout -encoding binary -translation binary
  20. foreach file $argv {
  21. my_grep $re $file
  22. }
  23.