Skip to content

Commit a33d3c3

Browse files
authored
Merge pull request #221 from rust-embedded/allow-underscore
allow underscore in spec
2 parents b4f3770 + 507e8af commit a33d3c3

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

CHANGELOG-rust.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This changelog tracks the Rust `svdtools` project. See
66
## [Unreleased]
77

88
* Interpolate path and name in `description` and `derivedFrom`
9+
* Allow specs started with `_` (missing part)
910

1011
## [v0.3.12] 2024-03-23
1112

@@ -15,6 +16,7 @@ This changelog tracks the Rust `svdtools` project. See
1516
* Refactor `RegisterBlockExt`, use `BlockPath` for better errors
1617
* Allow specs started with `_`
1718
* Allow process, `_delete` and `_modify` cluster without `_clusters` specifier
19+
* Allow 1 string `_include`
1820

1921
## [v0.3.11] 2024-03-06
2022

src/patch/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,12 @@ pub fn yaml_includes(parent: &mut Hash) -> Result<Vec<PathBuf>> {
162162
}
163163
}
164164

165-
let inc = parent.get_vec("_include")?.unwrap_or(&Vec::new()).clone();
165+
let inc = parent
166+
.str_vec_iter("_include")?
167+
.map(|s| s.to_string())
168+
.collect::<Vec<_>>();
166169
for relpath in inc {
167-
let relpath = relpath.as_str().unwrap();
170+
let relpath = relpath.as_str();
168171
let path = abspath(&self_path, Path::new(relpath))
169172
.with_context(|| anyhow!("Opening file \"{relpath}\" from file {self_path:?}"))?;
170173
if included.contains(&path) {
@@ -259,9 +262,6 @@ fn newglob(spec: &str) -> globset::GlobMatcher {
259262

260263
/// If a name matches a specification, return the first sub-specification that it matches
261264
fn matchsubspec<'a>(name: &str, spec: &'a str) -> Option<&'a str> {
262-
if spec.starts_with('_') {
263-
return None;
264-
}
265265
if spec.contains('{') {
266266
let glob = newglob(spec);
267267
if glob.is_match(name) {
@@ -731,9 +731,7 @@ fn spec_ind(spec: &str) -> Option<(usize, usize)> {
731731
Regex::new(r"^[\w%]*((?:[\?*]|\[\d+(?:-\d+)?\]|\[[a-zA-Z]+(?:-[a-zA-Z]+)?\])+)[\w%]*$")
732732
.unwrap()
733733
});
734-
let Some(caps) = RE.captures(spec) else {
735-
return None;
736-
};
734+
let caps = RE.captures(spec)?;
737735
let spec = caps.get(0).unwrap();
738736
let token = caps.get(1).unwrap();
739737
let li = token.start();

0 commit comments

Comments
 (0)