Skip to content

Commit 05f85d2

Browse files
committed
Remove duplicate underscore removal
In order to retain duplicate underscores from original type identifiers. Invalid character removal is also tweaked to reduce the number of underscores introduced in the previous step.
1 parent 4a8ca1a commit 05f85d2

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/ansi-c/type2name.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,23 +305,18 @@ std::string type_name2type_identifier(const std::string &name)
305305
};
306306
const auto replace_invalid_characters_with_underscore =
307307
[](const std::string &identifier) {
308-
static const std::regex non_alpha_numeric{"[^A-Za-z0-9]"};
308+
static const std::regex non_alpha_numeric{"[^A-Za-z0-9]+"};
309309
return std::regex_replace(identifier, non_alpha_numeric, "_");
310310
};
311-
const auto remove_duplicate_underscores = [](const std::string &identifier) {
312-
static const std::regex duplicate_underscore{"_+"};
313-
return std::regex_replace(identifier, duplicate_underscore, "_");
314-
};
315311
const auto strip_leading_non_letters = [](const std::string &identifier) {
316312
static const std::regex identifier_regex{"[A-Za-z][A-Za-z0-9_]*"};
317313
std::smatch match_results;
318314
bool found = std::regex_search(identifier, match_results, identifier_regex);
319315
POSTCONDITION(found);
320316
return match_results.str(0);
321317
};
322-
return strip_leading_non_letters(
323-
remove_duplicate_underscores(replace_invalid_characters_with_underscore(
324-
replace_special_characters(name))));
318+
return strip_leading_non_letters(replace_invalid_characters_with_underscore(
319+
replace_special_characters(name)));
325320
}
326321

327322
std::string type_to_partial_identifier(const typet &type, const namespacet &ns)

0 commit comments

Comments
 (0)