mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-24 02:38:42 +00:00
New python script that print a specified number of lines surrounding a
located pattern. In other words, grep -C for Solaris. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15425 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9b87287e7d
commit
21eccb6563
29
test/Scripts/prcontext.py
Executable file
29
test/Scripts/prcontext.py
Executable 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
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user