Skip to content

fix: remove the need for the regex crate's pattern feature #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion crates/zkevm_test_harness/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ env_logger = "0.9"
smallvec = "1.13"
structopt = "0.3.26"
codegen = "0.2.0"
regex = { version = "1.10.6", features = ["pattern"] }
regex = "1.11.1"

[dev-dependencies]
rand = "0.4"
Expand Down
12 changes: 6 additions & 6 deletions crates/zkevm_test_harness/src/tests/utils/preprocess_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn replace_tags_in_template(
let mut result = asm_template.clone();
let template_regex = Regex::new(r#"\$\{[^\}]+\}"#).expect("Invalid regex");

for (_, matched) in asm_template.match_indices(&template_regex) {
for matched in template_regex.find_iter(&asm_template).map(|m| m.as_str()) {
let prefix = "${";
let suffix = "}";
let key_to_replace = matched
Expand Down Expand Up @@ -111,7 +111,7 @@ fn link_additional_contracts(
// regex: <ADDRESS.asm>
let contract_regex = Regex::new(r#"<\d+\.asm>"#).expect("Invalid regex");

for (_, matched) in asm.match_indices(&contract_regex) {
for matched in contract_regex.find_iter(asm).map(|m| m.as_str()) {
let prefix = "<";
let suffix = ".asm>";
let contract_address = Address::from_low_u64_be(
Expand Down Expand Up @@ -214,7 +214,7 @@ fn replace_directives(asm: String, directive: Directive) -> (String, Vec<String>
};

let mut args_for_commands: Vec<String> = Vec::new();
for (index, matched) in asm.match_indices(&regex) {
for (index, matched) in regex.find_iter(&asm).map(|m| (m.start(), m.as_str())) {
// skip if directive commented out
if asm[..index]
.chars()
Expand Down Expand Up @@ -330,9 +330,9 @@ fn parse_args<'a>(text: &'a str, prefix: &str, suffix: &str) -> Vec<&'a str> {
.expect("Invalid text in directive")
.trim();

trimmed_content
.matches(&args_regex)
.map(|x| x.trim_matches(',').trim().trim_matches('"'))
args_regex
.find_iter(trimmed_content)
.map(|x| x.as_str().trim_matches(',').trim().trim_matches('"'))
.collect()
}

Expand Down
Loading