Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion flow/scripts/util.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ proc recover_power_helper { } {
}

proc extract_stage { input_file } {
if { ![regexp {/([0-9])_(([0-9])_)?} $input_file match num1 _ num2] } {
# Match the stage prefix on the basename, not the full path: an ancestor
# dir like ".../4_slices/3_place.odb" would otherwise match "4_" -> stage 4.
set stage_file [file tail $input_file]
if { ![regexp {^([0-9])_(([0-9])_)?} $stage_file match num1 _ num2] } {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a non-capturing group (?:...) for the optional second stage number allows you to avoid capturing the intermediate _ group (e.g., 2_), which eliminates the need for the dummy variable _ in the regexp variable list. This makes the regular expression and the variable bindings cleaner and more maintainable.

  if { ![regexp {^([0-9])_(?:([0-9])_)?} $stage_file match num1 num2] } {

puts "Error: Could not determine design stage from $input_file"
exit 1
}
Expand Down