3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-11-03 13:07:58 +00:00

Fix verilog backend to avoid IdString::c_str()

This commit is contained in:
Robert O'Callahan 2025-10-13 22:23:51 +00:00
parent e4a5bd7cb2
commit 609da65bb4

View file

@ -108,22 +108,30 @@ IdString initial_id;
void reset_auto_counter_id(RTLIL::IdString id, bool may_rename)
{
const char *str = id.c_str();
if (*str == '$' && may_rename && !norename)
auto_name_map[id] = auto_name_counter++;
if (str[0] != '\\' || str[1] != '_' || str[2] == 0)
auto it = id.begin();
auto it_end = id.end();
if (it == it_end)
return;
for (int i = 2; str[i] != 0; i++) {
if (str[i] == '_' && str[i+1] == 0)
if (*it == '$' && may_rename && !norename)
auto_name_map[id] = auto_name_counter++;
if (*it != '\\' || *it != '_' || (it + 1) == it_end)
return;
it += 2;
auto start = it;
while (it != it_end) {
char ch = *it;
if (ch == '_' && (it + 1) == it_end)
continue;
if (str[i] < '0' || str[i] > '9')
if (ch < '0' || ch > '9')
return;
}
int num = atoi(str+2);
std::string s;
std::copy(start, it_end, std::back_inserter(s));
int num = atoi(s.c_str());
if (num >= auto_name_offset)
auto_name_offset = num + 1;
}