diff --git a/bash-5.1/r_variables/src/lib.rs b/bash-5.1/r_variables/src/lib.rs index f8b02fde2917184cbbf9136207c41929cc76ae60..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; @@ -144,3 +145,24 @@ unsafe extern "C" fn atoi(mut __nptr: *const libc::c_char) -> libc::c_int { 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); + } +}