1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

New python script that print a specified number of lines surrounding a

located pattern.
In other words, grep -C for Solaris.

llvm-svn: 15425
This commit is contained in:
John Criswell 2004-08-02 22:28:50 +00:00
parent c0288af302
commit 40fb366a90

29
test/Scripts/prcontext.py Executable file
View File

@ -0,0 +1,29 @@
#
# Usage:
# prcontext <pattern> <# lines of context>
#
import sys
#
# Get the arguments
#
pattern=sys.argv[1]
num=int(sys.argv[2])
#
# Get all of the lines in the file.
#
lines=sys.stdin.readlines()
index=0
for line in lines:
if ((line.find(pattern)) != -1):
if (index-num < 0):
bottom=0
else:
bottom=index-num
for output in lines[bottom:index+num+1]:
print output[:-1]
index=index+1