diff --git a/Cargo.lock b/Cargo.lock index bc144ff..2f8a11d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1704,9 +1704,7 @@ dependencies = [ "nom_locate", "num-traits", "once_cell", - "os_str_bytes", "regex", - "rustversion", "thiserror", ] @@ -2338,9 +2336,6 @@ name = "os_str_bytes" version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" -dependencies = [ - "memchr", -] [[package]] name = "owned_ttf_parser" @@ -2918,12 +2913,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rustversion" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" - [[package]] name = "ryu" version = "1.0.18" diff --git a/librashader-presets/Cargo.toml b/librashader-presets/Cargo.toml index e9adf4b..b73e3e1 100644 --- a/librashader-presets/Cargo.toml +++ b/librashader-presets/Cargo.toml @@ -21,9 +21,6 @@ once_cell = "1" # we don't need unicode regex = { version = "1", default-features = false, features = ["perf"] } -rustversion = "1.0" -os_str_bytes = { version = "6", features = ["conversions"] } - [features] parse_legacy_glsl = [] diff --git a/librashader-presets/src/context.rs b/librashader-presets/src/context.rs index 46799a0..bb81328 100644 --- a/librashader-presets/src/context.rs +++ b/librashader-presets/src/context.rs @@ -365,7 +365,6 @@ impl WildcardContext { } } -#[rustversion::since(1.74)] pub(crate) fn apply_context(path: &mut PathBuf, context: &FastHashMap) { use std::ffi::{OsStr, OsString}; @@ -412,53 +411,3 @@ pub(crate) fn apply_context(path: &mut PathBuf, context: &FastHashMap) { - use os_str_bytes::RawOsStr; - static WILDCARD_REGEX: Lazy = Lazy::new(|| Regex::new("\\$([A-Z-_]+)\\$").unwrap()); - if context.is_empty() { - return; - } - let path_str = RawOsStr::new(path.as_os_str()); - let path_bytes = path_str.to_raw_bytes(); - // Don't want to do any extra work if there's no match. - if !WILDCARD_REGEX.is_match(&path_bytes) { - return; - } - - let mut new_path = PathBuf::with_capacity(path.capacity()); - for component in path.components() { - match component { - Component::Normal(path) => { - let haystack = RawOsStr::new(path); - let haystack = haystack.to_raw_bytes(); - - let replaced = - WILDCARD_REGEX.replace_all(&haystack, |caps: ®ex::bytes::Captures| { - let Some(name) = caps.get(1) else { - return caps[0].to_vec(); - }; - - let Ok(key) = std::str::from_utf8(name.as_bytes()) else { - return caps[0].to_vec(); - }; - if let Some(replacement) = context.get(key) { - return RawOsStr::from_str(replacement).to_raw_bytes().to_vec(); - } - return caps[0].to_vec(); - }); - - // SAFETY: The original source is valid encoded bytes, and our replacement is - // valid encoded bytes. This upholds the safety requirements of `from_encoded_bytes_unchecked`. - new_path.push(RawOsStr::assert_cow_from_raw_bytes(&replaced.as_ref()).to_os_str()) - } - _ => new_path.push(component), - } - } - - // If no wildcards are found within the path, or the path after replacing the wildcards does not exist on disk, the path returned will be unaffected. - if let Ok(true) = new_path.try_exists() { - *path = new_path; - } -}