Skip to content

Commit be0fd75

Browse files
authored
Merge pull request #197 from rust-embedded/slash
escape on match
2 parents 3f9264e + 58d3f8e commit be0fd75

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

CHANGELOG-rust.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ This changelog tracks the Rust `svdtools` project. See
55

66
## [Unreleased]
77

8+
* Fix escape special characters on Windows
9+
810
## [v0.3.8] 2023-12-23
911

1012
* Fix #176 in `collect_in_cluster`

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ serde_json = { version = "1.0", features = ["preserve_order"] }
3838
anyhow = "1.0.65"
3939
thiserror = "1.0.35"
4040
linked-hash-map = "0.5"
41-
globset = "0.4.8"
41+
globset = "0.4.14"
4242
commands = "0.0.5"
4343
env_logger = "0.10"
4444
log = { version = "~0.4", features = ["std"] }

src/patch/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pub mod patch_cli;
22

3-
use globset::Glob;
43
use std::fs::File;
54
use std::io::{Read, Write};
65
use std::path::{Path, PathBuf};
@@ -248,19 +247,27 @@ fn matchname(name: &str, spec: &str) -> bool {
248247
matchsubspec(name, spec).is_some()
249248
}
250249

250+
fn newglob(spec: &str) -> globset::GlobMatcher {
251+
globset::GlobBuilder::new(spec)
252+
.backslash_escape(true)
253+
.build()
254+
.unwrap()
255+
.compile_matcher()
256+
}
257+
251258
/// If a name matches a specification, return the first sub-specification that it matches
252259
fn matchsubspec<'a>(name: &str, spec: &'a str) -> Option<&'a str> {
253260
if spec.starts_with('_') {
254261
return None;
255262
}
256263
if spec.contains('{') {
257-
let glob = Glob::new(spec).unwrap().compile_matcher();
264+
let glob = newglob(spec);
258265
if glob.is_match(name) {
259266
return Some(spec);
260267
}
261268
} else {
262269
for subspec in spec.split(',') {
263-
let glob = Glob::new(subspec).unwrap().compile_matcher();
270+
let glob = newglob(subspec);
264271
if glob.is_match(name) {
265272
return Some(subspec);
266273
}

0 commit comments

Comments
 (0)