mirror of
https://github.com/openhwgroup/cvw.git
synced 2025-04-20 03:47:20 -04:00
track GetLinenum.do (tcl procedure to find line numbers to exclude)
This commit is contained in:
parent
a3d9e11b0f
commit
92cd0cb6ab
1 changed files with 18 additions and 0 deletions
18
sim/GetLineNum.do
Normal file
18
sim/GetLineNum.do
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Alec Vercruysse
|
||||
# 2023-04-12
|
||||
# Note that the target string is regex, and needs to be double-escaped.
|
||||
# e.g. to match a (, you need \\(.
|
||||
proc GetLineNum {fname target} {
|
||||
set f [open $fname]
|
||||
set linectr 1
|
||||
while {[gets $f line] != -1} {
|
||||
if {[regexp $target $line]} {
|
||||
close $f
|
||||
return $linectr
|
||||
}
|
||||
incr linectr
|
||||
}
|
||||
close $f
|
||||
return -code error \
|
||||
"target string not found"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue