Support negative template literals

Fixes #1
This commit is contained in:
Luke Street 2023-12-11 13:29:25 -05:00
parent 0f20b45a49
commit ad2154fc66
2 changed files with 11 additions and 1 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "cwdemangle"
version = "0.1.6"
version = "0.1.7"
edition = "2018"
authors = ["Luke Street <luke@street.dev>"]
license = "MIT OR Apache-2.0"

View File

@ -127,6 +127,12 @@ fn demangle_arg<'a>(
mut str: &'a str,
options: &DemangleOptions,
) -> Option<(String, String, &'a str)> {
// Negative constant
if let Some(str) = str.strip_prefix('-') {
let (size, rest) = parse_digits(str)?;
let out = format!("-{size}");
return Some((out.clone(), String::new(), rest));
}
let mut result = String::new();
let (mut pre, mut post, rest) = parse_qualifiers(str);
result += pre.as_str();
@ -694,6 +700,10 @@ mod tests {
demangle("QuerySymbolToMapFile___Q24nw4r2dbFPUcPC12OSModuleInfoUlPUcUl", &options),
Some("nw4r::db::QuerySymbolToMapFile_(unsigned char*, const OSModuleInfo*, unsigned long, unsigned char*, unsigned long)".to_string())
);
assert_eq!(
demangle("__ct__Q37JGadget27TLinkList<10JUTConsole,-24>8iteratorFQ37JGadget13TNodeLinkList8iterator", &options),
Some("JGadget::TLinkList<JUTConsole, -24>::iterator::iterator(JGadget::TNodeLinkList::iterator)".to_string())
);
}
#[test]