From 06864f435459aa71194a0eee8249f5ad6adc9432 Mon Sep 17 00:00:00 2001 From: wangmengc Date: Fri, 31 May 2024 10:26:59 +0800 Subject: [PATCH] add expr_unwind function --- utshell-0.5/r_expr/src/lib.rs | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/utshell-0.5/r_expr/src/lib.rs b/utshell-0.5/r_expr/src/lib.rs index 19ff50c1..8ebfebac 100644 --- a/utshell-0.5/r_expr/src/lib.rs +++ b/utshell-0.5/r_expr/src/lib.rs @@ -1601,4 +1601,42 @@ unsafe extern "C" fn subexpr(mut expr: *mut libc::c_char) -> intmax_t { } popexp(); return val; +} + + +#[no_mangle] +unsafe extern "C" fn expr_unwind() { + loop { + expr_depth -= 1; + if !(expr_depth > 0 as libc::c_int) { + break; + } + if !((**expr_stack.offset(expr_depth as isize)).tokstr).is_null() { + sh_xfree( + (**expr_stack.offset(expr_depth as isize)).tokstr as *mut libc::c_void, + b"../expr.c\0" as *const u8 as *const libc::c_char, + 308 as libc::c_int, + ); + } + if !((**expr_stack.offset(expr_depth as isize)).expression).is_null() { + sh_xfree( + (**expr_stack.offset(expr_depth as isize)).expression as *mut libc::c_void, + b"../expr.c\0" as *const u8 as *const libc::c_char, + 311 as libc::c_int, + ); + } + sh_xfree( + *expr_stack.offset(expr_depth as isize) as *mut libc::c_void, + b"../expr.c\0" as *const u8 as *const libc::c_char, + 313 as libc::c_int, + ); + } + if expr_depth == 0 as libc::c_int { + sh_xfree( + *expr_stack.offset(expr_depth as isize) as *mut libc::c_void, + b"../expr.c\0" as *const u8 as *const libc::c_char, + 316 as libc::c_int, + ); + } + noeval = 0 as libc::c_int; } \ No newline at end of file -- Gitee