diff --git a/bash-5.1/r_variables/src/lib.rs b/bash-5.1/r_variables/src/lib.rs index 3023ddb385c43e9203aa1524161543a06a96efcc..cb0e1fede3d3b90135e2fd865a6ca66b5cb7ca6c 100644 --- a/bash-5.1/r_variables/src/lib.rs +++ b/bash-5.1/r_variables/src/lib.rs @@ -1,3 +1,4 @@ + use libc::*; use r_bash::*; use std::ffi::CStr; @@ -98,6 +99,17 @@ pub unsafe extern "C" fn bind_variable( ); } } + + vc = (*vc).down; + } + + return bind_variable_internal( + name, + value, + (*global_variables).table, + 0 as libc::c_int, + flags, + ); } #[derive(Copy, Clone)] @@ -121,3 +133,36 @@ macro_rules! vc_istempenv { ((*$vc).flags & VC_TEMPFLAGS as libc::c_int) == VC_TEMPFLAGS as libc::c_int } } + +static mut last_table_searched: *mut HASH_TABLE = 0 as *const HASH_TABLE + as *mut HASH_TABLE; + +#[inline] +unsafe extern "C" fn atoi(mut __nptr: *const libc::c_char) -> libc::c_int { + return strtol( + __nptr, + 0 as *mut libc::c_void as *mut *mut libc::c_char, + 10 as libc::c_int, + ) as libc::c_int; +} + +unsafe extern "C" fn create_variable_tables() { + if shell_variables.is_null() { + // new_var_context 下面会实现 + global_variables = new_var_context( + 0 as *mut libc::c_void as *mut libc::c_char, + 0 as libc::c_int, + ); + shell_variables = global_variables; + (*shell_variables).scope = 0 as libc::c_int; + //hash_create 为外部函数 + (*shell_variables).table = hash_create(VARIABLES_HASH_BUCKETS!() as libc::c_int); + } + if shell_functions.is_null() { + shell_functions = hash_create(FUNCTIONS_HASH_BUCKETS!() as libc::c_int); + } + // debugger + if shell_function_defs.is_null() { + shell_function_defs = hash_create(FUNCTIONS_HASH_BUCKETS!() as libc::c_int); + } +}