Fix vpi_handle_by_name() handling of escaped identifiers when finding a toplevel module

find_scope() requires the hierarchical path to use escaped identifiers;
without the leading '\' and trailing ' ', if there are any '.' characters,
the path will be broken up at the wrong point(s).
This commit is contained in:
Marlon James 2023-11-06 15:48:23 -08:00
parent 22b68ad24d
commit d4aef1e6d8
1 changed files with 12 additions and 10 deletions

View File

@ -1473,16 +1473,6 @@ vpiHandle vpi_handle_by_name(const char *name, vpiHandle scope)
*(nm_base-1) = 0;
}
if (*nm_base == '\\') {
// Skip the \ at the beginning
++nm_base;
// Drop the space at the end if it exists
if ((next = strchr(nm_base, ' '))) {
*next = 0;
}
}
// If there is no escaped identifier then just look for the last '.'
} else {
nm_base = strrchr(nm_path, '.');
@ -1554,6 +1544,18 @@ vpiHandle vpi_handle_by_name(const char *name, vpiHandle scope)
hand = tmp;
}
// find_name() expects escaped identifiers to be stripped
if (*nm_base == '\\') {
// Skip the \ at the beginning
++nm_base;
// Drop the space at the end if it exists
char *next;
if ((next = strchr(nm_base, ' '))) {
*next = 0;
}
}
// Now we have the correct scope, look for the item.
vpiHandle out = find_name(nm_base, hand);