From 92cd0cb6ab2467bfea758db2891005fb48e05c7d Mon Sep 17 00:00:00 2001 From: Alec Vercruysse Date: Wed, 12 Apr 2023 15:58:38 -0700 Subject: [PATCH] track GetLinenum.do (tcl procedure to find line numbers to exclude) --- sim/GetLineNum.do | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 sim/GetLineNum.do diff --git a/sim/GetLineNum.do b/sim/GetLineNum.do new file mode 100644 index 00000000..4d38d912 --- /dev/null +++ b/sim/GetLineNum.do @@ -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" +}