From ace97dd4d7f9e2b3afde23838744e654e23144b2 Mon Sep 17 00:00:00 2001 From: liutong Date: Thu, 29 Jun 2023 10:47:31 +0800 Subject: [PATCH] git add cargo vendor files --- bash-5.1/builtins_rust/command/src/lib.rs | 4 +- bash-5.1/builtins_rust/common/src/lib.rs | 24 +- bash-5.1/builtins_rust/exec/src/lib.rs | 2 +- bash-5.1/builtins_rust/exec_cmd/src/lib.rs | 130 ++++----- bash-5.1/builtins_rust/fc/src/lib.rs | 2 +- bash-5.1/builtins_rust/help/src/lib.rs | 36 +-- bash-5.1/builtins_rust/history/src/lib.rs | 4 +- bash-5.1/builtins_rust/jobs/src/lib.rs | 2 +- bash-5.1/builtins_rust/printf/src/lib.rs | 2 +- bash-5.1/builtins_rust/read/src/lib.rs | 4 +- bash-5.1/builtins_rust/set/src/lib.rs | 294 ++++++++++----------- bash-5.1/builtins_rust/shopt/src/lib.rs | 2 +- bash-5.1/builtins_rust/source/src/lib.rs | 6 +- bash-5.1/builtins_rust/type/src/lib.rs | 98 +++---- bash-5.1/builtins_rust/ulimit/src/lib.rs | 174 ++++++------ bash-5.1/builtins_rust/umask/src/lib.rs | 4 +- bash-5.1/builtins_rust/wait/src/lib.rs | 2 +- record.txt | 1 + 18 files changed, 396 insertions(+), 395 deletions(-) diff --git a/bash-5.1/builtins_rust/command/src/lib.rs b/bash-5.1/builtins_rust/command/src/lib.rs index b7f593de..3c2347ac 100644 --- a/bash-5.1/builtins_rust/command/src/lib.rs +++ b/bash-5.1/builtins_rust/command/src/lib.rs @@ -247,7 +247,7 @@ pub const CDESC_STDPATH: i32 = 0x100; //#define CDESC_STDPATH 0x100 /* command -p */ -pub const const_command_builtin:&CStr =unsafe{ CStr::from_bytes_with_nul_unchecked(b"command_builtin\0")};//.unwrap(); +pub const const_command_builtin:*mut libc::c_char = b"command_builtin\0" as *const u8 as *const libc::c_char as *mut libc::c_char;//.unwrap(); //#define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN | (use_standard_path ? CMD_STDPATH : 0)) //#define CMD_WANT_SUBSHELL 0x01 /* User wants a subshell: ( command ) */ //#define CMD_FORCE_SUBSHELL 0x02 /* Shell needs to force a subshell. */ @@ -345,7 +345,7 @@ pub unsafe extern "C" fn r_command_builtin(mut list: *mut WordList) -> libc::c_i return if any_found != 0 { EXECUTION_SUCCESS!() } else { EXECUTION_FAILURE!() }; } begin_unwind_frame( - const_command_builtin.as_ptr() as *mut libc::c_char + const_command_builtin ); command = make_bare_simple_command(); // let ref mut fresh0 = (*(*command).value.Simple).words; diff --git a/bash-5.1/builtins_rust/common/src/lib.rs b/bash-5.1/builtins_rust/common/src/lib.rs index fa1361f8..e01b6705 100644 --- a/bash-5.1/builtins_rust/common/src/lib.rs +++ b/bash-5.1/builtins_rust/common/src/lib.rs @@ -519,14 +519,14 @@ macro_rules! VUNSETATTR { #[macro_export] macro_rules! ISOCTAL { ($c:expr) => { - ($c) >= b'0' as i8 && ($c) <= b'7' as i8 + ($c) >= b'0' as libc::c_char && ($c) <= b'7' as libc::c_char }; } #[macro_export] macro_rules! DIGIT { ($c:expr) => { - ($c) >= b'0' as i8 && ($c) <= b'9' as i8 + ($c) >= b'0' as libc::c_char && ($c) <= b'9' as libc::c_char }; } @@ -746,7 +746,7 @@ pub extern "C" fn r_no_options(list:*mut WordList)->i32{ reset_internal_getopt(); let c_str = CString::new("").unwrap(); let c_ptr = c_str.as_ptr(); - opt = internal_getopt(list,c_ptr as *mut i8); + opt = internal_getopt(list,c_ptr as *mut libc::c_char); if opt != -1{ if opt == GETOPT_HELP!(){ builtin_help(); @@ -824,11 +824,11 @@ pub extern "C" fn r_sh_invalidnum(s:*mut c_char){ let mut msg = String::new(); let mut mag_ptr:*const c_char = std::ptr::null_mut(); - if *s == b'0' as i8 && isdigit(*s.offset(1) as c_int) != 0{ + if *s == b'0' as libc::c_char && isdigit(*s.offset(1) as c_int) != 0{ msg.push_str("invalid octal number"); mag_ptr = msg.as_ptr() as *mut c_char; } - else if *s == b'0' as i8 && *s.offset(1) == b'x' as i8{ + else if *s == b'0' as libc::c_char && *s.offset(1) == b'x' as libc::c_char{ msg.push_str("invalid hex number"); mag_ptr = msg.as_ptr() as *mut c_char; } @@ -1148,7 +1148,7 @@ pub extern "C" fn r_get_numeric_arg(mut list:*mut WordList,fatal:i32,count:*mut *count = 1; } - if !list.is_null() && !(*list).word.is_null() && ISOPTION((*(*list).word).word,b'-' as i8){ + if !list.is_null() && !(*list).word.is_null() && ISOPTION((*(*list).word).word,b'-' as libc::c_char){ list = (*list).next; } @@ -1159,7 +1159,7 @@ pub extern "C" fn r_get_numeric_arg(mut list:*mut WordList,fatal:i32,count:*mut r_sh_neednumarg((*(*list).word).word); } else { - r_sh_neednumarg(String::from("`'").as_ptr() as *mut i8); + r_sh_neednumarg(String::from("`'").as_ptr() as *mut libc::c_char); } if fatal == 0{ @@ -1188,7 +1188,7 @@ pub extern "C" fn r_get_exitstat(mut list:*mut WordList)->i32{ let arg:*mut c_char; unsafe{ - if !list.is_null() && !(*list).word.is_null() && ISOPTION((*(*list).word).word,b'-' as i8){ + if !list.is_null() && !(*list).word.is_null() && ISOPTION((*(*list).word).word,b'-' as libc::c_char){ list = (*list).next; } @@ -1211,7 +1211,7 @@ pub extern "C" fn r_get_exitstat(mut list:*mut WordList)->i32{ r_sh_neednumarg((*(*list).word).word); } else { - r_sh_neednumarg(String::from("`'").as_ptr() as *mut i8); + r_sh_neednumarg(String::from("`'").as_ptr() as *mut libc::c_char); } return EX_BADUSAGE!(); @@ -1234,7 +1234,7 @@ pub extern "C" fn r_read_octal(mut string:*mut c_char)->i32{ unsafe{ while *string!=0 && ISOCTAL!(*string){ digits += 1; - result = (result * 8) + (*string - b'0' as i8) as i32; + result = (result * 8) + (*string - b'0' as libc::c_char) as i32; string = (string as usize + 1 ) as *mut c_char; if result > 0o7777{ return -1; @@ -1390,11 +1390,11 @@ pub extern "C" fn r_get_job_spec(list:*mut WordList)->i32{ word = (*(*list).word).word; - if *word.offset(0) == '\0' as i8 { + if *word.offset(0) == '\0' as libc::c_char { return NO_JOB!(); } - if *word.offset(0) == '%' as i8 { + if *word.offset(0) == '%' as libc::c_char { word = word.offset(1); } diff --git a/bash-5.1/builtins_rust/exec/src/lib.rs b/bash-5.1/builtins_rust/exec/src/lib.rs index ca8399db..d2a4aff4 100644 --- a/bash-5.1/builtins_rust/exec/src/lib.rs +++ b/bash-5.1/builtins_rust/exec/src/lib.rs @@ -135,7 +135,7 @@ extern "C" fn r_mkdashname(name:*mut c_char)->*mut c_char{ unsafe{ ret = xmalloc(2 + strlen(name)) as *mut c_char; - *ret.offset(0) = '-' as i8; + *ret.offset(0) = '-' as libc::c_char; strcpy(ret.offset(1), name); return ret; } diff --git a/bash-5.1/builtins_rust/exec_cmd/src/lib.rs b/bash-5.1/builtins_rust/exec_cmd/src/lib.rs index 6825fbe3..3aad47b4 100644 --- a/bash-5.1/builtins_rust/exec_cmd/src/lib.rs +++ b/bash-5.1/builtins_rust/exec_cmd/src/lib.rs @@ -695,201 +695,201 @@ impl Factory for SimpleFactory { } } -unsafe fn get_cmd_type (command : *mut i8) -> CMDType{ +unsafe fn get_cmd_type (command : *mut libc::c_char) -> CMDType{ let mut types = CMDType::HelpCmd; - if libc::strcmp(command, b"alias\0" as *const u8 as *const i8 as *mut i8) == 0{ + if libc::strcmp(command, b"alias\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::AliasCmd; } - if libc::strcmp(command, b"unalias\0" as *const u8 as *const i8 as *mut i8) == 0{ + if libc::strcmp(command, b"unalias\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::UnAliasCmd; } - else if libc::strcmp(command, b"bind\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"bind\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::BindCmd; } - else if libc::strcmp(command, b"break\0" as *const u8 as *const i8 as *mut i8) == 0 { + else if libc::strcmp(command, b"break\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::BreakCmd; } - else if libc::strcmp(command, b"continue\0" as *const u8 as *const i8 as *mut i8) == 0 { + else if libc::strcmp(command, b"continue\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::ContinueCmd; } - else if libc::strcmp(command, b"builtin\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"builtin\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::BuiltinCmd; } - else if libc::strcmp(command, b"caller\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"caller\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::CallerCmd; } - else if libc::strcmp(command, b"cd\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"cd\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::CdCmd; } - else if libc::strcmp(command, b"pwd\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"pwd\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::PwdCmd; } - else if libc::strcmp(command, b":\0" as *const u8 as *const i8 as *mut i8) == 0 - || libc::strcmp(command, b"true\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b":\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 + || libc::strcmp(command, b"true\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::ColonCmd; } - else if libc::strcmp(command, b"false\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"false\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::FalseCmd; } - else if libc::strcmp(command, b"command\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"command\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::CommandCmd; } - else if libc::strcmp(command, b"common\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"common\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::CommonCmd; } - else if libc::strcmp(command, b"complete\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"complete\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::CompleteCmd; } - else if libc::strcmp(command, b"compopt\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"compopt\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::CompoptCmd; } - else if libc::strcmp(command, b"compgen\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"compgen\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::CompgenCmd; } - else if libc::strcmp(command,b"declare\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"declare\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::DeclareCmd; } - else if libc::strcmp(command,b"local\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"local\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::LocalCmd; } - else if libc::strcmp(command,b"echo\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"echo\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::EchoCmd; } - else if libc::strcmp(command,b"enable\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"enable\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::EnableCmd; } - else if libc::strcmp(command,b"eval\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"eval\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::EvalCmd; } - else if libc::strcmp(command,b"exec\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"exec\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::ExecCmd; } - else if libc::strcmp(command,b"exit\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"exit\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::ExitCmd; } - else if libc::strcmp(command,b"logout\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"logout\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::LogoutCmd; } - else if libc::strcmp(command,b"fc\0" as *const u8 as *const i8 as *mut i8) == 0 { + else if libc::strcmp(command,b"fc\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::FcCmd; } - else if libc::strcmp(command,b"fg\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"fg\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::FgCmd; } - else if libc::strcmp(command,b"bg\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"bg\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::BgCmd; } - else if libc::strcmp(command,b"getopts\0" as *const u8 as *const i8 as *mut i8) == 0 { + else if libc::strcmp(command,b"getopts\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::GetoptsCmd; } - else if libc::strcmp(command, b"hash\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"hash\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::HashCmd; } - else if libc::strcmp(command,b"help\0" as *const u8 as *const i8 as * mut i8) == 0 { + else if libc::strcmp(command,b"help\0" as *const u8 as *const libc::c_char as * mut libc::c_char) == 0 { types = CMDType::HelpCmd; } - else if libc::strcmp(command,b"history\0" as *const u8 as *const i8 as *mut i8) == 0 { + else if libc::strcmp(command,b"history\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::HistoryCmd; } - else if libc::strcmp(command,b"jobs\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"jobs\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::JobsCmd; } - else if libc::strcmp(command, b"kill\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"kill\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::KillCmd; } - else if libc::strcmp(command, b"mapfile\0" as *const u8 as *const i8 as *mut i8) == 0 || - libc::strcmp(command, b"readarray\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"mapfile\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 || + libc::strcmp(command, b"readarray\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::MapfileCmd;; } - else if libc::strcmp(command,b"printf\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"printf\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::PrintfCmd; } - else if libc::strcmp(command,b"pushd\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"pushd\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::PushdCmd; } - else if libc::strcmp(command,b"dirs\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"dirs\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::DirsCmd; } - else if libc::strcmp(command,b"popd\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"popd\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::PopdCmd; } - else if libc::strcmp(command, b"read\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"read\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::ReadCmd; } - else if libc::strcmp(command, b"let\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"let\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::LetCmd; } - else if libc::strcmp(command,b"return\0" as *const u8 as *const i8 as *mut i8) == 0 { + else if libc::strcmp(command,b"return\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::ReturnCmd; } - else if libc::strcmp(command,b"set\0" as *const u8 as *const i8 as *mut i8) == 0 - || libc::strcmp(command,b"typeset\0" as *const u8 as *const i8 as *mut i8) == 0 { + else if libc::strcmp(command,b"set\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 + || libc::strcmp(command,b"typeset\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::SetCmd; } - else if libc::strcmp(command,b"unset\0" as *const u8 as *const i8 as *mut i8) == 0 { + else if libc::strcmp(command,b"unset\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::UnSetCmd; } - else if libc::strcmp(command,b"setattr\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"setattr\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::SetattrCmd; } - else if libc::strcmp(command,b"readonly\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"readonly\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::ReadonlyCmd; } - else if libc::strcmp(command,b"export\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"export\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::ExportCmd; } - else if libc::strcmp(command,b"shift\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"shift\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::ShiftCmd; } - else if libc::strcmp(command,b"shopt\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command,b"shopt\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::ShoptCmd; } - else if libc::strcmp(command,b"source\0" as *const u8 as *const i8 as *mut i8) == 0 - || libc::strcmp(command,b".\0" as *const u8 as *const i8 as *mut i8)== 0 { + else if libc::strcmp(command,b"source\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 + || libc::strcmp(command,b".\0" as *const u8 as *const libc::c_char as *mut libc::c_char)== 0 { types = CMDType::SourceCmd; } - else if libc::strcmp(command, b"suspend\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command, b"suspend\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::SuspendCmd; } - else if libc::strcmp(command,b"test\0" as *const u8 as *const i8 as *mut i8) == 0 - || libc::strcmp(command,b"[\0" as *const u8 as *const i8 as *mut i8)== 0 { + else if libc::strcmp(command,b"test\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 + || libc::strcmp(command,b"[\0" as *const u8 as *const libc::c_char as *mut libc::c_char)== 0 { types = CMDType::TestCmd; } - else if libc::strcmp(command ,b"times\0" as *const u8 as *const i8 as *mut i8) == 0 { + else if libc::strcmp(command ,b"times\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::TimesCmd; } - else if libc::strcmp(command ,b"trap\0" as *const u8 as *const i8 as *mut i8) == 0 { + else if libc::strcmp(command ,b"trap\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::TrapCmd; } - else if libc::strcmp(command ,b"type\0" as *const u8 as *const i8 as *mut i8) == 0 { + else if libc::strcmp(command ,b"type\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::TypeCmd; } - else if libc::strcmp(command ,b"ulimit\0" as *const u8 as *const i8 as *mut i8) == 0{ + else if libc::strcmp(command ,b"ulimit\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{ types = CMDType::UlimitCmd; } - else if libc::strcmp(command ,b"umask\0" as *const u8 as *const i8 as *mut i8 ) == 0{ + else if libc::strcmp(command ,b"umask\0" as *const u8 as *const libc::c_char as *mut libc::c_char ) == 0{ types = CMDType::UmaskCmd; } - else if libc::strcmp(command , b"wait\0" as *const u8 as *const i8 as *mut i8) == 0 { + else if libc::strcmp(command , b"wait\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::WaitCmd; } @@ -897,7 +897,7 @@ unsafe fn get_cmd_type (command : *mut i8) -> CMDType{ } #[no_mangle] -pub extern "C" fn r_exec_cmd(command : *mut i8, mut list :*mut WordList) -> i32 { +pub extern "C" fn r_exec_cmd(command : *mut libc::c_char, mut list :*mut WordList) -> i32 { println!("enter r_exec_cmd"); unsafe { @@ -907,4 +907,4 @@ pub extern "C" fn r_exec_cmd(command : *mut i8, mut list :*mut WordList) -> i32 let factory = SimpleFactory::new(); let cmdCall = factory.make_product(commandType); cmdCall.excute(list) -} \ No newline at end of file +} diff --git a/bash-5.1/builtins_rust/fc/src/lib.rs b/bash-5.1/builtins_rust/fc/src/lib.rs index 66bbbfc7..f5728386 100644 --- a/bash-5.1/builtins_rust/fc/src/lib.rs +++ b/bash-5.1/builtins_rust/fc/src/lib.rs @@ -400,7 +400,7 @@ pub extern "C" fn r_set_verbose_flag (){ #[no_mangle] pub extern "C" fn r_fc_number (list:* mut WordList)->i32 { - let mut s:*mut c_char = 0 as *mut i8; + let mut s:*mut c_char = 0 as *mut libc::c_char; if list == std::ptr::null_mut(){ return 0; diff --git a/bash-5.1/builtins_rust/help/src/lib.rs b/bash-5.1/builtins_rust/help/src/lib.rs index 390f3a90..37ce387c 100644 --- a/bash-5.1/builtins_rust/help/src/lib.rs +++ b/bash-5.1/builtins_rust/help/src/lib.rs @@ -82,7 +82,7 @@ extern "C"{ fn throw_to_top_level(); fn default_columns() -> usize; fn wcsnwidth (chaa : * mut libc::wchar_t, size :i32, i: i32) -> i32; - fn xstrmatch (string1 : * mut libc::c_char, string2 : * mut libc::c_char, i : i8) -> i8; + fn xstrmatch (string1 : * mut libc::c_char, string2 : * mut libc::c_char, i : libc::c_char) -> libc::c_char; fn open(pathname : *const libc::c_char, oflag : i32) -> i32; fn wcwidth( c :libc::wchar_t) -> i32; static mut loptend:*mut WordList; @@ -320,7 +320,7 @@ fn show_longdoc(i : i32){ // usefile = usefile && unsafe{*((doc as usize + 8 as usize)as *mut *mut libc::c_char) as *mut libc::c_char} == std::ptr::null_mut(); //usefile = usefile && ((doc as usize + 8 as usize) as * mut c_char) == std::ptr::null_mut(); //usefile = usefile && (*(doc as usize + 8 as usize) as *mut libc::c_char )as char== '/' as char ; - //usefile = doc!= std::ptr::null_mut() && *((doc as usize + ) as * mut c_char)== '/' as i8 && (doc as usize +4)as * mut c_char == std::ptr::null_mut() as * mut c_char; + //usefile = doc!= std::ptr::null_mut() && *((doc as usize + ) as * mut c_char)== '/' as libc::c_char && (doc as usize +4)as * mut c_char == std::ptr::null_mut() as * mut c_char; } // let usefile = (doc!= std::ptr::null_mut() && char::from(unsafe {*((doc + 4*8) as usize ) as * mut c_char) as u8 })== '/'); if usefile { @@ -357,7 +357,7 @@ fn show_desc (name : *mut c_char, i :i32){ let mut j :i32; let r :i32; let mut doc : *mut *mut libc::c_char; - let mut line : *mut i8 = 0 as *mut i8 ; + let mut line : *mut libc::c_char = 0 as *mut libc::c_char ; let mut fd : i32; let mut usefile : bool; @@ -366,18 +366,18 @@ fn show_desc (name : *mut c_char, i :i32){ doc = builtin1.long_doc; } // usefile = (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL); - usefile = doc!= std::ptr::null_mut() && unsafe {*doc as *mut i8} != std::ptr::null_mut(); - usefile = usefile && unsafe {**doc as i8 } == '/' as i8; - //usefile = usefile && unsafe {*(doc as usize + 8 as usize) as *mut i8} != std::ptr::null_mut(); + usefile = doc!= std::ptr::null_mut() && unsafe {*doc as *mut libc::c_char} != std::ptr::null_mut(); + usefile = usefile && unsafe {**doc as libc::c_char } == '/' as libc::c_char; + //usefile = usefile && unsafe {*(doc as usize + 8 as usize) as *mut libc::c_char} != std::ptr::null_mut(); if usefile { - fd = open_helpfile (unsafe {*doc as *mut i8 }); + fd = open_helpfile (unsafe {*doc as *mut libc::c_char }); if (fd < 0){ //无返回值 return (); } unsafe { - r = zmapfd (fd, *(line as *mut i8) as *mut *mut i8 ,(doc as *mut i8)); + r = zmapfd (fd, *(line as *mut libc::c_char) as *mut *mut libc::c_char ,(doc as *mut libc::c_char)); libc::close (fd); } /* XXX - handle errors if zmapfd returns < 0 */ @@ -386,7 +386,7 @@ fn show_desc (name : *mut c_char, i :i32){ { if doc!= std::ptr::null_mut() { unsafe { - line = *doc as *mut i8; + line = *doc as *mut libc::c_char; } } else{ @@ -430,8 +430,8 @@ fn show_manpage (name : *mut c_char, i : i32){ doc = builtin1.long_doc; } //*doc = (*((shell_builtins as usize + i as usize) as *mut builtin).long_doc as *mut libc::c_char); - usefile = doc!= std::ptr::null_mut() && unsafe {*doc as *mut i8} != std::ptr::null_mut(); - usefile = usefile && unsafe {**doc as i8 } == '/' as i8; + usefile = doc!= std::ptr::null_mut() && unsafe {*doc as *mut libc::c_char} != std::ptr::null_mut(); + usefile = usefile && unsafe {**doc as libc::c_char } == '/' as libc::c_char; if usefile{ @@ -451,7 +451,7 @@ fn show_manpage (name : *mut c_char, i : i32){ if doc!= std::ptr::null_mut(){ unsafe { - line = *doc as *mut i8; + line = *doc as *mut libc::c_char; } } else{ @@ -596,18 +596,18 @@ fn show_builtin_command_help (){ let height : i32 = 76; let mut width : usize; let mut t :*mut libc::c_char; - let mut blurb:[i8;128] = ['0' as i8;128]; + let mut blurb:[libc::c_char;128] = ['0' as libc::c_char;128]; println!("help command edit by huanhuan."); println!("{}",("These shell commands are defined internally. Type `help' to see this list.\n Type `help name' to find out more about the function `name'.\n Use `info bash' to find out more about the shell in general.\n Use `man -k' or `info' to find out more about commands not in this list.\n A star (*) next to a name means that the command is disabled.\n")); - let ref2: &mut i8= &mut blurb[0]; + let ref2: &mut libc::c_char= &mut blurb[0]; unsafe { width = default_columns(); } width /= 2; - if width > (std::mem::size_of::()*128) { - width = std::mem::size_of::()*128; + if width > (std::mem::size_of::()*128) { + width = std::mem::size_of::()*128; } if width <= 3{ width = 40; @@ -620,13 +620,13 @@ fn show_builtin_command_help (){ QUIT(); } if MB_CUR_MAX!() > 1 { - let ptr2: *mut i8 = ref2 as *mut i8; + let ptr2: *mut libc::c_char = ref2 as *mut libc::c_char; wdispcolumn (i, ptr2,128, width as i32, height); } } } //#endif /* HELP_BUILTIN */ -fn strmatch (pattern : *mut libc::c_char, string : *mut libc::c_char, flags : i8) -> i8 +fn strmatch (pattern : *mut libc::c_char, string : *mut libc::c_char, flags : libc::c_char) -> libc::c_char { if ((string as usize)as * mut c_char != std::ptr::null_mut()) || ((pattern as usize)as * mut c_char != std::ptr::null_mut()){ return FNM_NOMATCH!(); diff --git a/bash-5.1/builtins_rust/history/src/lib.rs b/bash-5.1/builtins_rust/history/src/lib.rs index 37caa346..54fd1b46 100644 --- a/bash-5.1/builtins_rust/history/src/lib.rs +++ b/bash-5.1/builtins_rust/history/src/lib.rs @@ -87,9 +87,9 @@ unsafe { let c_tmp = if *delete_arg == b'-' as c_char {delete_arg.offset(1 as isize ) as *mut c_char} else {delete_arg}; range = libc::strchr(c_tmp, b'-' as c_int); - printf(b"AAAAAAArange=%u, c_tmp=%s\n" as *const u8 as *const i8, range, c_tmp); + printf(b"AAAAAAArange=%u, c_tmp=%s\n" as *const u8 as *const libc::c_char, range, c_tmp); if !range.is_null() { - printf(b"AAAAAAArange=%s\n" as *const u8 as *const i8, range); + printf(b"AAAAAAArange=%s\n" as *const u8 as *const libc::c_char, range); let mut delete_start: c_long = 0; let mut delete_end: c_long = 0; diff --git a/bash-5.1/builtins_rust/jobs/src/lib.rs b/bash-5.1/builtins_rust/jobs/src/lib.rs index 6354a9e5..17b62c73 100644 --- a/bash-5.1/builtins_rust/jobs/src/lib.rs +++ b/bash-5.1/builtins_rust/jobs/src/lib.rs @@ -391,7 +391,7 @@ extern "C" { } libc::free((*(*l).word).word as * mut libc::c_void); - (*(*(*l).word).word) = (*get_job_by_jid! (job)).pgrp as i8; + (*(*(*l).word).word) = (*get_job_by_jid! (job)).pgrp as libc::c_char; } l=(*l).next; } diff --git a/bash-5.1/builtins_rust/printf/src/lib.rs b/bash-5.1/builtins_rust/printf/src/lib.rs index 23bf4584..429860b0 100644 --- a/bash-5.1/builtins_rust/printf/src/lib.rs +++ b/bash-5.1/builtins_rust/printf/src/lib.rs @@ -190,7 +190,7 @@ unsafe { if *fmt == b'\\' as c_char { fmt = (fmt as usize + 1) as *mut c_char; - let mut mbch: [i8;25] = [0; 25]; + let mut mbch: [libc::c_char;25] = [0; 25]; let mut mblen: c_int = 0; fmt = (fmt as usize + tescape(fmt, mbch.as_ptr() as *mut c_char, std::mem::transmute(&mblen), PT_NULL as *mut c_int) as usize) as *mut c_char; let mut mbind = 0; diff --git a/bash-5.1/builtins_rust/read/src/lib.rs b/bash-5.1/builtins_rust/read/src/lib.rs index 3fcc4683..d5ae2945 100644 --- a/bash-5.1/builtins_rust/read/src/lib.rs +++ b/bash-5.1/builtins_rust/read/src/lib.rs @@ -162,7 +162,7 @@ unsafe { 'N' | 'n' => { if opt_char == 'N' { ignore_delim = 1; - delim = -1; + delim = 255 as u8 as libc::c_char; } nflag = 1; code = legal_number(list_optarg, &mut intval); @@ -222,7 +222,7 @@ unsafe { //忽略界定符 if ignore_delim != 0{ //-N ignore_delim = 1 - delim = -1; + delim = 255 as u8 as libc::c_char; } ifs_chars = getifs(); //ifs_chars is "\n" diff --git a/bash-5.1/builtins_rust/set/src/lib.rs b/bash-5.1/builtins_rust/set/src/lib.rs index 715d32d6..8caab34f 100644 --- a/bash-5.1/builtins_rust/set/src/lib.rs +++ b/bash-5.1/builtins_rust/set/src/lib.rs @@ -207,7 +207,7 @@ macro_rules! att_array{ #[macro_export] macro_rules! savestring { ($x:expr) => { - libc::strcpy(xmalloc ((1+ strlen ($x)) as u64) as *mut i8, $x) + libc::strcpy(xmalloc ((1+ strlen ($x)) as u64) as *mut libc::c_char, $x) } } @@ -221,9 +221,9 @@ macro_rules! value_cell { #[derive(Copy, Clone)] #[repr(C)] pub struct variable { - pub name: *mut i8, - pub value: *mut i8, - pub exportstr: *mut i8, + pub name: *mut libc::c_char, + pub value: *mut libc::c_char, + pub exportstr: *mut libc::c_char, pub dynamic_value: sh_var_value_func_t, pub assign_func: sh_var_assign_func_t, pub attributes: i32, @@ -233,7 +233,7 @@ pub struct variable { #[derive(Copy, Clone)] #[repr(C)] pub struct opp{ - name : *mut i8, + name : *mut libc::c_char, letter : i32, variable : *mut i32, set_func : Option::, @@ -268,7 +268,7 @@ macro_rules! VA_ONEWORD { pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"allexport\0" as *const u8 as *const i8 as *mut i8, + name : b"allexport\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'a' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -289,7 +289,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"braceexpand\0" as *const u8 as *const i8 as *mut i8, + name : b"braceexpand\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'B' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -308,7 +308,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"emacs\0" as *const u8 as *const i8 as *mut i8, + name : b"emacs\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'\0' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -320,7 +320,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"errexit\0" as *const u8 as *const i8 as *mut i8 , + name : b"errexit\0" as *const u8 as *const libc::c_char as *mut libc::c_char , letter : b'e' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -339,7 +339,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp { - name : b"errtrace\0" as *const u8 as *const i8 as *mut i8, + name : b"errtrace\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'E' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -358,7 +358,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp { - name : b"functrace\0" as *const u8 as *const i8 as *mut i8, + name : b"functrace\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'T' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -377,7 +377,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp { - name : b"hashall\0" as *const u8 as *const i8 as *mut i8, + name : b"hashall\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'h' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -396,7 +396,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"histexpand\0" as *const u8 as *const i8 as *mut i8, + name : b"histexpand\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'H' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -415,7 +415,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"history\0" as *const u8 as *const i8 as *mut i8, + name : b"history\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'\0' as i32, // variable : 0 as *const libc::c_void // as *mut libc::c_void @@ -432,7 +432,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"ignoreeof\0" as *const u8 as *const i8 as *mut i8, + name : b"ignoreeof\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'\0' as i32, /*variable : 0 as *const libc::c_void as *mut libc::c_void @@ -449,7 +449,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"interactive-comments\0" as *const u8 as *const i8 as *mut i8, + name : b"interactive-comments\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'\0' as i32, /*variable : 0 as *const libc::c_void as *mut libc::c_void @@ -469,7 +469,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"keyword\0" as *const u8 as *const i8 as *mut i8, + name : b"keyword\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'k' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -488,7 +488,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"monitor\0" as *const u8 as *const i8 as *mut i8, + name : b"monitor\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'm' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -507,7 +507,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"noclobber\0" as *const u8 as *const i8 as *mut i8, + name : b"noclobber\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'C' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -526,7 +526,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"noexec\0" as *const u8 as *const i8 as *mut i8, + name : b"noexec\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'n' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -545,7 +545,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"noglob\0" as *const u8 as *const i8 as *mut i8, + name : b"noglob\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'f' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -564,7 +564,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"nolog\0" as *const u8 as *const i8 as *mut i8, + name : b"nolog\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'\0' as i32, /*variable : 0 as *const libc::c_void as *mut libc::c_void @@ -584,7 +584,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"notify\0" as *const u8 as *const i8 as *mut i8, + name : b"notify\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'b' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -603,7 +603,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"nounset\0" as *const u8 as *const i8 as *mut i8, + name : b"nounset\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'u' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -622,7 +622,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"onecmd\0" as *const u8 as *const i8 as *mut i8, + name : b"onecmd\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b't' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -641,7 +641,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"physical\0" as *const u8 as *const i8 as *mut i8, + name : b"physical\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'P' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -660,7 +660,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"pipefail\0" as *const u8 as *const i8 as *mut i8, + name : b"pipefail\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'\0' as i32, /*variable : 0 as *const libc::c_void as *mut libc::c_void @@ -680,7 +680,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"posix\0" as *const u8 as *const i8 as *mut i8, + name : b"posix\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'\0' as i32, /*variable : 0 as *const libc::c_void as *mut libc::c_void @@ -697,7 +697,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"privileged\0" as *const u8 as *const i8 as *mut i8, + name : b"privileged\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'p' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -716,7 +716,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"verbose\0" as *const u8 as *const i8 as *mut i8, + name : b"verbose\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'v' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -735,7 +735,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"vi\0" as *const u8 as *const i8 as *mut i8, + name : b"vi\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'\0' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -747,7 +747,7 @@ pub static mut o_options : [opp ; 28] = unsafe {[ { opp{ - name : b"xtrace\0" as *const u8 as *const i8 as *mut i8, + name : b"xtrace\0" as *const u8 as *const libc::c_char as *mut libc::c_char, letter : b'x' as i32, variable : 0 as *const libc::c_void as *mut libc::c_void @@ -786,72 +786,72 @@ pub static mut o_options : [opp ; 28] = unsafe {[ ]}; extern "C" { - fn setopt_set_func_t (i :i32 , name : *mut i8) -> i32; - fn setopt_get_func_t (name : *mut i8)-> i32; + fn setopt_set_func_t (i :i32 , name : *mut libc::c_char) -> i32; + fn setopt_get_func_t (name : *mut libc::c_char)-> i32; fn xmalloc(_: u64) -> *mut libc::c_void; - fn unbind_variable_noref(_: *const i8) -> i32; - fn unbind_nameref(_: *const i8) -> i32; - fn unbind_func(_: *const i8) -> i32; - fn strvec_create(_: i32) -> *mut *mut i8; + fn unbind_variable_noref(_: *const libc::c_char) -> i32; + fn unbind_nameref(_: *const libc::c_char) -> i32; + fn unbind_func(_: *const libc::c_char) -> i32; + fn strvec_create(_: i32) -> *mut *mut libc::c_char; fn all_shell_variables() -> *mut *mut SHELL_VAR; fn print_var_list(_: *mut *mut SHELL_VAR); fn print_func_list(_: *mut *mut SHELL_VAR); fn change_flag(_: i32, _: i32) -> i32; - fn strlen(_: *const i8) -> u64; + fn strlen(_: *const libc::c_char) -> u64; fn builtin_usage(); - fn find_function (name:* const i8)->* mut SHELL_VAR; + fn find_function (name:* const libc::c_char)->* mut SHELL_VAR; fn bind_variable( - _: *const i8, - _: *mut i8, + _: *const libc::c_char, + _: *mut libc::c_char, _: i32, ) -> *mut SHELL_VAR; - fn find_variable(_: *const i8) -> *mut SHELL_VAR; - fn rl_variable_bind (_: *const i8, _: *const i8) -> i32; + fn find_variable(_: *const libc::c_char) -> *mut SHELL_VAR; + fn rl_variable_bind (_: *const libc::c_char, _: *const libc::c_char) -> i32; fn find_variable_last_nameref( - _: *const i8, + _: *const libc::c_char, _: i32, ) -> *mut SHELL_VAR; fn extract_colon_unit( - _: *mut i8, + _: *mut libc::c_char, _: *mut i32, - ) -> *mut i8; + ) -> *mut libc::c_char; fn valid_array_reference ( - _ : *const i8 , + _ : *const libc::c_char , _ : i32 )-> i32; fn array_variable_part ( - _: *const i8, + _: *const libc::c_char, _: i32, - _:*mut *mut i8, + _:*mut *mut libc::c_char, _:*mut i32 ) -> *mut SHELL_VAR; fn all_shell_functions () -> *mut *mut SHELL_VAR; fn num_posix_options() -> i32; fn find_flag(_: i32) -> *mut i32; - fn internal_getopt (list:*mut WordList , opts:*mut i8)->i32; - fn get_posix_options(_: *mut i8) -> *mut i8; + fn internal_getopt (list:*mut WordList , opts:*mut libc::c_char)->i32; + fn get_posix_options(_: *mut libc::c_char) -> *mut libc::c_char; fn sh_chkwrite (_:i32)->i32; fn reset_internal_getopt(); - fn sh_invalidopt (value:* mut i8); - fn sv_ignoreeof (_ : *mut i8); - fn sv_strict_posix (_: *mut i8); + fn sh_invalidopt (value:* mut libc::c_char); + fn sv_ignoreeof (_ : *mut libc::c_char); + fn sv_strict_posix (_: *mut libc::c_char); fn with_input_from_stdin(); - fn sh_invalidoptname (value:* mut i8); + fn sh_invalidoptname (value:* mut libc::c_char); fn bash_history_enable(); fn load_history(); fn bash_history_disable(); fn remember_args (list:* mut WordList, argc:i32); - fn sh_invalidid (value:* mut i8); - fn legal_identifier (_:*const i8) -> i32; - fn unbind_array_element(_: *mut SHELL_VAR, _:*mut i8,_: i32) -> i32; - fn unbind_variable (_: *const i8) -> i32; - fn with_input_from_stream (_:libc::FILE , _: *const i8); - fn stupidly_hack_special_variables (_ : *mut i8); - fn builtin_error(_: *const i8, _: ...); + fn sh_invalidid (value:* mut libc::c_char); + fn legal_identifier (_:*const libc::c_char) -> i32; + fn unbind_array_element(_: *mut SHELL_VAR, _:*mut libc::c_char,_: i32) -> i32; + fn unbind_variable (_: *const libc::c_char) -> i32; + fn with_input_from_stream (_:libc::FILE , _: *const libc::c_char); + fn stupidly_hack_special_variables (_ : *mut libc::c_char); + fn builtin_error(_: *const libc::c_char, _: ...); fn builtin_help(); static mut posixly_correct : i32; static mut enable_history_list : i32; @@ -861,7 +861,7 @@ extern "C" { static mut pipefail_opt : i32; static mut mark_modified_vars: i32; static mut remember_on_history: i32; - static mut optflags: [i8; 0]; + static mut optflags: [libc::c_char; 0]; static mut list_opttype:i32; static mut no_line_editing :i32; static mut interactive : i32; @@ -876,11 +876,11 @@ extern "C" { type setopt_set_func_t = unsafe extern "C" fn ( i :i32 , - name : *mut i8 + name : *mut libc::c_char ) -> i32; type setopt_get_func_t = unsafe extern "C" fn ( - name : *mut i8 + name : *mut libc::c_char ) -> i32; type sh_var_value_func_t = unsafe extern "C" fn ( @@ -889,25 +889,25 @@ type sh_var_value_func_t = unsafe extern "C" fn ( type sh_var_assign_func_t = unsafe extern "C" fn ( _ : *mut SHELL_VAR , - _ : *mut i8, + _ : *mut libc::c_char, _ : arrayind_t, - _ : *mut i8 + _ : *mut libc::c_char ) -> *mut SHELL_VAR; //type check = String::from_utf8(cc::Build::new().file("../builtins/set.def").expand()).unwrap(); -static mut on: *const i8 = b"on\0" as *const u8 as *const i8; -static mut off: *const i8 = b"off\0" as *const u8 as *const i8; +static mut on: *const libc::c_char = b"on\0" as *const u8 as *const libc::c_char; +static mut off: *const libc::c_char = b"off\0" as *const u8 as *const libc::c_char; static mut previous_option_value: i32 = 0; pub type SHELL_VAR = variable; pub type arrayind_t = i64; -unsafe fn STREQ( a:* const i8, b:* const i8)->bool { +unsafe fn STREQ( a:* const libc::c_char, b:* const libc::c_char)->bool { //println!("hahhahahhahahah"); //println!("a is {:?}, b is {:?}",CStr::from_ptr(a),CStr::from_ptr(b)); return (*a ==*b) && (libc::strcmp(a, b) == 0); } -unsafe fn find_minus_o_option (mut name : *mut i8) -> i32 { +unsafe fn find_minus_o_option (mut name : *mut libc::c_char) -> i32 { //println! ("enter find_minus_o_option"); let mut i : i32 = 0; for j in 0..N_O_OPTIONS!()-1 { @@ -923,7 +923,7 @@ unsafe fn find_minus_o_option (mut name : *mut i8) -> i32 { -1 } -unsafe fn minus_o_option_value (name : *mut i8) -> i32{ +unsafe fn minus_o_option_value (name : *mut libc::c_char) -> i32{ let mut i : i32 = 0; let mut on_or_off : *mut i32 = 0 as *mut i32; @@ -943,7 +943,7 @@ unsafe fn minus_o_option_value (name : *mut i8) -> i32{ } } -unsafe fn print_minus_o_option (name : *mut i8, value : i32, pflag : i32){ +unsafe fn print_minus_o_option (name : *mut libc::c_char, value : i32, pflag : i32){ if pflag == 0 { if value > 0 { println!("{:?} {:?}", CStr::from_ptr(name), CStr::from_ptr(on)); @@ -999,9 +999,9 @@ unsafe fn list_minus_o_opts (mode : i32 , reusable :i32){ } } -unsafe fn get_minus_o_opts () -> *mut *mut i8{ +unsafe fn get_minus_o_opts () -> *mut *mut libc::c_char{ - let mut ret = 0 as *mut *mut i8; + let mut ret = 0 as *mut *mut libc::c_char; let mut i : i32 = 0; ret = strvec_create(N_O_OPTIONS!() as i32 + 1); for j in 0..N_O_OPTIONS!(){ @@ -1019,26 +1019,26 @@ unsafe fn get_minus_o_opts () -> *mut *mut i8{ ret } -unsafe fn get_current_options () -> *mut i8{ +unsafe fn get_current_options () -> *mut libc::c_char{ - let mut temp : *mut i8 = 0 as *mut i8; + let mut temp : *mut libc::c_char = 0 as *mut libc::c_char; let mut i : i32 =0 ; let mut posixopts: i32 = 0; posixopts = unsafe {num_posix_options ()}; /* shopts modified by posix mode */ /* Make the buffer big enough to hold the set -o options and the shopt options modified by posix mode. */ - temp = unsafe {xmalloc((1 + N_O_OPTIONS!() as i32 + posixopts) as u64) as *mut i8}; + temp = unsafe {xmalloc((1 + N_O_OPTIONS!() as i32 + posixopts) as u64) as *mut libc::c_char}; for t in 0..N_O_OPTIONS!() { i = t as i32; if o_options[t as usize].letter != 0 { unsafe { *(temp.offset(t as isize)) = - *(find_flag (o_options[t as usize].letter)) as i8 + *(find_flag (o_options[t as usize].letter)) as libc::c_char }; } else { unsafe { - *(temp.offset(t as isize)) = GET_BINARY_O_OPTION_VALUE!(t,o_options[i as usize].name) as i8; + *(temp.offset(t as isize)) = GET_BINARY_O_OPTION_VALUE!(t,o_options[i as usize].name) as libc::c_char; } } } @@ -1046,12 +1046,12 @@ unsafe fn get_current_options () -> *mut i8{ bitmap. They will be handled in set_current_options() */ unsafe { get_posix_options (temp.offset(i as isize)); - *(temp.offset((i+posixopts) as isize) )= b'\0' as i8; + *(temp.offset((i+posixopts) as isize) )= b'\0' as libc::c_char; } return (temp); } -unsafe fn set_current_options (bitmap : *const i8) { +unsafe fn set_current_options (bitmap : *const libc::c_char) { let mut i : i32 ; let mut v : i32 ; @@ -1099,22 +1099,22 @@ unsafe fn set_current_options (bitmap : *const i8) { } } -unsafe extern "C" fn set_ignoreeof (on_or_off : i32 , option_name : *mut i8) -> i32 { +unsafe extern "C" fn set_ignoreeof (on_or_off : i32 , option_name : *mut libc::c_char) -> i32 { on_or_off == FLAG_ON!(); ignoreeof = on_or_off; - unbind_variable_noref (b"ignoreeof\0" as *const u8 as *const i8); + unbind_variable_noref (b"ignoreeof\0" as *const u8 as *const libc::c_char); if ignoreeof != 0 { - bind_variable (b"IGNOREEOF\0" as *const u8 as *const i8, - b"10\0" as *const u8 as *mut i8, 0); + bind_variable (b"IGNOREEOF\0" as *const u8 as *const libc::c_char, + b"10\0" as *const u8 as *mut libc::c_char, 0); } else { - unbind_variable_noref (b"IGNOREEOF\0" as *const u8 as *const i8); + unbind_variable_noref (b"IGNOREEOF\0" as *const u8 as *const libc::c_char); } - sv_ignoreeof (b"IGNOREEOF\0" as *const u8 as *const i8 as *mut i8); + sv_ignoreeof (b"IGNOREEOF\0" as *const u8 as *const libc::c_char as *mut libc::c_char); return 0; } -unsafe extern "C" fn set_posix_mode (on_or_off : i32 , option_name : *mut i8) -> i32 { +unsafe extern "C" fn set_posix_mode (on_or_off : i32 , option_name : *mut libc::c_char) -> i32 { if (on_or_off == FLAG_ON!() && posixly_correct != 0 ) || (on_or_off == FLAG_OFF!() && posixly_correct == 0){ return 0; @@ -1123,24 +1123,24 @@ unsafe extern "C" fn set_posix_mode (on_or_off : i32 , option_name : *mut i8) -> posixly_correct = on_or_off ; if posixly_correct != 0 { - unbind_variable_noref(b"POSIXLY_CORRECT\0" as *const u8 as *const i8); + unbind_variable_noref(b"POSIXLY_CORRECT\0" as *const u8 as *const libc::c_char); } else { - bind_variable (b"POSIXLY_CORRECT\0" as *const u8 as *const i8, - b"y\0" as *const u8 as *mut i8, 0); + bind_variable (b"POSIXLY_CORRECT\0" as *const u8 as *const libc::c_char, + b"y\0" as *const u8 as *mut libc::c_char, 0); } - sv_strict_posix (b"POSIXLY_CORRECT\0" as *const u8 as *mut i8); + sv_strict_posix (b"POSIXLY_CORRECT\0" as *const u8 as *mut libc::c_char); return 0; } -unsafe extern "C" fn set_edit_mode (on_or_off : i32 , option_name : *mut i8) -> i32{ +unsafe extern "C" fn set_edit_mode (on_or_off : i32 , option_name : *mut libc::c_char) -> i32{ //println!("set edit mode by huanhuan"); let mut isemacs : i32; if on_or_off == FLAG_ON!() { - rl_variable_bind (b"editing-mode\0" as *const u8 as *const i8, + rl_variable_bind (b"editing-mode\0" as *const u8 as *const libc::c_char, option_name); if interactive > 0 { with_input_from_stdin () @@ -1156,10 +1156,10 @@ unsafe extern "C" fn set_edit_mode (on_or_off : i32 , option_name : *mut i8) -> else { isemacs = 0; } - if isemacs != 0 && *option_name == b'e' as i8 - || (isemacs == 0 && *option_name == b'v' as i8) { + if isemacs != 0 && *option_name == b'e' as libc::c_char + || (isemacs == 0 && *option_name == b'v' as libc::c_char) { if interactive > 0 { - with_input_from_stream (stdin, b"stdin\0" as *const u8 as *const i8); + with_input_from_stream (stdin, b"stdin\0" as *const u8 as *const libc::c_char); } } @@ -1168,9 +1168,9 @@ unsafe extern "C" fn set_edit_mode (on_or_off : i32 , option_name : *mut i8) -> {no_line_editing}; } -unsafe extern "C" fn get_edit_mode (name : *mut i8) -> i32 { +unsafe extern "C" fn get_edit_mode (name : *mut libc::c_char) -> i32 { - if *name == b'e' as i8 { + if *name == b'e' as libc::c_char { if no_line_editing== 0 && rl_editing_mode == 1 { return 1; } @@ -1188,7 +1188,7 @@ unsafe extern "C" fn get_edit_mode (name : *mut i8) -> i32 { } } -unsafe extern "C" fn bash_set_history (on_or_off : i32 , option_name : *mut i8) -> i32 { +unsafe extern "C" fn bash_set_history (on_or_off : i32 , option_name : *mut libc::c_char) -> i32 { if on_or_off == FLAG_ON!() { enable_history_list = 1; @@ -1206,7 +1206,7 @@ unsafe extern "C" fn bash_set_history (on_or_off : i32 , option_name : *mut i8) return 1 - enable_history_list; } -unsafe fn set_minus_o_option (on_or_off : i32, option_name : *mut i8) -> i32 { +unsafe fn set_minus_o_option (on_or_off : i32, option_name : *mut libc::c_char) -> i32 { //println!("enter set_minus_o_option"); let mut i : i32 ; @@ -1257,8 +1257,8 @@ unsafe fn print_all_shell_variables (){ pub unsafe fn r_set_shellopts () { //println!("set shellopts by huanhuan"); - let mut value : *mut i8; - let mut tflag : [i8;N_O_OPTIONS!()] = [0 as i8 ;N_O_OPTIONS!()]; + let mut value : *mut libc::c_char; + let mut tflag : [libc::c_char;N_O_OPTIONS!()] = [0 as libc::c_char ;N_O_OPTIONS!()]; let mut vsize : i32 = 0; let mut i: i32 = 0; let mut vptr : i32 ; @@ -1283,18 +1283,18 @@ pub unsafe fn r_set_shellopts () { } } } - value = unsafe {xmalloc((vsize + 1) as u32 as u64) as *mut i8}; + value = unsafe {xmalloc((vsize + 1) as u32 as u64) as *mut libc::c_char}; vptr = 0; for j in 0..N_O_OPTIONS!(){ i = j as i32; if o_options[i as usize].name != std::ptr::null_mut(){ - if tflag[i as usize] != 0 as i8 { + if tflag[i as usize] != 0 as libc::c_char { unsafe { libc::strcpy (value.offset(vptr as isize), o_options[i as usize].name); vptr = vptr + strlen (o_options[i as usize].name) as u64 as i64 as i32; } - *value.offset(vptr as isize) = b':' as i8; + *value.offset(vptr as isize) = b':' as libc::c_char; vptr = vptr+1; } } @@ -1303,9 +1303,9 @@ pub unsafe fn r_set_shellopts () { if vptr > 0 { vptr = vptr-1; } - *value.offset(vptr as isize) = b'\0' as i8; + *value.offset(vptr as isize) = b'\0' as libc::c_char; - v = find_variable (b"SHELLOPTS\0" as *const u8 as *mut i8); + v = find_variable (b"SHELLOPTS\0" as *const u8 as *mut libc::c_char); /* Turn off the read-only attribute so we can bind the new value, and note whether or not the variable was exported. */ @@ -1316,7 +1316,7 @@ pub unsafe fn r_set_shellopts () { else { exported = 0; } - v = bind_variable (b"SHELLOPTS\0" as *const u8 as *mut i8, value, 0); + v = bind_variable (b"SHELLOPTS\0" as *const u8 as *mut libc::c_char, value, 0); /* Turn the read-only attribute back on, and turn off the export attribute if it was set implicitly by mark_modified_vars and SHELLOPTS was not exported before we bound the new value. */ @@ -1331,8 +1331,8 @@ pub unsafe fn r_set_shellopts () { } -unsafe fn parse_shellopts (value : *mut i8) { - let mut vname : *mut i8; +unsafe fn parse_shellopts (value : *mut libc::c_char) { + let mut vname : *mut libc::c_char; let mut vptr : i32 = 0; loop { vname = extract_colon_unit(value, &mut vptr); @@ -1345,11 +1345,11 @@ unsafe fn parse_shellopts (value : *mut i8) { } unsafe fn initialize_shell_options (no_shellopts : i32) { - let mut temp: *mut i8; + let mut temp: *mut libc::c_char; let mut var : *mut SHELL_VAR = 0 as *mut SHELL_VAR; if no_shellopts == 0 { - var = find_variable (b"SHELLOPTS\0" as *const u8 as *const i8); + var = find_variable (b"SHELLOPTS\0" as *const u8 as *const libc::c_char); /* set up any shell options we may have inherited. */ if !var.is_null() && imported_p!(var) != 0 { if assoc_p! (var) != 0 || array_p !(var) != 0{ @@ -1388,8 +1388,8 @@ unsafe fn reset_shell_options () { let mut opts_changed : i32; let mut rv : i32; let mut r : i32 ; - let mut arg : *mut i8 = 0 as *mut i8; - let mut s: [i8;3] = [0 as i8;3]; + let mut arg : *mut libc::c_char = 0 as *mut libc::c_char; + let mut s: [libc::c_char;3] = [0 as libc::c_char;3]; let mut opt : i32; let mut flag : bool = false; if list.is_null() { @@ -1413,12 +1413,12 @@ unsafe fn reset_shell_options () { match optChar { 'i' => { s[0] = unsafe { - list_opttype as i8 + list_opttype as libc::c_char }; - s[1] = b'i' as u8 as i8; - s[2] = b'\0' as u8 as i8; + s[1] = b'i' as u8 as libc::c_char; + s[2] = b'\0' as u8 as libc::c_char; unsafe { - sh_invalidopt (s.as_ptr() as *mut i8); + sh_invalidopt (s.as_ptr() as *mut libc::c_char); builtin_usage(); } return EX_USAGE;} @@ -1426,7 +1426,7 @@ unsafe fn reset_shell_options () { unsafe { builtin_usage (); } - if unsafe {list_optopt} == b'?' as i8 as i32 { + if unsafe {list_optopt} == b'?' as libc::c_char as i32 { return EXECUTION_SUCCESS!(); } else { @@ -1446,7 +1446,7 @@ unsafe fn reset_shell_options () { return EX_USAGE; } } - // opt = unsafe {internal_getopt(list, optflags.as_ptr() as *mut i8)}; + // opt = unsafe {internal_getopt(list, optflags.as_ptr() as *mut libc::c_char)}; opt = unsafe {internal_getopt (list, optflags.as_mut_ptr())}; } opts_changed = 0; @@ -1457,16 +1457,16 @@ unsafe fn reset_shell_options () { arg = unsafe {(*(*list).word).word}; //if (arg[0] == '-' && (!arg[1] || (arg[1] == '-' && !arg[2]))) if unsafe { - (*arg == b'-' as u8 as i8) + (*arg == b'-' as u8 as libc::c_char) && ( arg.offset(1 as isize) == std::ptr::null_mut() - || (*(arg.offset(1 as isize)) == b'-' as u8 as i8 + || (*(arg.offset(1 as isize)) == b'-' as u8 as libc::c_char && arg.offset(2 as isize) != std::ptr::null_mut())) } { //println!("*arg == b'-' && arg[1] && arg[1]== b'-'"); unsafe { list = (*list).next; /* `set --' unsets the positional parameters. */ - if *arg.offset(1 as isize) == b'-' as u8 as i8 { + if *arg.offset(1 as isize) == b'-' as u8 as libc::c_char { //println!("arg[1]== b'-'"); force_assignment = 1; } @@ -1506,7 +1506,7 @@ unsafe fn reset_shell_options () { else if optChar == 'o' { /* -+o option-name */ //println!("optChar == 'o'"); - let mut option_name : *mut i8 = 0 as *mut i8 ; + let mut option_name : *mut libc::c_char = 0 as *mut libc::c_char ; let mut opt : *mut WordList = 0 as *mut WordList; unsafe {opt = (*list).next;} if opt == std::ptr::null_mut(){ @@ -1539,9 +1539,9 @@ unsafe fn reset_shell_options () { if (option_name == std::ptr::null_mut() || unsafe { - *option_name == '\u{0}' as i8 - ||*option_name == '-' as i8 - || *option_name == '+' as i8 + *option_name == '\u{0}' as libc::c_char + ||*option_name == '-' as libc::c_char + || *option_name == '+' as libc::c_char }){ //on_or_off == '+' as i32; unsafe { @@ -1577,11 +1577,11 @@ unsafe fn reset_shell_options () { } else if unsafe{change_flag (flag_name, on_or_off) == FLAG_ERROR!()}{ //println!("change_flag ...."); - s[0] = on_or_off as i8; - s[1] = flag_name as i8 ; - s[2] = '\0' as i32 as i8 ; + s[0] = on_or_off as libc::c_char; + s[1] = flag_name as libc::c_char ; + s[2] = '\0' as i32 as libc::c_char ; unsafe { - sh_invalidopt (s.as_ptr() as *mut i8); + sh_invalidopt (s.as_ptr() as *mut libc::c_char); builtin_usage (); r_set_shellopts (); } @@ -1634,14 +1634,14 @@ pub extern "C" fn r_unset_builtin(mut list: *mut WordList) -> i32 { let mut global_unset_var: i32 = 0; let mut vflags: i32 = 0; let mut valid_id: i32 = 0; - let mut name: *mut i8 = 0 as *mut i8; - let mut tname: *mut i8 = 0 as *mut i8; + let mut name: *mut libc::c_char = 0 as *mut libc::c_char; + let mut tname: *mut libc::c_char = 0 as *mut libc::c_char; println!("enter r_unset by huanhuan"); let mut c_str_fnv = CString::new("fnv").unwrap(); unsafe { reset_internal_getopt(); - opt= internal_getopt (list, c_str_fnv.as_ptr() as * mut i8); + opt= internal_getopt (list, c_str_fnv.as_ptr() as * mut libc::c_char); while opt != -1 { let optu8:u8= opt as u8; @@ -1659,7 +1659,7 @@ pub extern "C" fn r_unset_builtin(mut list: *mut WordList) -> i32 { return EX_USAGE; } } - opt =internal_getopt (list, c_str_fnv.as_ptr() as * mut i8); + opt =internal_getopt (list, c_str_fnv.as_ptr() as * mut libc::c_char); } //println!("unset func={}, unset val=%{}", global_unset_func, global_unset_var); @@ -1667,7 +1667,7 @@ pub extern "C" fn r_unset_builtin(mut list: *mut WordList) -> i32 { if global_unset_func != 0 && global_unset_var != 0 { builtin_error (b"cannot simultaneously unset a function and a variable \0" as *const u8 - as *const i8); + as *const libc::c_char); return EXECUTION_FAILURE!(); } else if unset_function != 0 && nameref != 0 { @@ -1684,7 +1684,7 @@ pub extern "C" fn r_unset_builtin(mut list: *mut WordList) -> i32 { let mut var : *mut SHELL_VAR; let mut tem : i32 = 0; - let mut t : *mut i8 = 0 as *mut i8; + let mut t : *mut libc::c_char = 0 as *mut libc::c_char; name = (*(*list).word).word; unset_function = global_unset_func; @@ -1693,7 +1693,7 @@ pub extern "C" fn r_unset_builtin(mut list: *mut WordList) -> i32 { if !unset_function == 0 && nameref == 0 && valid_array_reference (name, vflags) != 0 { t = libc::strchr (name, '[' as i32); - *t.offset(1 as isize) = b'\0' as i32 as i8; + *t.offset(1 as isize) = b'\0' as i32 as libc::c_char; unset_array = unset_array + 1; } @@ -1726,7 +1726,7 @@ pub extern "C" fn r_unset_builtin(mut list: *mut WordList) -> i32 { if var != std::ptr::null_mut() && unset_function == 0 && non_unsettable_p!(var) != 0 { builtin_error (b"%s: cannot unset \0" as *const u8 - as *const i8, name); + as *const libc::c_char, name); any_failed = any_failed + 1; list = (*list).next; } @@ -1744,12 +1744,12 @@ pub extern "C" fn r_unset_builtin(mut list: *mut WordList) -> i32 { if var!= std::ptr::null_mut() && readonly_p! (var)!= 0 { if unset_function != 0 { - builtin_error (b"%s: cannot unset: readonly %s \0 " as *const u8 as *mut i8, - (*var).name, b"function\0" as *const u8 as *mut i8); + builtin_error (b"%s: cannot unset: readonly %s \0 " as *const u8 as *mut libc::c_char, + (*var).name, b"function\0" as *const u8 as *mut libc::c_char); } else { - builtin_error (b"%s: cannot unset: readonly %s \0" as *const u8 as *mut i8, - (*var).name, b"variable\0" as *const u8 as *mut i8); + builtin_error (b"%s: cannot unset: readonly %s \0" as *const u8 as *mut libc::c_char, + (*var).name, b"variable\0" as *const u8 as *mut libc::c_char); } any_failed = any_failed + 1; list = (*list).next; @@ -1760,7 +1760,7 @@ pub extern "C" fn r_unset_builtin(mut list: *mut WordList) -> i32 { tem = unbind_array_element (var, t, vflags); /* XXX new third arg */ if tem == -2 && array_p!(var) == 0 && assoc_p! (var) == 0 { builtin_error (b"%s: not an array variable\0" as *const u8 - as *const i8, (*var).name); + as *const libc::c_char, (*var).name); any_failed = any_failed + 1; list = (*list).next; } diff --git a/bash-5.1/builtins_rust/shopt/src/lib.rs b/bash-5.1/builtins_rust/shopt/src/lib.rs index 717189df..2f4ed512 100644 --- a/bash-5.1/builtins_rust/shopt/src/lib.rs +++ b/bash-5.1/builtins_rust/shopt/src/lib.rs @@ -926,7 +926,7 @@ pub unsafe extern "C" fn r_shopt_builtin(mut list: *mut WordList) -> i32 { reset_internal_getopt(); let psuoq = CString::new("psuoq").expect("CString::new failed"); loop { - opt = internal_getopt( list, psuoq.as_ptr() as *mut i8); + opt = internal_getopt( list, psuoq.as_ptr() as *mut libc::c_char); if !(opt != -(1 as i32)) { break; } diff --git a/bash-5.1/builtins_rust/source/src/lib.rs b/bash-5.1/builtins_rust/source/src/lib.rs index 190eb0a0..7ce136b0 100644 --- a/bash-5.1/builtins_rust/source/src/lib.rs +++ b/bash-5.1/builtins_rust/source/src/lib.rs @@ -307,7 +307,7 @@ pub extern "C" fn r_source_builtin (list:* mut WordList)->i32 let mut llist:* mut WordList = loptend.clone(); if list == std::ptr::null_mut() { - builtin_error (b"filename argument required\0" as *const u8 as *const i8 as *mut i8 ); + builtin_error (b"filename argument required\0" as *const u8 as *const libc::c_char as *mut libc::c_char ); builtin_usage (); return EX_USAGE; } @@ -345,7 +345,7 @@ pub extern "C" fn r_source_builtin (list:* mut WordList)->i32 } } - begin_unwind_frame (b"source\0" as *const u8 as *const i8 as *mut i8); + begin_unwind_frame (b"source\0" as *const u8 as *const libc::c_char as *mut libc::c_char); let xf:Functions=Functions{f_xfree :xfree}; add_unwind_protect (xf, filename); @@ -381,7 +381,7 @@ pub extern "C" fn r_source_builtin (list:* mut WordList)->i32 result = source_file (filename, (list !=std::ptr::null_mut() && (*list).next !=std::ptr::null_mut()) as i32); - run_unwind_frame (b"source\0" as *const u8 as *const i8 as *mut i8); + run_unwind_frame (b"source\0" as *const u8 as *const libc::c_char as *mut libc::c_char); return result; } diff --git a/bash-5.1/builtins_rust/type/src/lib.rs b/bash-5.1/builtins_rust/type/src/lib.rs index 497a021c..fc4c26dd 100644 --- a/bash-5.1/builtins_rust/type/src/lib.rs +++ b/bash-5.1/builtins_rust/type/src/lib.rs @@ -100,7 +100,7 @@ macro_rules! MP_RMDOT{ #[macro_export] macro_rules! STREQ{ ($a:expr,$b:expr) =>{ - *$a as i8 == *$b as i8 && libc::strcmp($a,$b)==0 + *$a as libc::c_char == *$b as libc::c_char && libc::strcmp($a,$b)==0 } } @@ -114,11 +114,11 @@ macro_rules! SIZEOFWORD{ #[repr(C)] pub struct SHELL_VAR { - name:*mut i8, - value:*mut i8, - exportstr:*mut i8, + name:*mut libc::c_char, + value:*mut libc::c_char, + exportstr:*mut libc::c_char, dynamic_value:*mut fn(v:* mut SHELL_VAR)->*mut SHELL_VAR, - assign_func:* mut fn(v:* mut SHELL_VAR,str1:* mut i8,t:i64,str2:* mut i8)->*mut SHELL_VAR, + assign_func:* mut fn(v:* mut SHELL_VAR,str1:* mut libc::c_char,t:i64,str2:* mut libc::c_char)->*mut SHELL_VAR, attributes:i32, context:i32 } @@ -126,9 +126,9 @@ pub struct SHELL_VAR { #[repr (C)] #[derive(Copy,Clone)] pub struct alias { - name :*mut i8, - value :*mut i8 , - flags:i8 + name :*mut libc::c_char, + value :*mut libc::c_char , + flags:libc::c_char } type sh_builtin_func_t = fn(WordList) -> i32; @@ -192,7 +192,7 @@ pub union REDIRECT { flags: i32 , instruction:r_instruction, redirectee:REDIRECTEE, - here_doc_eof:*mut i8 + here_doc_eof:*mut libc::c_char } #[repr(C)] @@ -262,14 +262,14 @@ pub struct function_def { line: i32 , name:*mut WordDesc, command:*mut COMMAND, - source_file:*mut i8 + source_file:*mut libc::c_char } #[repr(C)] pub struct group_com { ignore: i32 , command:*mut COMMAND, - source_file:*mut i8 + source_file:*mut libc::c_char } #[repr(C)] @@ -316,7 +316,7 @@ pub struct subshell_com { #[repr(C)] pub struct coproc_com { flags:i32, - name:*mut i8, + name:*mut libc::c_char, command:*mut COMMAND } @@ -345,7 +345,7 @@ macro_rules! FS_EXEC_ONLY { macro_rules! ABSPATH { ($s :expr) => { unsafe { - char::from(*($s as *mut i8) as u8) }== '/'; + char::from(*($s as *mut libc::c_char) as u8) }== '/'; // $x == '/'; } @@ -354,27 +354,27 @@ macro_rules! ABSPATH { extern "C" { fn reset_internal_getopt(); - fn internal_getopt (list:*mut WordList , opts:*mut i8)->i32; + fn internal_getopt (list:*mut WordList , opts:*mut libc::c_char)->i32; fn builtin_usage(); fn builtin_help(); - fn sh_notfound (name:* mut i8); + fn sh_notfound (name:* mut libc::c_char); fn sh_chkwrite (ret:i32)->i32; - fn find_alias(alia :*mut i8) ->alias_t; - fn sh_single_quote(quote: *const i8) -> *mut i8; - fn find_reserved_word(word: *mut i8)->i32; - fn find_function (name:* const i8)-> *mut SHELL_VAR; - fn named_function_string (name: *mut i8, cmd:* mut COMMAND, i:i32)->* mut i8; - fn find_shell_builtin(builtin: *mut i8) -> *mut i8; - fn find_special_builtin(builtins: *mut i8) -> *mut sh_builtin_func_t; - fn absolute_program(program:*const i8) -> i32; - fn file_status(status :*const i8) -> i32 ; - fn phash_search(search:*const i8) -> *mut i8; - fn conf_standard_path() -> *mut i8; - fn find_in_path(path1:*const i8, path2:*mut i8, num: i32) -> *mut i8; - fn find_user_command(cmd:*mut i8) -> *mut i8; - fn user_command_matches(cmd:*const i8, num1:i32, num2:i32) -> *mut i8; - fn sh_makepath(path:*const i8, path1:*const i8, i: i32) -> *mut i8; - //fn find_alias(alia : *mut i8) -> *mut alias_t; + fn find_alias(alia :*mut libc::c_char) ->alias_t; + fn sh_single_quote(quote: *const libc::c_char) -> *mut libc::c_char; + fn find_reserved_word(word: *mut libc::c_char)->i32; + fn find_function (name:* const libc::c_char)-> *mut SHELL_VAR; + fn named_function_string (name: *mut libc::c_char, cmd:* mut COMMAND, i:i32)->* mut libc::c_char; + fn find_shell_builtin(builtin: *mut libc::c_char) -> *mut libc::c_char; + fn find_special_builtin(builtins: *mut libc::c_char) -> *mut sh_builtin_func_t; + fn absolute_program(program:*const libc::c_char) -> i32; + fn file_status(status :*const libc::c_char) -> i32 ; + fn phash_search(search:*const libc::c_char) -> *mut libc::c_char; + fn conf_standard_path() -> *mut libc::c_char; + fn find_in_path(path1:*const libc::c_char, path2:*mut libc::c_char, num: i32) -> *mut libc::c_char; + fn find_user_command(cmd:*mut libc::c_char) -> *mut libc::c_char; + fn user_command_matches(cmd:*const libc::c_char, num1:i32, num2:i32) -> *mut libc::c_char; + fn sh_makepath(path:*const libc::c_char, path1:*const libc::c_char, i: i32) -> *mut libc::c_char; + //fn find_alias(alia : *mut libc::c_char) -> *mut alias_t; static expand_aliases : i32; static mut loptend:*mut WordList; static posixly_correct:i32; @@ -396,27 +396,27 @@ pub unsafe extern "C" fn r_type_builtin (mut list :*mut WordList) -> i32 { unsafe{ this = list; while this != std::ptr::null_mut() && char::from((*(*(*this).word).word) as u8) == '-' { - let mut flag = (((*(*this).word).word) as usize + 1) as *mut i8; + let mut flag = (((*(*this).word).word) as usize + 1) as *mut libc::c_char; let mut c_str_type = CString::new("type").unwrap(); let c_str_type1 = CString::new("-type").unwrap(); let c_str_path = CString::new("path").unwrap(); let c_str_path1 = CString::new("-path").unwrap(); let c_str_all = CString::new("all").unwrap(); let c_str_all1 = CString::new("-all").unwrap(); - if STREQ!(flag, c_str_type.as_ptr() as *mut i8 ) || STREQ!(flag, c_str_type1.as_ptr() as *mut i8) { + if STREQ!(flag, c_str_type.as_ptr() as *mut libc::c_char ) || STREQ!(flag, c_str_type1.as_ptr() as *mut libc::c_char) { unsafe { - *((((*(*this).word).word) as usize + 1) as *mut i8) = 't' as i8 ; - *((((*(*this).word).word) as usize + 2) as *mut i8) = '\0' as i8 ; + *((((*(*this).word).word) as usize + 1) as *mut libc::c_char) = 't' as libc::c_char ; + *((((*(*this).word).word) as usize + 2) as *mut libc::c_char) = '\0' as libc::c_char ; } } - else if STREQ!(flag, c_str_path.as_ptr() as *mut i8) || STREQ!(flag, c_str_path1.as_ptr() as *mut i8){ - *((((*(*this).word).word) as usize + 1) as *mut i8) = 'p' as i8 ; - *((((*(*this).word).word) as usize + 2) as *mut i8) = '\0' as i8 ; + else if STREQ!(flag, c_str_path.as_ptr() as *mut libc::c_char) || STREQ!(flag, c_str_path1.as_ptr() as *mut libc::c_char){ + *((((*(*this).word).word) as usize + 1) as *mut libc::c_char) = 'p' as libc::c_char ; + *((((*(*this).word).word) as usize + 2) as *mut libc::c_char) = '\0' as libc::c_char ; } - else if STREQ!(flag, c_str_all.as_ptr() as *mut i8) || STREQ!(flag, c_str_all1.as_ptr() as *mut i8) { - *((((*(*this).word).word) as usize + 1) as *mut i8) = 'a' as i8 ; - *((((*(*this).word).word) as usize + 2) as *mut i8) = '\0' as i8 ; + else if STREQ!(flag, c_str_all.as_ptr() as *mut libc::c_char) || STREQ!(flag, c_str_all1.as_ptr() as *mut libc::c_char) { + *((((*(*this).word).word) as usize + 1) as *mut libc::c_char) = 'a' as libc::c_char ; + *((((*(*this).word).word) as usize + 2) as *mut libc::c_char) = '\0' as libc::c_char ; } if (*this).next != std::ptr::null_mut(){ @@ -430,7 +430,7 @@ pub unsafe extern "C" fn r_type_builtin (mut list :*mut WordList) -> i32 { reset_internal_getopt(); let c_str_afptP = CString::new("afptP").unwrap(); - let mut opt = unsafe {internal_getopt(list,c_str_afptP.as_ptr() as *mut i8) } ; + let mut opt = unsafe {internal_getopt(list,c_str_afptP.as_ptr() as *mut libc::c_char) } ; while opt != -1{ let optu8:u8= opt as u8; let optChar:char=char::from(optu8); @@ -455,7 +455,7 @@ pub unsafe extern "C" fn r_type_builtin (mut list :*mut WordList) -> i32 { } } } - opt = internal_getopt (list, c_str_afptP.as_ptr() as * mut i8); + opt = internal_getopt (list, c_str_afptP.as_ptr() as * mut libc::c_char); } list = loptend; while list != std::ptr::null_mut() { @@ -486,15 +486,15 @@ pub unsafe extern "C" fn r_type_builtin (mut list :*mut WordList) -> i32 { } -fn describe_command (command : *mut i8, dflags : i32) -> i32 { +fn describe_command (command : *mut libc::c_char, dflags : i32) -> i32 { let mut found : i32 = 0; let mut i : i32; let mut found_file : i32 = 0; let mut f : i32; let mut all : i32; - let mut full_path : *mut i8; - let mut x : *mut i8; - let mut pathlist : *mut i8; + let mut full_path : *mut libc::c_char; + let mut x : *mut libc::c_char; + let mut pathlist : *mut libc::c_char; let mut func : *mut SHELL_VAR = 0 as *mut SHELL_VAR; // let mut alias : *mut alias_t; @@ -514,7 +514,7 @@ fn describe_command (command : *mut i8, dflags : i32) -> i32 { { if (dflags & CDESC_TYPE!()) != 0{ unsafe { - libc::puts("alias" as *const i8 ); + libc::puts("alias" as *const libc::c_char ); } } else if (dflags & CDESC_SHORTDESC!()) != 0 { @@ -570,7 +570,7 @@ fn describe_command (command : *mut i8, dflags : i32) -> i32 { } } else if dflags & CDESC_SHORTDESC!() != 0 { - let mut result : *mut i8; + let mut result : *mut libc::c_char; unsafe { println!("{:?} is a function",CStr::from_ptr(command)); result = named_function_string (command, function_cell(find_function (command)), FUNC_MULTILINE!()|FUNC_EXTERNAL!()); diff --git a/bash-5.1/builtins_rust/ulimit/src/lib.rs b/bash-5.1/builtins_rust/ulimit/src/lib.rs index 6acb9796..283ed16c 100644 --- a/bash-5.1/builtins_rust/ulimit/src/lib.rs +++ b/bash-5.1/builtins_rust/ulimit/src/lib.rs @@ -22,15 +22,15 @@ pub struct RESOURCE_LIMITS{ option : i32, /* The ulimit option for this limit. */ parameter : i32, /* Parameter to pass to get_limit (). */ block_factor : i32, /* Blocking factor for specific limit. */ - description : *const i8, /* Descriptive string to output. */ - units : *const i8 /* scale */ + description : *const libc::c_char, /* Descriptive string to output. */ + units : *const libc::c_char /* scale */ } #[repr (C)] #[derive(Copy,Clone)] pub struct _cmd { cmd : i32, - arg : *mut i8 + arg : *mut libc::c_char } #[repr (C)] @@ -41,9 +41,9 @@ pub struct user_info { euid : uid_t, gid : gid_t, egid : gid_t, - user_name : *mut i8, - shell :*mut i8, - home_dir : *mut i8 + user_name : *mut libc::c_char, + shell :*mut libc::c_char, + home_dir : *mut libc::c_char } #[macro_export] @@ -233,40 +233,40 @@ const limits: [ RESOURCE_LIMITS_T;18] =[ parameter: __RLIMIT_RTTIME as i32, block_factor: 1 as i32, description: b"real-time non-blocking time\0" as *const u8 - as *const i8, - units: b"microseconds\0" as *const u8 as *const i8, + as *const libc::c_char, + units: b"microseconds\0" as *const u8 as *const libc::c_char, }}, { RESOURCE_LIMITS { option: 'c' as i32, parameter: RLIMIT_CORE as i32, block_factor: -(2 as i32), - description: b"core file size\0" as *const u8 as *const i8, - units: b"blocks\0" as *const u8 as *const i8, + description: b"core file size\0" as *const u8 as *const libc::c_char, + units: b"blocks\0" as *const u8 as *const libc::c_char, }}, { RESOURCE_LIMITS { option: 'd' as i32, parameter: RLIMIT_DATA as i32, block_factor: 1024 as i32, - description: b"data seg size\0" as *const u8 as *const i8, - units: b"kbytes\0" as *const u8 as *const i8, + description: b"data seg size\0" as *const u8 as *const libc::c_char, + units: b"kbytes\0" as *const u8 as *const libc::c_char, }}, { RESOURCE_LIMITS { option: 'e' as i32, parameter: __RLIMIT_NICE as i32, block_factor: 1 as i32, - description: b"scheduling priority\0" as *const u8 as *const i8, - units: 0 as *const libc::c_void as *mut libc::c_void as *mut i8, + description: b"scheduling priority\0" as *const u8 as *const libc::c_char, + units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char, }}, { RESOURCE_LIMITS { option: 'f' as i32, parameter: RLIMIT_FSIZE as i32, block_factor: -(2 as i32), - description: b"file size\0" as *const u8 as *const i8, - units: b"blocks\0" as *const u8 as *const i8, + description: b"file size\0" as *const u8 as *const libc::c_char, + units: b"blocks\0" as *const u8 as *const libc::c_char, }}, { @@ -274,8 +274,8 @@ const limits: [ RESOURCE_LIMITS_T;18] =[ option: 'i' as i32, parameter: __RLIMIT_SIGPENDING as i32, block_factor: 1 as i32, - description: b"pending signals\0" as *const u8 as *const i8, - units: 0 as *const libc::c_void as *mut libc::c_void as *mut i8, + description: b"pending signals\0" as *const u8 as *const libc::c_char, + units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char, } }, @@ -283,88 +283,88 @@ const limits: [ RESOURCE_LIMITS_T;18] =[ option: 'l' as i32, parameter: __RLIMIT_MEMLOCK as i32, block_factor: 1024 as i32, - description: b"max locked memory\0" as *const u8 as *const i8, - units: b"kbytes\0" as *const u8 as *const i8, + description: b"max locked memory\0" as *const u8 as *const libc::c_char, + units: b"kbytes\0" as *const u8 as *const libc::c_char, }}, { RESOURCE_LIMITS { option: 'm' as i32, parameter: __RLIMIT_RSS as i32, block_factor: 1024 as i32, - description: b"max memory size\0" as *const u8 as *const i8, - units: b"kbytes\0" as *const u8 as *const i8, + description: b"max memory size\0" as *const u8 as *const libc::c_char, + units: b"kbytes\0" as *const u8 as *const libc::c_char, }}, { RESOURCE_LIMITS { option: 'n' as i32, parameter: RLIMIT_NOFILE as i32, block_factor: 1 as i32, - description: b"open files\0" as *const u8 as *const i8, - units: 0 as *const libc::c_void as *mut libc::c_void as *mut i8, + description: b"open files\0" as *const u8 as *const libc::c_char, + units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char, }}, { RESOURCE_LIMITS { option: 'p' as i32, parameter: 257 as i32, block_factor: 512 as i32, - description: b"pipe size\0" as *const u8 as *const i8, - units: b"512 bytes\0" as *const u8 as *const i8, + description: b"pipe size\0" as *const u8 as *const libc::c_char, + units: b"512 bytes\0" as *const u8 as *const libc::c_char, }}, { RESOURCE_LIMITS { option: 'q' as i32, parameter: __RLIMIT_MSGQUEUE as i32, block_factor: 1 as i32, - description: b"POSIX message queues\0" as *const u8 as *const i8, - units: b"bytes\0" as *const u8 as *const i8, + description: b"POSIX message queues\0" as *const u8 as *const libc::c_char, + units: b"bytes\0" as *const u8 as *const libc::c_char, }}, { RESOURCE_LIMITS { option: 'r' as i32, parameter: __RLIMIT_RTPRIO as i32, block_factor: 1 as i32, - description: b"real-time priority\0" as *const u8 as *const i8, - units: 0 as *const libc::c_void as *mut libc::c_void as *mut i8, + description: b"real-time priority\0" as *const u8 as *const libc::c_char, + units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char, }}, { RESOURCE_LIMITS { option: 's' as i32, parameter: RLIMIT_STACK as i32, block_factor: 1024 as i32, - description: b"stack size\0" as *const u8 as *const i8, - units: b"kbytes\0" as *const u8 as *const i8, + description: b"stack size\0" as *const u8 as *const libc::c_char, + units: b"kbytes\0" as *const u8 as *const libc::c_char, }}, { RESOURCE_LIMITS { option: 't' as i32, parameter: RLIMIT_CPU as i32, block_factor: 1 as i32, - description: b"cpu time\0" as *const u8 as *const i8, - units: b"seconds\0" as *const u8 as *const i8, + description: b"cpu time\0" as *const u8 as *const libc::c_char, + units: b"seconds\0" as *const u8 as *const libc::c_char, }}, { RESOURCE_LIMITS { option: 'u' as i32, parameter: __RLIMIT_NPROC as i32, block_factor: 1 as i32, - description: b"max user processes\0" as *const u8 as *const i8, - units: 0 as *const libc::c_void as *mut libc::c_void as *mut i8, + description: b"max user processes\0" as *const u8 as *const libc::c_char, + units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char, }}, { RESOURCE_LIMITS { option: 'v' as i32, parameter: RLIMIT_AS as i32, block_factor: 1024 as i32, - description: b"virtual memory\0" as *const u8 as *const i8, - units: b"kbytes\0" as *const u8 as *const i8, + description: b"virtual memory\0" as *const u8 as *const libc::c_char, + units: b"kbytes\0" as *const u8 as *const libc::c_char, }}, { RESOURCE_LIMITS { option: 'x' as i32, parameter: __RLIMIT_LOCKS as i32, block_factor: 1 as i32, - description: b"file locks\0" as *const u8 as *const i8, - units: 0 as *const libc::c_void as *mut libc::c_void as *mut i8, + description: b"file locks\0" as *const u8 as *const libc::c_char, + units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char, }}, { RESOURCE_LIMITS { @@ -372,8 +372,8 @@ const limits: [ RESOURCE_LIMITS_T;18] =[ parameter: -1, block_factor:-1, description: 0 as *const libc::c_void as *mut libc::c_void - as *mut i8, - units: 0 as *const libc::c_void as *mut libc::c_void as *mut i8, + as *mut libc::c_char, + units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char, }} ]; @@ -381,17 +381,17 @@ extern "C" { fn reset_internal_getopt(); fn xmalloc(_: u64) -> *mut libc::c_void; fn xrealloc(_: *mut libc::c_void, _: u64) -> *mut libc::c_void; - fn all_digits(_: *const i8) -> i32; + fn all_digits(_: *const libc::c_char) -> i32; fn sh_chkwrite(_: i32) -> i32; - fn internal_getopt(_: *mut WordList, _: *mut i8) -> i32; - fn strerror(_: i32) -> *mut i8; - fn sprintf(_: *mut i8, _: *const i8, _: ...) -> i32; - fn string_to_rlimtype(_: *mut i8 ) -> rlim_t; + fn internal_getopt(_: *mut WordList, _: *mut libc::c_char) -> i32; + fn strerror(_: i32) -> *mut libc::c_char; + fn sprintf(_: *mut libc::c_char, _: *const libc::c_char, _: ...) -> i32; + fn string_to_rlimtype(_: *mut libc::c_char ) -> rlim_t; fn getdtablesize() -> i32; fn builtin_help (); fn builtin_usage(); - fn sh_erange (s:* mut i8, desc:* mut i8); - fn sh_invalidnum(arg1: *mut i8); + fn sh_erange (s:* mut libc::c_char, desc:* mut libc::c_char); + fn sh_invalidnum(arg1: *mut libc::c_char); fn __errno_location() -> *mut i32; fn getrlimit(__resource: __rlimit_resource_t, __rlimits: *mut rlimit) -> i32; fn setrlimit( @@ -399,17 +399,17 @@ extern "C" { __rlimits: *const rlimit, ) -> i32; - fn builtin_error(_: *const i8, _: ...); + fn builtin_error(_: *const libc::c_char, _: ...); fn getmaxchild() -> i64; fn print_rlimtype(_: rlim_t, _: i32); static mut loptend: *mut WordList; - static mut list_optarg: *mut i8; + static mut list_optarg: *mut libc::c_char; static mut posixly_correct:i32 ; static mut current_user: user_info; } -static mut optstring:[ i8;4 + 2 * NCMDS!() as usize] = [0;4 + 2 * NCMDS!() as usize]; +static mut optstring:[ libc::c_char;4 + 2 * NCMDS!() as usize] = [0;4 + 2 * NCMDS!() as usize]; static mut cmdlist : *mut ULCMD = 0 as *const ULCMD as *mut ULCMD; static mut ncmd : i32 = 0; @@ -432,7 +432,7 @@ fn _findlim (opt:i32) -> i32{ pub unsafe extern "C" fn r_ulimit_builtin(mut list: *mut WordList) -> i32{ //println!("enter ulimit set by huanhuan"); - let mut s : *mut i8; + let mut s : *mut libc::c_char; let mut c : i32 ; let mut limind : i32 ; let mut mode : i32 = 0 ; @@ -441,23 +441,23 @@ pub unsafe extern "C" fn r_ulimit_builtin(mut list: *mut WordList) -> i32{ if optstring[0] == 0 { //println!(" optstring[0] == 0"); s = optstring.as_mut_ptr(); - s = (s as usize ) as *mut i8; - *s = 'a' as i8; - s = (s as usize + 1) as *mut i8; - *s = 'S' as i8; - s = (s as usize + 1) as *mut i8; - *s = 'H' as i8; + s = (s as usize ) as *mut libc::c_char; + *s = 'a' as libc::c_char; + s = (s as usize + 1) as *mut libc::c_char; + *s = 'S' as libc::c_char; + s = (s as usize + 1) as *mut libc::c_char; + *s = 'H' as libc::c_char; c = 0 ; for i in 0..17 { if limits[i].option > 0{ //println!("limits[i].option > 0 is {}",limits[i].option); - s = (s as usize + 1) as *mut i8; - *s = limits[i].option as i8; - s = (s as usize + 1) as *mut i8; - *s = ';' as i8; + s = (s as usize + 1) as *mut libc::c_char; + *s = limits[i].option as libc::c_char; + s = (s as usize + 1) as *mut libc::c_char; + *s = ';' as libc::c_char; } } - *s = '\0' as i8; + *s = '\0' as libc::c_char; } //println! ("cmdlistsz is {}",cmdlistsz); @@ -472,7 +472,7 @@ pub unsafe extern "C" fn r_ulimit_builtin(mut list: *mut WordList) -> i32{ } ncmd = 0; reset_internal_getopt (); - opt = internal_getopt(list, optstring.as_ptr() as *mut i8); + opt = internal_getopt(list, optstring.as_ptr() as *mut libc::c_char); //println! ("get opt 2 is {}",opt); while opt != -1 { //println!("opt is {}", opt); @@ -517,7 +517,7 @@ pub unsafe extern "C" fn r_ulimit_builtin(mut list: *mut WordList) -> i32{ } } - opt = internal_getopt (list, optstring.as_ptr() as * mut i8); + opt = internal_getopt (list, optstring.as_ptr() as * mut libc::c_char); } // println! ("now cmd1 opt is {:?}",(*((cmdlist as usize + (ncmd as usize)*std::mem::size_of::()) @@ -582,9 +582,9 @@ pub unsafe extern "C" fn r_ulimit_builtin(mut list: *mut WordList) -> i32{ //println!("now get limind is {}",limind); if limind == -1 { unsafe { - builtin_error(b"%s: bad command : %s\0" as *const u8 as *const i8, + builtin_error(b"%s: bad command : %s\0" as *const u8 as *const libc::c_char, (*cmdlist.offset(d as isize)).cmd, - strerror(*__errno_location()) as *const i8); + strerror(*__errno_location()) as *const libc::c_char); } return EX_USAGE; } @@ -607,7 +607,7 @@ pub unsafe extern "C" fn r_ulimit_builtin(mut list: *mut WordList) -> i32{ } -unsafe fn ulimit_internal (cmd : i32 , cmdarg :*mut i8,mut mode : i32, multiple : i32) -> i32 { +unsafe fn ulimit_internal (cmd : i32 , cmdarg :*mut libc::c_char,mut mode : i32, multiple : i32) -> i32 { let mut opt : i32 ; let mut limind : i32 ; @@ -642,8 +642,8 @@ unsafe fn ulimit_internal (cmd : i32 , cmdarg :*mut i8,mut mode : i32, multiple if opt < 0 { unsafe { - builtin_error(b"%s: cannot get limit : %s\0" as *const u8 as *const i8, limits[limind as usize].description, - strerror(*__errno_location()) as *const i8); + builtin_error(b"%s: cannot get limit : %s\0" as *const u8 as *const libc::c_char, limits[limind as usize].description, + strerror(*__errno_location()) as *const libc::c_char); } return EXECUTION_FAILURE!(); @@ -664,14 +664,14 @@ unsafe fn ulimit_internal (cmd : i32 , cmdarg :*mut i8,mut mode : i32, multiple let mut c_str_hard = CString::new("hard").unwrap(); let mut c_str_soft = CString::new("soft").unwrap(); let mut c_str_unlimited = CString::new("unlimited").unwrap(); - if unsafe{STREQ!(cmdarg,c_str_hard.as_ptr() as *mut i8 )}{ + if unsafe{STREQ!(cmdarg,c_str_hard.as_ptr() as *mut libc::c_char )}{ real_limit = hard_limit; } - else if unsafe{STREQ!(cmdarg, c_str_soft.as_ptr() as *mut i8)}{ + else if unsafe{STREQ!(cmdarg, c_str_soft.as_ptr() as *mut libc::c_char)}{ real_limit = soft_limit; } - else if unsafe{STREQ!(cmdarg, c_str_unlimited.as_ptr() as *mut i8)}{ + else if unsafe{STREQ!(cmdarg, c_str_unlimited.as_ptr() as *mut libc::c_char)}{ real_limit = RLIM_INFINITY!(); } @@ -683,7 +683,7 @@ unsafe fn ulimit_internal (cmd : i32 , cmdarg :*mut i8,mut mode : i32, multiple if (real_limit / block_factor as i64) != limit { // println!("real_limit / block_factor as i64) != limit"); let c_str_limit =CString::new("limit").unwrap(); - unsafe {sh_erange (cmdarg,c_str_limit.as_ptr() as *mut i8)}; + unsafe {sh_erange (cmdarg,c_str_limit.as_ptr() as *mut libc::c_char)}; return EXECUTION_FAILURE!(); } //println!("real_limit / block_factor as i64) == limit"); @@ -694,8 +694,8 @@ unsafe fn ulimit_internal (cmd : i32 , cmdarg :*mut i8,mut mode : i32, multiple return EXECUTION_FAILURE!(); } if set_limit (limind, real_limit, mode) < 0 { - builtin_error(b"%s: cannot modify limit : %s\0" as *const u8 as *const i8, limits[limind as usize].description, - strerror(*__errno_location()) as *const i8); + builtin_error(b"%s: cannot modify limit : %s\0" as *const u8 as *const libc::c_char, limits[limind as usize].description, + strerror(*__errno_location()) as *const libc::c_char); return EXECUTION_FAILURE!(); } return EXECUTION_SUCCESS!(); @@ -728,7 +728,7 @@ fn get_limit (mut ind : i32, softlim : *mut RLIMTYPE, hardlim : *mut RLIMTYPE ) } RLIMIT_VIRTMEM!() => { - return unsafe {getmaxvm(softlim, hardlim as *mut i8) }; + return unsafe {getmaxvm(softlim, hardlim as *mut libc::c_char) }; } RLIMIT_MAXUPROC!() => { if getmaxuprc ((value as usize) as *mut u64) < 0 { @@ -819,7 +819,7 @@ fn set_limit (ind : i32, newlim : RLIMTYPE, mode : i32) -> i32{ } } -unsafe fn getmaxvm(softlim : *mut RLIMTYPE , hardlim : *mut i8) -> i32 { +unsafe fn getmaxvm(softlim : *mut RLIMTYPE , hardlim : *mut libc::c_char) -> i32 { let mut datalim : rlimit = rlimit { rlim_cur: 0, rlim_max: 0 }; let mut stacklim : rlimit = rlimit { rlim_cur: 0, rlim_max: 0 }; @@ -831,7 +831,7 @@ unsafe fn getmaxvm(softlim : *mut RLIMTYPE , hardlim : *mut i8) -> i32 { return -1; } *softlim = (datalim.rlim_cur as i64 / 1024 as i64) + (stacklim.rlim_cur as i64/1024 as i64); - *hardlim = ((datalim.rlim_max as i64) /1024 as i64) as i8 + (stacklim.rlim_max as i64/1024 as i64) as i8; + *hardlim = ((datalim.rlim_max as i64) /1024 as i64) as libc::c_char + (stacklim.rlim_max as i64/1024 as i64) as libc::c_char; return 0; } @@ -888,8 +888,8 @@ fn print_all_limits (mut mode : i32) { else if unsafe { *__errno_location() != libc::EINVAL } { unsafe { - builtin_error(b"%s: cannot get limit : %s\0" as *const u8 as *const i8, limits[i as usize].description, - strerror(*__errno_location()) as *const i8); + builtin_error(b"%s: cannot get limit : %s\0" as *const u8 as *const libc::c_char, limits[i as usize].description, + strerror(*__errno_location()) as *const libc::c_char); } } i = i+1; @@ -899,7 +899,7 @@ fn print_all_limits (mut mode : i32) { fn printone (limind : i32, curlim :RLIMTYPE , pdesc : i32){ // println!("enter printone"); //println!("now get curlim is {}",curlim); - let mut unitstr :[ i8; 64] = [0 ; 64]; + let mut unitstr :[ libc::c_char; 64] = [0 ; 64]; let mut factor : i32 ; // println!("limind1 is {} ",limind); @@ -908,7 +908,7 @@ fn printone (limind : i32, curlim :RLIMTYPE , pdesc : i32){ if !limits[limind as usize].units.is_null(){ unsafe { //println!("ffffffffff11"); - sprintf (unitstr.as_mut_ptr(), b"(%s, -%c) \0" as *const u8 as *const i8, + sprintf (unitstr.as_mut_ptr(), b"(%s, -%c) \0" as *const u8 as *const libc::c_char, limits[limind as usize].units, limits[limind as usize].option); } @@ -916,7 +916,7 @@ fn printone (limind : i32, curlim :RLIMTYPE , pdesc : i32){ } else { unsafe { - sprintf (unitstr.as_mut_ptr(),b"(-%c) \0" as *const u8 as *const i8, + sprintf (unitstr.as_mut_ptr(),b"(-%c) \0" as *const u8 as *const libc::c_char, limits[limind as usize].option); } @@ -986,8 +986,8 @@ fn set_all_limits (mut mode : i32 , newlim : RLIMTYPE) -> i32 { while limits[i as usize].option > 0 { if set_limit (i, newlim, mode) < 0 { unsafe { - builtin_error(b"%s: cannot modify limit : %s\0" as *const u8 as *const i8, limits[i as usize].description, - strerror(*__errno_location()) as *const i8); + builtin_error(b"%s: cannot modify limit : %s\0" as *const u8 as *const libc::c_char, limits[i as usize].description, + strerror(*__errno_location()) as *const libc::c_char); } retval = 1; i = i +1; diff --git a/bash-5.1/builtins_rust/umask/src/lib.rs b/bash-5.1/builtins_rust/umask/src/lib.rs index 2cca8c7b..e45a50f7 100644 --- a/bash-5.1/builtins_rust/umask/src/lib.rs +++ b/bash-5.1/builtins_rust/umask/src/lib.rs @@ -402,7 +402,7 @@ extern "C" fn r_parse_symbolic_mode(mode:*mut c_char,initial_bits:i32)->i32{ /* Now perform the operation or return an error for a bad permission string. */ - if *s != 0 || *s == ',' as i8{ + if *s != 0 || *s == ',' as libc::c_char{ if who != 0{ perm &= who; } @@ -420,7 +420,7 @@ extern "C" fn r_parse_symbolic_mode(mode:*mut c_char,initial_bits:i32)->i32{ /* No other values are possible. */ _ => { } } - if *s == '\0' as i8{ + if *s == '\0' as libc::c_char{ break; } else { diff --git a/bash-5.1/builtins_rust/wait/src/lib.rs b/bash-5.1/builtins_rust/wait/src/lib.rs index 8eb61965..6cf0626b 100644 --- a/bash-5.1/builtins_rust/wait/src/lib.rs +++ b/bash-5.1/builtins_rust/wait/src/lib.rs @@ -407,7 +407,7 @@ pub extern "C" fn r_wait_builtin(mut list:*mut WordList)->i32{ //if defined (JOB_CONTROL) //else if w != std::ptr::null_mut() && (w as u8)as char == '%' { - else if *w != 0 && *w == '%' as i8 { + else if *w != 0 && *w == '%' as libc::c_char { /* Must be a job spec. Check it out. */ let job:i32; let mut set:SigSet = SigSet::empty(); diff --git a/record.txt b/record.txt index 4457aaa8..0440cf0a 100644 --- a/record.txt +++ b/record.txt @@ -39,3 +39,4 @@ 61 62 63 +64 -- Gitee