[llvm-commits] CVS: llvm/test/Scripts/prcontext.tcl

Tanya Brethour tbrethou at cs.uiuc.edu
Sat Nov 13 13:03:33 PST 2004



Changes in directory llvm/test/Scripts:

prcontext.tcl added (r1.1)
---
Log message:

Rewrote prcontext.py in tcl.


---
Diffs of the changes:  (+36 -0)

Index: llvm/test/Scripts/prcontext.tcl
diff -c /dev/null llvm/test/Scripts/prcontext.tcl:1.1
*** /dev/null	Sat Nov 13 15:03:32 2004
--- llvm/test/Scripts/prcontext.tcl	Sat Nov 13 15:03:22 2004
***************
*** 0 ****
--- 1,36 ----
+ #!/usr/bin/tclsh
+ #
+ # Usage:
+ # prcontext <pattern> <# lines of context>
+ # (for platforms that don't have grep -C)
+ 
+ 
+ #
+ # Get the arguments
+ #
+ set pattern [lindex $argv 0]
+ set num [lindex $argv 1]
+ 
+ 
+ #
+ # Get all of the lines in the file.
+ #
+ set lines [split [read stdin] \n]
+ 
+ set index 0
+ foreach line $lines {
+     if { [regexp $pattern $line match matchline] } {
+         if { [ expr [expr $index - $num] < 0 ] } {
+             set bottom 0
+         } else {
+             set bottom [expr $index - $num]
+         }
+         set endLineNum [ expr [expr $index + $num] + 1]
+         while {$bottom < $endLineNum} {
+             set output [lindex $lines $bottom]
+             puts $output
+             set bottom [expr $bottom + 1]
+         }
+     }
+     set index [expr $index + 1]
+ }
\ No newline at end of file






More information about the llvm-commits mailing list