diff --git a/src/lib.rs b/src/lib.rs index 3a61842..80697c7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -287,7 +287,11 @@ pub fn demangle(mut str: &str) -> Option { if str.starts_with('F') { str = &str[1..]; let (args, rest) = demangle_function_args(str)?; - fn_name = format!("{}({})", fn_name, args); + if args == "void" { + fn_name = format!("{}()", fn_name); + } else { + fn_name = format!("{}({})", fn_name, args); + } str = rest; } if str.starts_with('_') { @@ -404,10 +408,10 @@ mod tests { #[test] fn test_demangle() { assert_eq!(demangle("cfunction"), None); - assert_eq!(demangle("__dt__6CActorFv"), Some("CActor::~CActor(void)".to_string())); + assert_eq!(demangle("__dt__6CActorFv"), Some("CActor::~CActor()".to_string())); assert_eq!( demangle("GetSfxHandle__6CActorCFv"), - Some("CActor::GetSfxHandle(void) const".to_string()) + Some("CActor::GetSfxHandle() const".to_string()) ); assert_eq!( demangle("mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"), @@ -464,13 +468,15 @@ mod tests { assert_eq!( demangle("__opb__33TFunctor2CFv"), Some( - "TFunctor2::operator bool(void) const" - .to_string() + "TFunctor2::operator bool() const".to_string() ) ); assert_eq!( demangle("__opRC25TToken<15CCharLayoutInfo>__31TLockedToken<15CCharLayoutInfo>CFv"), - Some("TLockedToken::operator const TToken&(void) const".to_string()) + Some( + "TLockedToken::operator const TToken&() const" + .to_string() + ) ); assert_eq!( demangle("uninitialized_copy,Q24rstl17rmemory_allocator>,PQ224CSpawnSystemKeyframeData24CSpawnSystemKeyframeInfo>__4rstlFQ24rstl198pointer_iterator,Q24rstl17rmemory_allocator>Q24rstl198pointer_iterator,Q24rstl17rmemory_allocator>PQ224CSpawnSystemKeyframeData24CSpawnSystemKeyframeInfo"), @@ -478,7 +484,7 @@ mod tests { ); assert_eq!( demangle("__rf__Q34rstl120list,Q24rstl17rmemory_allocator>14const_iteratorCFv"), - Some("rstl::list, rstl::rmemory_allocator>::const_iterator::operator->(void) const".to_string()) + Some("rstl::list, rstl::rmemory_allocator>::const_iterator::operator->() const".to_string()) ); assert_eq!( demangle("ApplyRipples__FRC14CRippleManagerRA43_A43_Q220CFluidPlaneCPURender13SHFieldSampleRA22_A22_UcRA256_CfRQ220CFluidPlaneCPURender10SPatchInfo"), @@ -516,7 +522,7 @@ mod tests { ); assert_eq!( demangle("__dt__26__partial_array_destructorFv"), - Some("__partial_array_destructor::~__partial_array_destructor(void)".to_string()) + Some("__partial_array_destructor::~__partial_array_destructor()".to_string()) ); assert_eq!( demangle("__distance,1,Q24rstl52select1st>,Q24rstl21less<13TGameScriptId>,Q24rstl17rmemory_allocator>14const_iterator>__4rstlFQ34rstl195red_black_tree<13TGameScriptId,Q24rstl32pair<13TGameScriptId,9TUniqueId>,1,Q24rstl52select1st>,Q24rstl21less<13TGameScriptId>,Q24rstl17rmemory_allocator>14const_iteratorQ34rstl195red_black_tree<13TGameScriptId,Q24rstl32pair<13TGameScriptId,9TUniqueId>,1,Q24rstl52select1st>,Q24rstl21less<13TGameScriptId>,Q24rstl17rmemory_allocator>14const_iteratorQ24rstl20forward_iterator_tag"), diff --git a/src/main.rs b/src/main.rs index a1194c8..9e7e687 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ use argh::FromArgs; - use cwdemangle::demangle; #[derive(FromArgs)]