From f83828409e3beaf027f0d81653e1d7b2fa1d858c Mon Sep 17 00:00:00 2001 From: liutong Date: Tue, 27 Jun 2023 12:24:05 +0800 Subject: [PATCH] fix shopt error --- bash-5.1/builtins_rust/alias/src/lib.rs | 4 +- bash-5.1/builtins_rust/bind/src/lib.rs | 4 +- bash-5.1/builtins_rust/break_1/src/lib.rs | 4 +- .../builtins_rust/builtin/src/intercdep.rs | 4 +- bash-5.1/builtins_rust/caller/src/lib.rs | 4 +- bash-5.1/builtins_rust/cd/Cargo.toml | 1 + bash-5.1/builtins_rust/cd/src/lib.rs | 14 +-- bash-5.1/builtins_rust/colon/src/lib.rs | 4 +- bash-5.1/builtins_rust/command/src/lib.rs | 16 +-- bash-5.1/builtins_rust/common/src/lib.rs | 37 ++++-- bash-5.1/builtins_rust/complete/src/lib.rs | 22 ++-- bash-5.1/builtins_rust/declare/src/lib.rs | 14 +-- bash-5.1/builtins_rust/echo/src/lib.rs | 4 +- bash-5.1/builtins_rust/enable/src/lib.rs | 4 +- bash-5.1/builtins_rust/eval/src/lib.rs | 4 +- bash-5.1/builtins_rust/exec/src/lib.rs | 6 +- bash-5.1/builtins_rust/fc/src/lib.rs | 14 +-- bash-5.1/builtins_rust/fg_bg/src/lib.rs | 14 +-- bash-5.1/builtins_rust/getopts/src/lib.rs | 14 +-- bash-5.1/builtins_rust/hash/src/lib.rs | 4 +- bash-5.1/builtins_rust/help/src/lib.rs | 4 +- .../builtins_rust/history/src/intercdep.rs | 4 +- bash-5.1/builtins_rust/jobs/src/lib.rs | 14 +-- bash-5.1/builtins_rust/kill/src/intercdep.rs | 18 +-- .../builtins_rust/mapfile/src/intercdep.rs | 4 +- .../builtins_rust/printf/src/intercdep.rs | 4 +- bash-5.1/builtins_rust/pushd/src/lib.rs | 18 +-- bash-5.1/builtins_rust/read/src/intercdep.rs | 4 +- bash-5.1/builtins_rust/rlet/src/intercdep.rs | 4 +- .../builtins_rust/rreturn/src/intercdep.rs | 4 +- bash-5.1/builtins_rust/set/src/lib.rs | 14 +-- .../builtins_rust/setattr/src/intercdep.rs | 22 ++-- bash-5.1/builtins_rust/setattr/src/lib.rs | 2 +- bash-5.1/builtins_rust/shift/src/intercdep.rs | 4 +- bash-5.1/builtins_rust/shopt/Cargo.toml | 1 + bash-5.1/builtins_rust/shopt/src/lib.rs | 116 +++++++++--------- bash-5.1/builtins_rust/source/src/lib.rs | 14 +-- .../builtins_rust/suspend/src/intercdep.rs | 4 +- bash-5.1/builtins_rust/test/src/intercdep.rs | 4 +- bash-5.1/builtins_rust/times/src/intercdep.rs | 4 +- bash-5.1/builtins_rust/trap/src/intercdep.rs | 4 +- bash-5.1/builtins_rust/type/src/lib.rs | 16 +-- bash-5.1/builtins_rust/ulimit/src/lib.rs | 4 +- bash-5.1/builtins_rust/umask/Cargo.toml | 2 +- bash-5.1/builtins_rust/umask/src/lib.rs | 4 +- record.txt | 1 + 46 files changed, 256 insertions(+), 230 deletions(-) diff --git a/bash-5.1/builtins_rust/alias/src/lib.rs b/bash-5.1/builtins_rust/alias/src/lib.rs index 3d44ddf0..3e72eae5 100644 --- a/bash-5.1/builtins_rust/alias/src/lib.rs +++ b/bash-5.1/builtins_rust/alias/src/lib.rs @@ -35,12 +35,12 @@ pub struct word_desc { pub word: *mut libc::c_char, pub flags: libc::c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[derive(Copy, Clone)] #[repr(C)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; #[derive(Copy, Clone)] diff --git a/bash-5.1/builtins_rust/bind/src/lib.rs b/bash-5.1/builtins_rust/bind/src/lib.rs index c9c07b9a..bb809ef6 100644 --- a/bash-5.1/builtins_rust/bind/src/lib.rs +++ b/bash-5.1/builtins_rust/bind/src/lib.rs @@ -10,7 +10,7 @@ use rcommon::{r_builtin_usage,r_sh_chkwrite}; //struct #[repr (C)] -pub struct WORD_DESC{ +pub struct WordDesc{ pub word:*mut c_char, pub flags:c_int, } @@ -19,7 +19,7 @@ pub struct WORD_DESC{ // #[derive(Copy,Clone)] pub struct WORD_LIST{ pub next:*mut WORD_LIST, - pub word:*mut WORD_DESC, + pub word:*mut WordDesc, } #[repr (C)] pub struct _keymap_entry{ diff --git a/bash-5.1/builtins_rust/break_1/src/lib.rs b/bash-5.1/builtins_rust/break_1/src/lib.rs index 4b0b067f..471d119a 100644 --- a/bash-5.1/builtins_rust/break_1/src/lib.rs +++ b/bash-5.1/builtins_rust/break_1/src/lib.rs @@ -6,7 +6,7 @@ extern crate nix; use std::ffi::CString; use libc::c_long; #[repr(C)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut libc::c_char, pub flags: libc::c_int } @@ -15,7 +15,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } // 屏蔽警告。 diff --git a/bash-5.1/builtins_rust/builtin/src/intercdep.rs b/bash-5.1/builtins_rust/builtin/src/intercdep.rs index d07f2e3f..e288b8eb 100644 --- a/bash-5.1/builtins_rust/builtin/src/intercdep.rs +++ b/bash-5.1/builtins_rust/builtin/src/intercdep.rs @@ -5,13 +5,13 @@ pub struct word_desc { pub word: *mut c_char, pub flags: c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[repr(C)] #[derive(Copy, Clone)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/caller/src/lib.rs b/bash-5.1/builtins_rust/caller/src/lib.rs index 7a80e48b..81ce36d0 100644 --- a/bash-5.1/builtins_rust/caller/src/lib.rs +++ b/bash-5.1/builtins_rust/caller/src/lib.rs @@ -13,13 +13,13 @@ pub struct word_desc { pub word: *mut c_char, pub flags: c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[repr(C)] #[derive(Copy, Clone)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/cd/Cargo.toml b/bash-5.1/builtins_rust/cd/Cargo.toml index 22128558..22ac0616 100644 --- a/bash-5.1/builtins_rust/cd/Cargo.toml +++ b/bash-5.1/builtins_rust/cd/Cargo.toml @@ -3,6 +3,7 @@ authors = ["huzhengming"] name = "rcd" version = "0.0.1" edition = "2018" +build = "../build.rs" [dependencies] diff --git a/bash-5.1/builtins_rust/cd/src/lib.rs b/bash-5.1/builtins_rust/cd/src/lib.rs index adde5faf..d7e5d544 100644 --- a/bash-5.1/builtins_rust/cd/src/lib.rs +++ b/bash-5.1/builtins_rust/cd/src/lib.rs @@ -5,7 +5,7 @@ use libc::{c_char, c_long, c_void}; use std::{ffi::{CString, CStr}}; #[repr(C)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut libc::c_char, pub flags:libc::c_int } @@ -14,7 +14,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } #[repr(i8)] @@ -57,7 +57,7 @@ pub struct PROCESS { #[derive(Copy,Clone)] pub union REDIRECTEE { dest:libc::c_int, - filename:* mut WORD_DESC + filename:* mut WordDesc } #[repr(C)] @@ -76,7 +76,7 @@ pub union REDIRECT { pub struct for_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -93,7 +93,7 @@ pub struct PATTERN_LIST { pub struct case_com { flags:libc::c_int, line:libc::c_int, - word:*mut WORD_DESC, + word:*mut WordDesc, clauses:*mut PATTERN_LIST } @@ -132,7 +132,7 @@ pub struct simple_com { pub struct function_def { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, command:*mut COMMAND, source_file:*mut c_char } @@ -148,7 +148,7 @@ pub struct group_com { pub struct select_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } diff --git a/bash-5.1/builtins_rust/colon/src/lib.rs b/bash-5.1/builtins_rust/colon/src/lib.rs index ed63b736..abfb2753 100644 --- a/bash-5.1/builtins_rust/colon/src/lib.rs +++ b/bash-5.1/builtins_rust/colon/src/lib.rs @@ -16,13 +16,13 @@ pub struct word_desc { pub word: *mut c_char, pub flags: c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[repr(C)] #[derive(Copy, Clone)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/command/src/lib.rs b/bash-5.1/builtins_rust/command/src/lib.rs index 17b09ef8..9b01d168 100644 --- a/bash-5.1/builtins_rust/command/src/lib.rs +++ b/bash-5.1/builtins_rust/command/src/lib.rs @@ -62,19 +62,19 @@ pub struct word_desc { pub word: *mut libc::c_char, pub flags: libc::c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[derive(Copy, Clone)] #[repr(C)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; #[derive(Copy, Clone)] #[repr(C)] pub union REDIRECTEE { pub dest: libc::c_int, - pub filename: *mut WORD_DESC, + pub filename: *mut WordDesc, } #[derive(Copy, Clone)] #[repr(C)] @@ -146,7 +146,7 @@ pub struct cond_com { pub flags: libc::c_int, pub line: libc::c_int, pub type_0: libc::c_int, - pub op: *mut WORD_DESC, + pub op: *mut WordDesc, pub left: *mut cond_com, pub right: *mut cond_com, } @@ -162,7 +162,7 @@ pub struct arith_com { pub struct select_com { pub flags: libc::c_int, pub line: libc::c_int, - pub name: *mut WORD_DESC, + pub name: *mut WordDesc, pub map_list: *mut WORD_LIST, pub action: *mut COMMAND, } @@ -177,7 +177,7 @@ pub struct group_com { pub struct function_def { pub flags: libc::c_int, pub line: libc::c_int, - pub name: *mut WORD_DESC, + pub name: *mut WordDesc, pub command: *mut COMMAND, pub source_file: *mut libc::c_char, } @@ -217,7 +217,7 @@ pub struct while_com { pub struct case_com { pub flags: libc::c_int, pub line: libc::c_int, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, pub clauses: *mut PATTERN_LIST, } pub type PATTERN_LIST = pattern_list; @@ -234,7 +234,7 @@ pub struct pattern_list { pub struct for_com { pub flags: libc::c_int, pub line: libc::c_int, - pub name: *mut WORD_DESC, + pub name: *mut WordDesc, pub map_list: *mut WORD_LIST, pub action: *mut COMMAND, } diff --git a/bash-5.1/builtins_rust/common/src/lib.rs b/bash-5.1/builtins_rust/common/src/lib.rs index 5862e87f..aed5697f 100644 --- a/bash-5.1/builtins_rust/common/src/lib.rs +++ b/bash-5.1/builtins_rust/common/src/lib.rs @@ -16,13 +16,13 @@ pub struct word_desc { pub word: *mut c_char, pub flags: c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[repr(C)] #[derive(Copy, Clone)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; @@ -78,7 +78,7 @@ pub struct COMMAND { #[derive(Copy,Clone)] pub union REDIRECTEE { dest:libc::c_int, /* Place to redirect REDIRECTOR to, or ... */ - filename:* mut WORD_DESC /* filename to redirect to. */ + filename:* mut WordDesc /* filename to redirect to. */ } #[repr(u8)] @@ -109,7 +109,7 @@ pub union REDIRECT { pub struct for_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -117,7 +117,7 @@ pub struct for_com { pub struct case_com { flags:libc::c_int, line:libc::c_int, - word:*mut WORD_DESC, + word:*mut WordDesc, clauses:*mut PATTERN_LIST } @@ -161,7 +161,7 @@ pub struct simple_com { pub struct function_def { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, command:*mut COMMAND, source_file:*mut c_char } @@ -175,7 +175,7 @@ pub struct group_com { pub struct select_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -599,9 +599,26 @@ pub type QSFUNC = unsafe extern "C" fn(*const c_void,*const c_void)->i32; pub static EX_SUCCESS:i32 = 0; -pub static EX_USAGE:i32 = -99; -pub static EX_:i32 = 0; - +pub static EX_USAGE:i32 = 258; +/////// +pub static EX_BADUSAGE:i32 = 2; + +pub static EX_MISCERROR:i32 = 2; + +pub static EX_RETRYFAIL:i32 = 124; +pub static EX_WEXPCOMSUB:i32 = 125; +pub static EX_BINARY_FILE :i32 = 126; +pub static EX_NOEXEC: i32 = 126; +pub static EX_NOINPUT:i32 = 126; +pub static EX_NOTFOUND:i32 = 127; + +pub static EX_SHERRBASE:i32 = 256; /* all special error values are > this. */ + +pub static EX_BADSYNTAX:i32 = 257; /* shell syntax error */ +pub static EX_REDIRFAIL:i32 = 259; /* redirection failed */ +pub static EX_BADASSIGN :i32 = 260; /* variable assignment error */ +pub static EX_EXPFAIL:i32= 261;/* word expansion failed */ +pub static EX_DISKFALLBACK:i32 = 262; /* fall back to disk command from builtin */ //extern C extern "C"{ diff --git a/bash-5.1/builtins_rust/complete/src/lib.rs b/bash-5.1/builtins_rust/complete/src/lib.rs index d00afdf7..a2da096f 100644 --- a/bash-5.1/builtins_rust/complete/src/lib.rs +++ b/bash-5.1/builtins_rust/complete/src/lib.rs @@ -5,7 +5,7 @@ use libc::{c_char, c_int, c_ulong, c_void}; use std::{ffi::CString}; #[repr(C)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut c_char, pub flags:c_int } @@ -14,7 +14,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } #[repr(u8)] @@ -39,7 +39,7 @@ enum r_instruction { #[derive(Copy,Clone)] pub union REDIRECTEE { dest:c_int, - filename:* mut WORD_DESC + filename:* mut WordDesc } #[repr(C)] @@ -58,7 +58,7 @@ pub union REDIRECT { pub struct for_com { flags:c_int, line:c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -75,7 +75,7 @@ pub struct PATTERN_LIST { pub struct case_com { flags:c_int, line:c_int, - word:*mut WORD_DESC, + word:*mut WordDesc, clauses:*mut PATTERN_LIST } @@ -114,7 +114,7 @@ pub struct simple_com { pub struct function_def { flags:c_int, line:c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, command:*mut COMMAND, source_file:*mut c_char } @@ -130,7 +130,7 @@ pub struct group_com { pub struct select_com { flags:c_int, line:c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -583,11 +583,11 @@ extern "C" { fn builtin_usage(); static list_optarg:* mut c_char; fn builtin_error(err:*const c_char,...); - fn check_identifier (w:* mut WORD_DESC, f:i32)->i32; + fn check_identifier (w:* mut WordDesc, f:i32)->i32; static mut posixly_correct:i32; static mut loptend:*mut WORD_LIST; - fn make_word_list (w:* mut WORD_DESC, list:*mut WORD_LIST)->*mut WORD_LIST; - fn make_bare_word (w:*const c_char)->* mut WORD_DESC; + fn make_word_list (w:* mut WordDesc, list:*mut WORD_LIST)->*mut WORD_LIST; + fn make_bare_word (w:*const c_char)->* mut WordDesc; fn dispose_words (list:*mut WORD_LIST); fn progcomp_flush (); fn compspec_create ()->* mut COMPSPEC; @@ -709,7 +709,7 @@ pub extern "C" fn r_build_actions (list : *mut WORD_LIST, flagp:* mut _optflags, let mut opt_given:i32=0; let mut acts:c_ulong=0; let mut copts:c_ulong=0; - let mut w:WORD_DESC=WORD_DESC{word:std::ptr::null_mut(),flags:0}; + let mut w:WordDesc=WordDesc{word:std::ptr::null_mut(),flags:0}; unsafe { reset_internal_getopt (); diff --git a/bash-5.1/builtins_rust/declare/src/lib.rs b/bash-5.1/builtins_rust/declare/src/lib.rs index a4461765..33329355 100644 --- a/bash-5.1/builtins_rust/declare/src/lib.rs +++ b/bash-5.1/builtins_rust/declare/src/lib.rs @@ -6,7 +6,7 @@ use std::{ffi::CString}; // use rcommon::{r_sh_notfound,r_sh_invalidopt,r_sh_invalidid,r_sh_readonly,r_sh_chkwrite,}; #[repr(C)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut libc::c_char, pub flags:libc::c_int } @@ -15,7 +15,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } #[repr(u8)] @@ -40,7 +40,7 @@ enum r_instruction { #[derive(Copy,Clone)] pub union REDIRECTEE { dest:libc::c_int, - filename:* mut WORD_DESC + filename:* mut WordDesc } #[repr(C)] @@ -59,7 +59,7 @@ pub union REDIRECT { pub struct for_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -76,7 +76,7 @@ pub struct PATTERN_LIST { pub struct case_com { flags:libc::c_int, line:libc::c_int, - word:*mut WORD_DESC, + word:*mut WordDesc, clauses:*mut PATTERN_LIST } @@ -115,7 +115,7 @@ pub struct simple_com { pub struct function_def { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, command:*mut COMMAND, source_file:*mut c_char } @@ -131,7 +131,7 @@ pub struct group_com { pub struct select_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } diff --git a/bash-5.1/builtins_rust/echo/src/lib.rs b/bash-5.1/builtins_rust/echo/src/lib.rs index 9f547250..c7d674fd 100644 --- a/bash-5.1/builtins_rust/echo/src/lib.rs +++ b/bash-5.1/builtins_rust/echo/src/lib.rs @@ -7,7 +7,7 @@ use std::ptr::read_volatile; //结构体 #[repr (C)] -pub struct WORD_DESC{ +pub struct WordDesc{ pub word:*mut c_char, pub flags:c_int, } @@ -16,7 +16,7 @@ pub struct WORD_DESC{ // #[derive(Copy,Clone)] pub struct WORD_LIST{ pub next:*mut WORD_LIST, - pub word:*mut WORD_DESC, + pub word:*mut WordDesc, } diff --git a/bash-5.1/builtins_rust/enable/src/lib.rs b/bash-5.1/builtins_rust/enable/src/lib.rs index 1d61f3c4..c6f7224e 100644 --- a/bash-5.1/builtins_rust/enable/src/lib.rs +++ b/bash-5.1/builtins_rust/enable/src/lib.rs @@ -134,12 +134,12 @@ pub struct word_desc { pub word: *mut libc::c_char, pub flags: libc::c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[derive(Copy, Clone)] #[repr(C)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; pub type sh_load_func_t = unsafe extern "C" fn(*mut libc::c_char) -> libc::c_int; diff --git a/bash-5.1/builtins_rust/eval/src/lib.rs b/bash-5.1/builtins_rust/eval/src/lib.rs index 00ae90c3..51c400e4 100644 --- a/bash-5.1/builtins_rust/eval/src/lib.rs +++ b/bash-5.1/builtins_rust/eval/src/lib.rs @@ -11,13 +11,13 @@ use rcommon::{r_no_options,WORD_LIST}; // pub word: *mut c_char, // pub flags: c_int, // } -// pub type WORD_DESC = word_desc; +// pub type WordDesc = word_desc; // #[repr(C)] // #[derive(Copy, Clone)] // pub struct word_list { // pub next: *mut word_list, -// pub word: *mut WORD_DESC, +// pub word: *mut WordDesc, // } // pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/exec/src/lib.rs b/bash-5.1/builtins_rust/exec/src/lib.rs index 7adea360..a147a239 100644 --- a/bash-5.1/builtins_rust/exec/src/lib.rs +++ b/bash-5.1/builtins_rust/exec/src/lib.rs @@ -10,7 +10,7 @@ use rcommon::r_sh_restricted; #[repr (C)] #[derive(Copy,Clone)] -pub struct WORD_DESC{ +pub struct WordDesc{ pub word:*mut c_char, pub flags:c_int, } @@ -19,7 +19,7 @@ pub struct WORD_DESC{ #[derive(Copy,Clone)] pub struct WORD_LIST{ pub next:*mut WORD_LIST, - pub word:*mut WORD_DESC, + pub word:*mut WordDesc, } #[repr (C)] @@ -37,7 +37,7 @@ type REDIRECT = redirect; #[repr (C)] union REDIRECTEE { dest:i32, - filename:*mut WORD_DESC, + filename:*mut WordDesc, } #[repr(i8)] //i8 or C ??????? diff --git a/bash-5.1/builtins_rust/fc/src/lib.rs b/bash-5.1/builtins_rust/fc/src/lib.rs index 409dbe26..83cc882c 100644 --- a/bash-5.1/builtins_rust/fc/src/lib.rs +++ b/bash-5.1/builtins_rust/fc/src/lib.rs @@ -5,7 +5,7 @@ use libc::{c_char, c_long, c_void}; use std::{ffi::CString, i32, io::{Write, stdout}, ops::Add, string, u32}; #[repr(C)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut libc::c_char, pub flags:libc::c_int } @@ -14,7 +14,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } #[repr(i8)] @@ -57,7 +57,7 @@ pub struct PROCESS { #[derive(Copy,Clone)] pub union REDIRECTEE { dest:libc::c_int, - filename:* mut WORD_DESC + filename:* mut WordDesc } #[repr(C)] @@ -76,7 +76,7 @@ pub union REDIRECT { pub struct for_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -93,7 +93,7 @@ pub struct PATTERN_LIST { pub struct case_com { flags:libc::c_int, line:libc::c_int, - word:*mut WORD_DESC, + word:*mut WordDesc, clauses:*mut PATTERN_LIST } @@ -132,7 +132,7 @@ pub struct simple_com { pub struct function_def { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, command:*mut COMMAND, source_file:*mut c_char } @@ -148,7 +148,7 @@ pub struct group_com { pub struct select_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } diff --git a/bash-5.1/builtins_rust/fg_bg/src/lib.rs b/bash-5.1/builtins_rust/fg_bg/src/lib.rs index 224272af..5aa717ff 100644 --- a/bash-5.1/builtins_rust/fg_bg/src/lib.rs +++ b/bash-5.1/builtins_rust/fg_bg/src/lib.rs @@ -5,7 +5,7 @@ use libc::{c_char, c_long}; use std::{ffi::CString, ops::Add}; #[repr(C)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut libc::c_char, pub flags:libc::c_int } @@ -14,7 +14,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } #[repr(i8)] @@ -57,7 +57,7 @@ pub struct PROCESS { #[derive(Copy,Clone)] pub union REDIRECTEE { dest:libc::c_int, /* Place to redirect REDIRECTOR to, or ... */ - filename:* mut WORD_DESC /* filename to redirect to. */ + filename:* mut WordDesc /* filename to redirect to. */ } #[repr(C)] @@ -76,7 +76,7 @@ pub union REDIRECT { pub struct for_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -93,7 +93,7 @@ pub struct PATTERN_LIST { pub struct case_com { flags:libc::c_int, line:libc::c_int, - word:*mut WORD_DESC, + word:*mut WordDesc, clauses:*mut PATTERN_LIST } @@ -132,7 +132,7 @@ pub struct simple_com { pub struct function_def { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, command:*mut COMMAND, source_file:*mut c_char } @@ -148,7 +148,7 @@ pub struct group_com { pub struct select_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } diff --git a/bash-5.1/builtins_rust/getopts/src/lib.rs b/bash-5.1/builtins_rust/getopts/src/lib.rs index 90b0793a..fb324114 100644 --- a/bash-5.1/builtins_rust/getopts/src/lib.rs +++ b/bash-5.1/builtins_rust/getopts/src/lib.rs @@ -5,7 +5,7 @@ use libc::{c_char, c_long, c_void}; use std::{ffi::CString}; #[repr(C)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut libc::c_char, pub flags:libc::c_int } @@ -14,7 +14,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } #[repr(u8)] @@ -39,7 +39,7 @@ enum r_instruction { #[derive(Copy,Clone)] pub union REDIRECTEE { dest:libc::c_int, - filename:* mut WORD_DESC + filename:* mut WordDesc } #[repr(C)] @@ -58,7 +58,7 @@ pub union REDIRECT { pub struct for_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -75,7 +75,7 @@ pub struct PATTERN_LIST { pub struct case_com { flags:libc::c_int, line:libc::c_int, - word:*mut WORD_DESC, + word:*mut WordDesc, clauses:*mut PATTERN_LIST } @@ -114,7 +114,7 @@ pub struct simple_com { pub struct function_def { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, command:*mut COMMAND, source_file:*mut c_char } @@ -130,7 +130,7 @@ pub struct group_com { pub struct select_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } diff --git a/bash-5.1/builtins_rust/hash/src/lib.rs b/bash-5.1/builtins_rust/hash/src/lib.rs index 45dea8c1..5e0257f9 100644 --- a/bash-5.1/builtins_rust/hash/src/lib.rs +++ b/bash-5.1/builtins_rust/hash/src/lib.rs @@ -11,7 +11,7 @@ use rcommon::{r_find_shell_builtin,r_builtin_usage}; //struct //结构体 #[repr (C)] -pub struct WORD_DESC{ +pub struct WordDesc{ pub word:*mut c_char, pub flags:c_int, } @@ -20,7 +20,7 @@ pub struct WORD_DESC{ // #[derive(Copy,Clone)] pub struct WORD_LIST{ pub next:*mut WORD_LIST, - pub word:*mut WORD_DESC, + pub word:*mut WordDesc, } type PTR_T=c_void; diff --git a/bash-5.1/builtins_rust/help/src/lib.rs b/bash-5.1/builtins_rust/help/src/lib.rs index 40847e94..506df520 100644 --- a/bash-5.1/builtins_rust/help/src/lib.rs +++ b/bash-5.1/builtins_rust/help/src/lib.rs @@ -10,7 +10,7 @@ pub enum Option { } #[repr(C)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut libc::c_char, pub flags:libc::c_int } @@ -19,7 +19,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } #[repr (C)] diff --git a/bash-5.1/builtins_rust/history/src/intercdep.rs b/bash-5.1/builtins_rust/history/src/intercdep.rs index 187a02aa..1092742e 100644 --- a/bash-5.1/builtins_rust/history/src/intercdep.rs +++ b/bash-5.1/builtins_rust/history/src/intercdep.rs @@ -5,13 +5,13 @@ // pub word: *mut c_char, // pub flags: c_int, // } -// pub type WORD_DESC = word_desc; +// pub type WordDesc = word_desc; // #[repr(C)] // #[derive(Copy, Clone)] // pub struct word_list { // pub next: *mut word_list, -// pub word: *mut WORD_DESC, +// pub word: *mut WordDesc, // } // pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/jobs/src/lib.rs b/bash-5.1/builtins_rust/jobs/src/lib.rs index 3f74083e..f8791aa9 100644 --- a/bash-5.1/builtins_rust/jobs/src/lib.rs +++ b/bash-5.1/builtins_rust/jobs/src/lib.rs @@ -5,7 +5,7 @@ use libc::{c_char, c_long}; use std::ffi::CString; #[repr(C)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut libc::c_char, pub flags:libc::c_int } @@ -14,7 +14,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { pub next: *mut WORD_LIST, - pub word: *mut WORD_DESC + pub word: *mut WordDesc } #[repr(i8)] @@ -57,7 +57,7 @@ pub struct PROCESS { #[derive(Copy,Clone)] pub union REDIRECTEE { dest:libc::c_int, /* Place to redirect REDIRECTOR to, or ... */ - filename:* mut WORD_DESC /* filename to redirect to. */ + filename:* mut WordDesc /* filename to redirect to. */ } #[repr(C)] @@ -76,7 +76,7 @@ pub union REDIRECT { pub struct for_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -93,7 +93,7 @@ pub struct PATTERN_LIST { pub struct case_com { flags:libc::c_int, line:libc::c_int, - word:*mut WORD_DESC, + word:*mut WordDesc, clauses:*mut PATTERN_LIST } @@ -132,7 +132,7 @@ pub struct simple_com { pub struct function_def { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, command:*mut COMMAND, source_file:*mut c_char } @@ -148,7 +148,7 @@ pub struct group_com { pub struct select_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } diff --git a/bash-5.1/builtins_rust/kill/src/intercdep.rs b/bash-5.1/builtins_rust/kill/src/intercdep.rs index 1d7d400d..c8af4bc0 100644 --- a/bash-5.1/builtins_rust/kill/src/intercdep.rs +++ b/bash-5.1/builtins_rust/kill/src/intercdep.rs @@ -1,17 +1,17 @@ -use rcommon::{r_builtin_usage,r_sh_invalidsig,r_sh_badpid,r_sh_badjob,r_get_job_spec,r_display_signal_list,WORD_LIST,WORD_DESC}; +use rcommon::{r_builtin_usage,r_sh_invalidsig,r_sh_badpid,r_sh_badjob,r_get_job_spec,r_display_signal_list,WORD_LIST,WordDesc}; // #[repr(C)] // #[derive(Copy, Clone)] // pub struct word_desc { // pub word: *mut c_char, // pub flags: c_int, // } -// pub type WORD_DESC = word_desc; +// pub type WordDesc = word_desc; // #[repr(C)] // #[derive(Copy, Clone)] // pub struct word_list { // pub next: *mut word_list, -// pub word: *mut WORD_DESC, +// pub word: *mut WordDesc, // } // pub type WORD_LIST = word_list; @@ -39,7 +39,7 @@ pub type command_type = c_uint; #[derive(Copy, Clone)] pub union REDIRECTEE { pub dest: c_int, - pub filename: *mut WORD_DESC, + pub filename: *mut WordDesc, } pub type r_instruction = c_uint; @@ -100,7 +100,7 @@ pub type PATTERN_LIST = pattern_list; pub struct case_com { pub flags: c_int, pub line: c_int, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, pub clauses: *mut PATTERN_LIST, } @@ -110,7 +110,7 @@ pub type CASE_COM = case_com; pub struct for_com { pub flags: c_int, pub line: c_int, - pub name: *mut WORD_DESC, + pub name: *mut WordDesc, pub map_list: *mut WORD_LIST, pub action: *mut COMMAND, } @@ -133,7 +133,7 @@ pub type ARITH_FOR_COM = arith_for_com; pub struct select_com { pub flags: c_int, pub line: c_int, - pub name: *mut WORD_DESC, + pub name: *mut WordDesc, pub map_list: *mut WORD_LIST, pub action: *mut COMMAND, } @@ -173,7 +173,7 @@ pub struct cond_com { pub flags: c_int, pub line: c_int, pub type_: c_int, - pub op: *mut WORD_DESC, + pub op: *mut WordDesc, pub left: *mut cond_com, pub right: *mut cond_com, } @@ -194,7 +194,7 @@ pub type SIMPLE_COM = simple_com; pub struct function_def { pub flags: c_int, pub line: c_int, - pub name: *mut WORD_DESC, + pub name: *mut WordDesc, pub command: *mut COMMAND, pub source_file: *mut c_char, } diff --git a/bash-5.1/builtins_rust/mapfile/src/intercdep.rs b/bash-5.1/builtins_rust/mapfile/src/intercdep.rs index f4de2e9c..57b879ba 100644 --- a/bash-5.1/builtins_rust/mapfile/src/intercdep.rs +++ b/bash-5.1/builtins_rust/mapfile/src/intercdep.rs @@ -5,13 +5,13 @@ pub struct word_desc { pub word: *mut c_char, pub flags: c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[repr(C)] #[derive(Copy, Clone)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/printf/src/intercdep.rs b/bash-5.1/builtins_rust/printf/src/intercdep.rs index ebc27b22..8d2bc9f4 100644 --- a/bash-5.1/builtins_rust/printf/src/intercdep.rs +++ b/bash-5.1/builtins_rust/printf/src/intercdep.rs @@ -4,13 +4,13 @@ pub struct word_desc { pub word: *mut c_char, pub flags: c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[repr(C)] #[derive(Copy, Clone)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/pushd/src/lib.rs b/bash-5.1/builtins_rust/pushd/src/lib.rs index bd0783c7..4d08521a 100644 --- a/bash-5.1/builtins_rust/pushd/src/lib.rs +++ b/bash-5.1/builtins_rust/pushd/src/lib.rs @@ -5,7 +5,7 @@ use libc::{c_char, c_long, c_void}; use std::{ffi::CString}; #[repr(C)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut libc::c_char, pub flags:libc::c_int } @@ -14,7 +14,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } #[repr(u8)] @@ -39,7 +39,7 @@ enum r_instruction { #[derive(Copy,Clone)] pub union REDIRECTEE { dest:libc::c_int, - filename:* mut WORD_DESC + filename:* mut WordDesc } #[repr(C)] @@ -58,7 +58,7 @@ pub union REDIRECT { pub struct for_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -75,7 +75,7 @@ pub struct PATTERN_LIST { pub struct case_com { flags:libc::c_int, line:libc::c_int, - word:*mut WORD_DESC, + word:*mut WordDesc, clauses:*mut PATTERN_LIST } @@ -114,7 +114,7 @@ pub struct simple_com { pub struct function_def { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, command:*mut COMMAND, source_file:*mut c_char } @@ -130,7 +130,7 @@ pub struct group_com { pub struct select_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -257,8 +257,8 @@ extern "C" { fn cd_builtin (list:*mut WORD_LIST)->i32; fn polite_directory_format (path:* mut c_char)->* mut c_char; fn sh_erange (str1:* mut c_char, str2:* mut c_char); - fn make_word_list (w: * mut WORD_DESC , l: * mut WORD_LIST)->* mut WORD_LIST; - fn make_word (w:*const c_char)->* mut WORD_DESC; + fn make_word_list (w: * mut WordDesc , l: * mut WORD_LIST)->* mut WORD_LIST; + fn make_word (w:*const c_char)->* mut WordDesc; fn dispose_words (l: * mut WORD_LIST); fn strvec_resize (c:* mut * mut c_char, s:i32)->* mut * mut c_char; fn get_string_value (w:*const c_char)-> * mut c_char; diff --git a/bash-5.1/builtins_rust/read/src/intercdep.rs b/bash-5.1/builtins_rust/read/src/intercdep.rs index 231a6d95..4260b7a4 100644 --- a/bash-5.1/builtins_rust/read/src/intercdep.rs +++ b/bash-5.1/builtins_rust/read/src/intercdep.rs @@ -5,13 +5,13 @@ pub struct word_desc { pub word: *mut c_char, pub flags: c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[repr(C)] #[derive(Copy, Clone)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/rlet/src/intercdep.rs b/bash-5.1/builtins_rust/rlet/src/intercdep.rs index d2246f94..c25cd148 100644 --- a/bash-5.1/builtins_rust/rlet/src/intercdep.rs +++ b/bash-5.1/builtins_rust/rlet/src/intercdep.rs @@ -5,13 +5,13 @@ pub struct word_desc { pub word: *mut c_char, pub flags: c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[repr(C)] #[derive(Copy, Clone)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/rreturn/src/intercdep.rs b/bash-5.1/builtins_rust/rreturn/src/intercdep.rs index f1af7327..a686dd7b 100644 --- a/bash-5.1/builtins_rust/rreturn/src/intercdep.rs +++ b/bash-5.1/builtins_rust/rreturn/src/intercdep.rs @@ -5,13 +5,13 @@ // pub word: *mut c_char, // pub flags: c_int, // } -// pub type WORD_DESC = word_desc; +// pub type WordDesc = word_desc; // #[repr(C)] // #[derive(Copy, Clone)] // pub struct word_list { // pub next: *mut word_list, -// pub word: *mut WORD_DESC, +// pub word: *mut WordDesc, // } // pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/set/src/lib.rs b/bash-5.1/builtins_rust/set/src/lib.rs index deebcf1e..ed8e8a54 100644 --- a/bash-5.1/builtins_rust/set/src/lib.rs +++ b/bash-5.1/builtins_rust/set/src/lib.rs @@ -7,7 +7,7 @@ use std::ptr; use std::mem; use std::io; #[repr(C)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut i8, pub flags:i32 } @@ -16,7 +16,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } #[macro_export] @@ -1279,7 +1279,7 @@ unsafe fn print_all_shell_variables (){ } } -unsafe fn set_shellopts () { +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!()]; @@ -1391,7 +1391,7 @@ unsafe fn initialize_shell_options (no_shellopts : i32) { } /* Set up the $SHELLOPTS variable. */ - set_shellopts (); + r_set_shellopts (); } unsafe fn reset_shell_options () { @@ -1590,7 +1590,7 @@ unsafe fn reset_shell_options () { }; if r != EXECUTION_SUCCESS!() { unsafe { - set_shellopts () + r_set_shellopts () }; return (r); } @@ -1603,7 +1603,7 @@ unsafe fn reset_shell_options () { unsafe { sh_invalidopt (s.as_ptr() as *mut i8); builtin_usage (); - set_shellopts (); + r_set_shellopts (); } return EXECUTION_FAILURE!(); } @@ -1636,7 +1636,7 @@ unsafe fn reset_shell_options () { if opts_changed != 0 { unsafe { - set_shellopts(); + r_set_shellopts(); } } return rv; diff --git a/bash-5.1/builtins_rust/setattr/src/intercdep.rs b/bash-5.1/builtins_rust/setattr/src/intercdep.rs index cea139de..b6da1934 100644 --- a/bash-5.1/builtins_rust/setattr/src/intercdep.rs +++ b/bash-5.1/builtins_rust/setattr/src/intercdep.rs @@ -5,13 +5,13 @@ pub struct word_desc { pub word: *mut c_char, pub flags: c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[repr(C)] #[derive(Copy, Clone)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; @@ -53,7 +53,7 @@ pub type command_type = c_uint; #[derive(Copy, Clone)] pub union REDIRECTEE { pub dest: c_int, - pub filename: *mut WORD_DESC, + pub filename: *mut WordDesc, } pub type r_instruction = c_uint; @@ -115,7 +115,7 @@ pub type PATTERN_LIST = pattern_list; pub struct case_com { pub flags: c_int, pub line: c_int, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, pub clauses: *mut PATTERN_LIST, } @@ -125,7 +125,7 @@ pub type CASE_COM = case_com; pub struct for_com { pub flags: c_int, pub line: c_int, - pub name: *mut WORD_DESC, + pub name: *mut WordDesc, pub map_list: *mut WORD_LIST, pub action: *mut COMMAND, } @@ -148,7 +148,7 @@ pub type ARITH_FOR_COM = arith_for_com; pub struct select_com { pub flags: c_int, pub line: c_int, - pub name: *mut WORD_DESC, + pub name: *mut WordDesc, pub map_list: *mut WORD_LIST, pub action: *mut COMMAND, } @@ -188,7 +188,7 @@ pub struct cond_com { pub flags: c_int, pub line: c_int, pub type_: c_int, - pub op: *mut WORD_DESC, + pub op: *mut WordDesc, pub left: *mut cond_com, pub right: *mut cond_com, } @@ -209,7 +209,7 @@ pub type SIMPLE_COM = simple_com; pub struct function_def { pub flags: c_int, pub line: c_int, - pub name: *mut WORD_DESC, + pub name: *mut WordDesc, pub command: *mut COMMAND, pub source_file: *mut c_char, } @@ -359,10 +359,10 @@ extern "C" { pub fn assignment(string: *const c_char, flags: c_int) -> c_int; pub fn legal_identifier(arg1: *const c_char) -> c_int; pub fn sh_invalidid(s: *mut c_char); - pub fn make_word(string: *const c_char) -> *mut WORD_DESC; - pub fn make_word_list(word: *mut WORD_DESC, wlink: *mut WORD_LIST) -> *mut WORD_LIST; + pub fn make_word(string: *const c_char) -> *mut WordDesc; + pub fn make_word_list(word: *mut WordDesc, wlink: *mut WORD_LIST) -> *mut WORD_LIST; pub fn declare_builtin(list:* mut WORD_LIST) -> c_int; - pub fn dispose_word(w: *mut WORD_DESC); + pub fn dispose_word(w: *mut WordDesc); pub fn do_assignment_no_expand(string: *mut c_char) -> c_int; pub fn all_shell_functions() -> *mut *mut SHELL_VAR; diff --git a/bash-5.1/builtins_rust/setattr/src/lib.rs b/bash-5.1/builtins_rust/setattr/src/lib.rs index bbe8547b..86728ee0 100644 --- a/bash-5.1/builtins_rust/setattr/src/lib.rs +++ b/bash-5.1/builtins_rust/setattr/src/lib.rs @@ -28,7 +28,7 @@ pub extern "C" fn set_or_show_attributes(mut list: *mut WORD_LIST, mut attribute let mut aflags: c_int; let mut tlist: *mut WORD_LIST; let mut nlist: *mut WORD_LIST; - let mut w: *mut WORD_DESC; + let mut w: *mut WordDesc; unsafe { reset_internal_getopt(); let opt_str = std::ffi::CString::new("aAfnp").unwrap(); diff --git a/bash-5.1/builtins_rust/shift/src/intercdep.rs b/bash-5.1/builtins_rust/shift/src/intercdep.rs index 24ce4a1b..31959d8a 100644 --- a/bash-5.1/builtins_rust/shift/src/intercdep.rs +++ b/bash-5.1/builtins_rust/shift/src/intercdep.rs @@ -5,13 +5,13 @@ pub struct word_desc { pub word: *mut c_char, pub flags: c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[repr(C)] #[derive(Copy, Clone)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/shopt/Cargo.toml b/bash-5.1/builtins_rust/shopt/Cargo.toml index 2591d5e2..689ba728 100644 --- a/bash-5.1/builtins_rust/shopt/Cargo.toml +++ b/bash-5.1/builtins_rust/shopt/Cargo.toml @@ -7,6 +7,7 @@ edition = "2018" [dependencies] libc = "*" +rset = {path="../set"} [lib] crate-type = ["staticlib","rlib"] diff --git a/bash-5.1/builtins_rust/shopt/src/lib.rs b/bash-5.1/builtins_rust/shopt/src/lib.rs index baabf6fb..4f29fc2f 100644 --- a/bash-5.1/builtins_rust/shopt/src/lib.rs +++ b/bash-5.1/builtins_rust/shopt/src/lib.rs @@ -1,4 +1,5 @@ use std::ffi::*; +use rset::r_set_shellopts; use libc::*; /* /* First, the user-visible attributes */ @@ -123,7 +124,7 @@ extern "C" { fn minus_o_option_value(_: *mut libc::c_char) -> i32; fn list_minus_o_opts(_: i32, _: i32); fn set_minus_o_option(_: i32, _: *mut libc::c_char) -> libc::c_int; - fn set_shellopts(); + //fn r_set_shellopts(); static mut print_shift_error: i32; static mut source_uses_path: i32; static mut loptend: *mut WordList; @@ -923,8 +924,8 @@ static QFLAG:i32 = 0x04; static OFLAG:i32 = 0x08; static PFLAG:i32 = 0x10; static EX_USAGE:i32 = 258; -static SETOPT:i32 = 0; -static UNSETOPT:i32 = 1; +static SETOPT:i32 = 1; +static UNSETOPT:i32 = 0; static EXECUTION_SUCCESS : i32 = 0; static EXECUTION_FAILURE :i32 = 1; @@ -932,10 +933,10 @@ 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; #[no_mangle] pub unsafe extern "C" fn r_shopt_builtin(mut list: *mut WordList) -> i32 { - let mut opt: i32 = 0; + let mut opt: i32; let mut flags: i32 = 0; let mut rval: i32 = 0; - flags = 0 as i32; + reset_internal_getopt(); let psuoq = CString::new("psuoq").expect("CString::new failed"); loop { @@ -983,29 +984,30 @@ pub unsafe extern "C" fn r_shopt_builtin(mut list: *mut WordList) -> i32 { ); return EXECUTION_FAILURE; } - rval = 0; - if flags & OFLAG != 0 && flags & (SFLAG | UFLAG) == 0 // shopt -o + + if (flags & OFLAG != 0) &&( (flags & (SFLAG | UFLAG)) == 0) // shopt -o {//设置了o-flag,并没设s或u-flag rval = r_list_shopt_o_options(list, flags); - } else if !list.is_null() && flags & OFLAG != 0 { //shopt -so args + } else if !list.is_null() && flags & OFLAG != 0 { //设置-o了 //shopt -so args , shopt -u args rval = set_shopt_o_options( - if flags & SFLAG != 0 { '-' as i32 } else { '+' as i32 }, + if flags & SFLAG != 0 { '-' as i32 /*on*/} else { '+' as i32 /*off*/}, list, - flags & QFLAG, + flags & QFLAG,//是否沉默? ); } else if flags & OFLAG != 0 { // shopt -so rval = list_some_o_options( if flags & SFLAG != 0 { 1 } else { 0 }, flags, ); - } else if !list.is_null() && flags & (SFLAG | UFLAG) != 0 { // shopt -su args + } else if !list.is_null() && flags & (SFLAG | UFLAG) != 0 { // shopt -s/u args rval = toggle_shopts( if flags & SFLAG != 0 { 1 } else { 0 }, list, flags & QFLAG, ); } else if flags & (SFLAG | UFLAG) == 0 { // shopt [args] - rval = list_shopts(list, flags); + println!("shopt ===list all "); + rval = r_list_shopts(list, flags); } else { // shopt -su rval = list_some_shopts( if flags & SFLAG != 0 { SETOPT } else { UNSETOPT }, @@ -1092,8 +1094,9 @@ unsafe extern "C" fn shopt_error( s: *mut libc::c_char) { unsafe extern "C" fn toggle_shopts( mode: i32, list: *mut WordList, - quiet: i32, + _quiet: i32, ) -> i32 { + printf(CString::new(" set command: %s mode=%d").expect("").as_ptr() ,(*(*list).word).word, mode); let mut l: *mut WordList; let mut ind:i32; let mut rval: i32; @@ -1134,10 +1137,10 @@ unsafe extern "C" fn print_shopt( flags: i32, ) { - let msg: CString = CString::new("shopt %s %s\n").expect("CString new faild"); - let s: CString = CString::new("-s").expect("CString new faild"); - let u: CString = CString::new("-u").expect("CString new faild"); - let optfmt: CString = CString::new("%-15s\t\n").expect("CString new faild"); + let msg: CString = CString::new("shopt %s %s\n").expect("CString new faild"); + let s: CString = CString::new("-s").expect("CString new faild"); + let u: CString = CString::new("-u").expect("CString new faild"); + let optfmt: CString = CString::new("%-15s\t%s\n").expect("CString new faild"); if flags & PFLAG != 0 { printf( msg.as_ptr(), @@ -1156,41 +1159,42 @@ unsafe extern "C" fn print_shopt( ); }; } -unsafe extern "C" fn list_shopts( +unsafe extern "C" fn r_list_shopts( list: *mut WordList, flags: i32, ) -> i32 { let mut l:*mut WordList; let mut i; let mut val = 0; - let mut rval; - if list.is_null() { - for item in SHOPT_VARS { - if (flags & QFLAG) ==0 { - print_shopt(item.name, val, flags); + let mut rval =0; + rval = EXECUTION_SUCCESS; + if (flags & QFLAG) ==0 { + if list.is_null() { + for item in SHOPT_VARS { + if item.value != std::ptr::null_mut() { + val = *item.value; + print_shopt(item.name, val, flags); + } } + return sh_chkwrite(EXECUTION_SUCCESS); } - return sh_chkwrite(EXECUTION_SUCCESS); - } - l = list; - rval = EXECUTION_SUCCESS; - while !l.is_null() { - i = find_shopt((*(*l).word).word); - if i < 0 { - shopt_error((*(*l).word).word); - rval = EXECUTION_FAILURE; - } else { - val = *SHOPT_VARS[i as usize].value; - if val == 0 as i32 { + l = list; + while !l.is_null() { + i = find_shopt((*(*l).word).word); + if i < 0 { + shopt_error((*(*l).word).word); rval = EXECUTION_FAILURE; - } - if flags & QFLAG == 0 { + } else { + val = *SHOPT_VARS[i as usize].value; + if val == 0 { + rval = EXECUTION_FAILURE; + } print_shopt((*(*l).word).word, val, flags); } + l = (*l).next; } - l = (*l).next; - } + } return sh_chkwrite(rval); } @@ -1199,7 +1203,10 @@ unsafe extern "C" fn list_some_shopts( flags: i32, ) -> i32 { for item in SHOPT_VARS { - if ((flags & QFLAG) == 0 )&& mode==*item.value { + //if !item.name.is_null() { + //printf(b"===name=%s, value=%d\n\0" as *const u8 as *const libc::c_char, item.name as *const u8 as *const libc::c_char, *item.value); + //} + if ((flags & QFLAG) == 0 )&& item.value != std::ptr::null_mut() && mode==*item.value { print_shopt(item.name, *item.value, flags); } } @@ -1212,7 +1219,7 @@ unsafe extern "C" fn r_list_shopt_o_options( ) -> i32 { let mut l: *mut WordList = 0 as *mut WordList; let mut val: i32 = 0; - let mut rval: i32 = 0; + let mut rval: i32 = EXECUTION_SUCCESS; if list.is_null() { if flags & QFLAG == 0 { list_minus_o_opts(-1, flags & PFLAG); @@ -1220,7 +1227,7 @@ unsafe extern "C" fn r_list_shopt_o_options( return sh_chkwrite(EXECUTION_SUCCESS); } l = list; - rval = EXECUTION_SUCCESS; + while !l.is_null() { val = minus_o_option_value((*(*l).word).word); if val == -1 { @@ -1277,14 +1284,14 @@ unsafe extern "C" fn set_shopt_o_options( } l = (*l).next; } - set_shellopts(); + r_set_shellopts(); return rval; } unsafe extern "C" fn set_shellopts_after_change( option_name: *mut libc::c_char, mode: i32, ) -> i32 { - set_shellopts(); + r_set_shellopts(); return 0; } unsafe extern "C" fn shopt_set_debug_mode( @@ -1293,7 +1300,7 @@ unsafe extern "C" fn shopt_set_debug_mode( ) -> i32 { function_trace_mode = debugging_mode; error_trace_mode = function_trace_mode; - set_shellopts(); + r_set_shellopts(); if debugging_mode != 0 { init_bash_argv(); } @@ -1455,7 +1462,7 @@ pub unsafe extern "C" fn r_shopt_listopt( ) -> i32 { let mut i: i32 = 0; if name.is_null() { - return list_shopts( + return r_list_shopts( // 0 as *mut libc::c_void as *mut WORD_LIST, std::ptr::null_mut(), if reusable != 0 { PFLAG } else { 0 }, @@ -1499,7 +1506,7 @@ pub unsafe extern "C" fn r_set_bashopts() { .wrapping_add(1 as i32 as libc::c_ulong), ) as i32 as libc::c_int; */ - tflag[i as usize] = 1 as i32 as libc::c_char; + tflag[i as usize] = 1 as libc::c_char; } i += 1; } @@ -1528,20 +1535,19 @@ pub unsafe extern "C" fn r_set_bashopts() { (*v).attributes &= !(0x2 as i32); exported = (*v).attributes & 0x1 as i32; } else { - exported = 0 as i32; + exported = 0; } v = bind_variable( b"BASHOPTS\0" as *const u8 as *const libc::c_char, value, - 0 as i32, + 0, ); - (*v).attributes |= 0x2 as i32; + (*v).attributes |= 0x2; if mark_modified_vars != 0 && exported == 0 as i32 - && (*v).attributes & 0x1 as i32 != 0 + && (*v).attributes & 0x1 != 0 { - (*v).attributes &= !(0x1 as i32); + (*v).attributes &= !(0x1); } - //libc::free(value ); libc::free(value as *mut libc::c_void); } #[no_mangle] @@ -1581,11 +1587,11 @@ pub unsafe extern "C" fn r_initialize_bashopts(no_bashopts: i32) { temp = if (*var).attributes & att_array != 0 || (*var).attributes & att_assoc != 0 { - 0 as *mut libc::c_void as *mut libc::c_char + std::ptr::null_mut() } else { strcpy( xmalloc( - (1 as i32 as libc::c_ulong) + (1 as libc::c_ulong) .wrapping_add(strlen((*var).value)), ) as *mut libc::c_char, (*var).value, diff --git a/bash-5.1/builtins_rust/source/src/lib.rs b/bash-5.1/builtins_rust/source/src/lib.rs index f3e3d5e0..0aed0e8b 100644 --- a/bash-5.1/builtins_rust/source/src/lib.rs +++ b/bash-5.1/builtins_rust/source/src/lib.rs @@ -5,7 +5,7 @@ use libc::{c_char, c_long, c_void}; use std::{ffi::CString}; #[repr(C)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut libc::c_char, pub flags:libc::c_int } @@ -14,7 +14,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } #[repr(u8)] @@ -39,7 +39,7 @@ enum r_instruction { #[derive(Copy,Clone)] pub union REDIRECTEE { dest:libc::c_int, - filename:* mut WORD_DESC + filename:* mut WordDesc } #[repr(C)] @@ -58,7 +58,7 @@ pub union REDIRECT { pub struct for_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -75,7 +75,7 @@ pub struct PATTERN_LIST { pub struct case_com { flags:libc::c_int, line:libc::c_int, - word:*mut WORD_DESC, + word:*mut WordDesc, clauses:*mut PATTERN_LIST } @@ -114,7 +114,7 @@ pub struct simple_com { pub struct function_def { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, command:*mut COMMAND, source_file:*mut c_char } @@ -130,7 +130,7 @@ pub struct group_com { pub struct select_com { flags:libc::c_int, line:libc::c_int, - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } diff --git a/bash-5.1/builtins_rust/suspend/src/intercdep.rs b/bash-5.1/builtins_rust/suspend/src/intercdep.rs index c75067b2..ac1fd53e 100644 --- a/bash-5.1/builtins_rust/suspend/src/intercdep.rs +++ b/bash-5.1/builtins_rust/suspend/src/intercdep.rs @@ -5,13 +5,13 @@ // pub word: *mut c_char, // pub flags: c_int, // } -// pub type WORD_DESC = word_desc; +// pub type WordDesc = word_desc; // #[repr(C)] // #[derive(Copy, Clone)] // pub struct word_list { // pub next: *mut word_list, -// pub word: *mut WORD_DESC, +// pub word: *mut WordDesc, // } // pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/test/src/intercdep.rs b/bash-5.1/builtins_rust/test/src/intercdep.rs index 05be0bfe..515d49c5 100644 --- a/bash-5.1/builtins_rust/test/src/intercdep.rs +++ b/bash-5.1/builtins_rust/test/src/intercdep.rs @@ -5,13 +5,13 @@ // pub word: *mut c_char, // pub flags: c_int, // } -// pub type WORD_DESC = word_desc; +// pub type WordDesc = word_desc; // #[repr(C)] // #[derive(Copy, Clone)] // pub struct word_list { // pub next: *mut word_list, -// pub word: *mut WORD_DESC, +// pub word: *mut WordDesc, // } // pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/times/src/intercdep.rs b/bash-5.1/builtins_rust/times/src/intercdep.rs index beca3327..74e7b2e4 100644 --- a/bash-5.1/builtins_rust/times/src/intercdep.rs +++ b/bash-5.1/builtins_rust/times/src/intercdep.rs @@ -5,13 +5,13 @@ pub struct word_desc { pub word: *mut c_char, pub flags: c_int, } -pub type WORD_DESC = word_desc; +pub type WordDesc = word_desc; #[repr(C)] #[derive(Copy, Clone)] pub struct word_list { pub next: *mut word_list, - pub word: *mut WORD_DESC, + pub word: *mut WordDesc, } pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/trap/src/intercdep.rs b/bash-5.1/builtins_rust/trap/src/intercdep.rs index cbcbd002..5339dbb1 100644 --- a/bash-5.1/builtins_rust/trap/src/intercdep.rs +++ b/bash-5.1/builtins_rust/trap/src/intercdep.rs @@ -5,13 +5,13 @@ // pub word: *mut c_char, // pub flags: c_int, // } -// pub type WORD_DESC = word_desc; +// pub type WordDesc = word_desc; // #[repr(C)] // #[derive(Copy, Clone)] // pub struct word_list { // pub next: *mut word_list, -// pub word: *mut WORD_DESC, +// pub word: *mut WordDesc, // } // pub type WORD_LIST = word_list; diff --git a/bash-5.1/builtins_rust/type/src/lib.rs b/bash-5.1/builtins_rust/type/src/lib.rs index 0f0a43ae..b14dd28c 100644 --- a/bash-5.1/builtins_rust/type/src/lib.rs +++ b/bash-5.1/builtins_rust/type/src/lib.rs @@ -119,13 +119,13 @@ macro_rules! STREQ{ #[macro_export] macro_rules! SIZEOFWORD{ () => { - std::mem::size_of::() + std::mem::size_of::() } } #[repr(C)] #[derive(Copy,Clone)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut i8, pub flags:i32 } @@ -134,7 +134,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } #[repr(C)] @@ -224,7 +224,7 @@ pub union REDIRECT { pub struct for_com { flags: i32 , line: i32 , - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } @@ -233,14 +233,14 @@ pub struct for_com { #[derive(Copy,Clone)] pub union REDIRECTEE { dest: i32 , - filename:* mut WORD_DESC + filename:* mut WordDesc } #[repr(C)] pub struct case_com { flags: i32, line: i32, - word:*mut WORD_DESC, + word:*mut WordDesc, clauses:*mut PATTERN_LIST } #[repr(C)] @@ -285,7 +285,7 @@ pub struct simple_com { pub struct function_def { flags: i32 , line: i32 , - name:*mut WORD_DESC, + name:*mut WordDesc, command:*mut COMMAND, source_file:*mut i8 } @@ -301,7 +301,7 @@ pub struct group_com { pub struct select_com { flags: i32 , line: i32 , - name:*mut WORD_DESC, + name:*mut WordDesc, map_list:*mut WORD_LIST, action:*mut COMMAND } diff --git a/bash-5.1/builtins_rust/ulimit/src/lib.rs b/bash-5.1/builtins_rust/ulimit/src/lib.rs index 2e2d8627..664ebefe 100644 --- a/bash-5.1/builtins_rust/ulimit/src/lib.rs +++ b/bash-5.1/builtins_rust/ulimit/src/lib.rs @@ -16,7 +16,7 @@ pub struct rlimit { #[repr(C)] #[derive(Copy,Clone)] -pub struct WORD_DESC { +pub struct WordDesc { pub word: *mut i8, pub flags:i32 } @@ -25,7 +25,7 @@ pub struct WORD_DESC { #[derive(Copy,Clone)] pub struct WORD_LIST { next: *mut WORD_LIST, - word: *mut WORD_DESC + word: *mut WordDesc } #[repr (C)] diff --git a/bash-5.1/builtins_rust/umask/Cargo.toml b/bash-5.1/builtins_rust/umask/Cargo.toml index 1270c48d..3ec52c40 100644 --- a/bash-5.1/builtins_rust/umask/Cargo.toml +++ b/bash-5.1/builtins_rust/umask/Cargo.toml @@ -2,7 +2,7 @@ name = "rumask" version = "0.1.0" edition = "2018" -build = "../build.rs" +#build = "../build.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bash-5.1/builtins_rust/umask/src/lib.rs b/bash-5.1/builtins_rust/umask/src/lib.rs index 9191337c..77fe1656 100644 --- a/bash-5.1/builtins_rust/umask/src/lib.rs +++ b/bash-5.1/builtins_rust/umask/src/lib.rs @@ -8,7 +8,7 @@ use rcommon::{r_read_octal}; //结构体 #[repr (C)] #[derive(Debug)] -pub struct WORD_DESC{ +pub struct WordDesc{ pub word:*mut c_char, pub flags:c_int, } @@ -17,7 +17,7 @@ pub struct WORD_DESC{ #[derive(Debug)] pub struct WORD_LIST{ pub next:*mut WORD_LIST, - pub word:*mut WORD_DESC, + pub word:*mut WordDesc, } diff --git a/record.txt b/record.txt index d2cb2c80..ffe7c603 100644 --- a/record.txt +++ b/record.txt @@ -14,3 +14,4 @@ 36 37 38 +39 -- Gitee