From 1faf7132f71592c33bd4526713b01dcbcdb3d0bf Mon Sep 17 00:00:00 2001 From: wangmengc Date: Fri, 30 Jun 2023 10:46:31 +0800 Subject: [PATCH] sync from rpmbuild,remove doc and other file --- bash-5.1/.cargo/config.toml | 5 +++ bash-5.1/Makefile.in | 45 +++------------------ bash-5.1/builtins/pushd.def | 1 + bash-5.1/builtins_rust/alias/src/lib.rs | 4 +- bash-5.1/builtins_rust/bind/src/lib.rs | 2 - bash-5.1/builtins_rust/break_1/src/lib.rs | 37 +++++++++++------ bash-5.1/builtins_rust/caller/src/lib.rs | 6 +-- bash-5.1/builtins_rust/colon/src/lib.rs | 2 - bash-5.1/builtins_rust/common/Cargo.toml | 9 +++-- bash-5.1/builtins_rust/common/src/lib.rs | 4 +- bash-5.1/builtins_rust/declare/src/lib.rs | 11 +++--- bash-5.1/builtins_rust/echo/src/lib.rs | 1 - bash-5.1/builtins_rust/eval/Cargo.toml | 2 +- bash-5.1/builtins_rust/eval/src/lib.rs | 1 - bash-5.1/builtins_rust/exec/src/lib.rs | 18 --------- bash-5.1/builtins_rust/exec_cmd/Cargo.toml | 2 +- bash-5.1/builtins_rust/exit/Cargo.toml | 4 +- bash-5.1/builtins_rust/exit/src/lib.rs | 16 ++++---- bash-5.1/builtins_rust/getopts/src/lib.rs | 13 ------ bash-5.1/builtins_rust/hash/Cargo.toml | 2 +- bash-5.1/builtins_rust/hash/src/lib.rs | 15 ------- bash-5.1/builtins_rust/help/Cargo.toml | 10 ++--- bash-5.1/builtins_rust/history/src/lib.rs | 1 - bash-5.1/builtins_rust/jobs/src/lib.rs | 3 -- bash-5.1/builtins_rust/kill/src/lib.rs | 1 - bash-5.1/builtins_rust/mapfile/src/lib.rs | 1 - bash-5.1/builtins_rust/printf/src/lib.rs | 1 - bash-5.1/builtins_rust/pushd/src/lib.rs | 8 ---- bash-5.1/builtins_rust/read/src/lib.rs | 1 - bash-5.1/builtins_rust/rlet/src/lib.rs | 4 +- bash-5.1/builtins_rust/rreturn/src/lib.rs | 1 - bash-5.1/builtins_rust/set/src/lib.rs | 15 ++++--- bash-5.1/builtins_rust/setattr/src/lib.rs | 4 +- bash-5.1/builtins_rust/shift/src/lib.rs | 1 - bash-5.1/builtins_rust/shopt/src/lib.rs | 4 +- bash-5.1/builtins_rust/source/src/lib.rs | 8 ---- bash-5.1/builtins_rust/suspend/src/lib.rs | 3 +- bash-5.1/builtins_rust/test/src/lib.rs | 1 - bash-5.1/builtins_rust/times/src/lib.rs | 1 - bash-5.1/builtins_rust/trap/src/lib.rs | 1 - bash-5.1/builtins_rust/umask/Cargo.toml | 2 +- bash-5.1/builtins_rust/umask/src/lib.rs | 9 ----- bash-5.1/configure | 46 ++++++++++++---------- bash-5.1/configure.ac | 15 ++----- bash-5.1/execute_cmd.c | 4 +- bash-5.1/support/rash.pc | 2 +- record.txt | 1 + 47 files changed, 113 insertions(+), 235 deletions(-) diff --git a/bash-5.1/.cargo/config.toml b/bash-5.1/.cargo/config.toml index 11bdee26..cdf1653e 100644 --- a/bash-5.1/.cargo/config.toml +++ b/bash-5.1/.cargo/config.toml @@ -1,6 +1,11 @@ [source.crates-io] replace-with = "vendored-sources" +[source."https://github.com/shadowsocks/crypto"] +git = "https://github.com/shadowsocks/crypto" +branch = "master" +replace-with = "vendored-sources" + [source.vendored-sources] directory = "vendor" diff --git a/bash-5.1/Makefile.in b/bash-5.1/Makefile.in index 3ea296c0..f17ec7bc 100644 --- a/bash-5.1/Makefile.in +++ b/bash-5.1/Makefile.in @@ -243,7 +243,7 @@ SHLIB_DEP = ${SHLIB_LIBRARY} # we assume for now that readline source is being shipped with bash RL_LIBSRC = $(LIBSRC)/readline -RL_LIBDOC = $(RL_LIBSRC)/doc +# RL_LIBDOC = $(RL_LIBSRC)/doc RL_LIBDIR = @RL_LIBDIR@ RL_ABSSRC = ${topdir}/$(RL_LIBDIR) @@ -535,10 +535,6 @@ BUILTINS_LIB = -lbuiltins BUILTINS_LDFLAGS = -L$(DEFDIR) BUILTINS_DEP = $(BUILTINS_LIBRARY) -# Documentation for the shell. -DOCSRC = $(srcdir)/doc -DOCDIR = $(dot)/doc - # Translations and other i18n support files PO_SRC = $(srcdir)/po/ PO_DIR = $(dot)/po/ @@ -557,21 +553,19 @@ CREATED_SUPPORT = signames.h recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) \ buildversion.o mksignames.o signames.o buildsignames.o CREATED_CONFIGURE = config.h config.cache config.status config.log \ stamp-h po/POTFILES config.status.lineno -CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \ +CREATED_MAKEFILES = Makefile builtins/Makefile \ lib/readline/Makefile lib/glob/Makefile \ lib/sh/Makefile lib/tilde/Makefile lib/malloc/Makefile \ - lib/termcap/Makefile examples/loadables/Makefile \ - examples/loadables/Makefile.inc \ - examples/loadables/perl/Makefile support/Makefile \ + lib/termcap/Makefile \ + support/Makefile \ lib/intl/Makefile po/Makefile po/Makefile.in CREATED_HEADERS = signames.h config.h pathnames.h version.h y.tab.h \ ${DEFDIR}/builtext.h OTHER_DOCS = $(srcdir)/CHANGES $(srcdir)/COMPAT $(srcdir)/NEWS $(srcdir)/POSIX \ - $(srcdir)/RBASH $(srcdir)/README + $(srcdir)/RBASH OTHER_INSTALLED_DOCS = CHANGES COMPAT NEWS POSIX RBASH README -LOADABLES_DIR = ${top_builddir}/examples/loadables RUST_DIR = $(top_builddir)/builtins_rust #RUST_TARGET_LIB = $(top_builddir)/target/debug/librjobs.a $(top_builddir)/target/debug/librread.a @@ -798,8 +792,6 @@ $(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/aclocal.m4 $(srcdir)/confi reconfig: force sh $(srcdir)/configure -C -loadables: - cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) all #newversion: mkversion # $(RM) .build @@ -807,11 +799,6 @@ loadables: # mv -f newversion.h version.h # $(MAKE) -f $(srcdir)/Makefile $(MFLAGS) srcdir=$(srcdir) -doc documentation: force - @(cd $(DOCDIR) ; $(MAKE) $(MFLAGS) ) - -info dvi ps: force - @(cd $(DOCDIR) ; $(MAKE) $(MFLAGS) CFLAGS='$(CCFLAGS)' $@ ) force: @@ -826,19 +813,12 @@ tags: $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) installdirs: @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(bindir) - @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(man1dir) @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(infodir) - @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(docdir) -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) install: .made installdirs $(INSTALL_PROGRAM) $(INSTALLMODE) $(Program) $(DESTDIR)$(bindir)/$(Program) $(INSTALL_SCRIPT) $(INSTALLMODE2) rashbug $(DESTDIR)$(bindir)/rashbug - $(INSTALL_DATA) $(OTHER_DOCS) $(DESTDIR)$(docdir) - -( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \ - man1dir=$(man1dir) man1ext=$(man1ext) \ - man3dir=$(man3dir) man3ext=$(man3ext) \ - infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ ) -( cd $(DEFDIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) @@ -881,13 +861,7 @@ uninstall-headers: uninstall: .made $(RM) $(DESTDIR)$(bindir)/$(Program) $(DESTDIR)$(bindir)/rashbug - -( cd $(DESTDIR)$(docdir) && ${RM} ${OTHER_INSTALLED_DOCS} ) - -( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \ - man1dir=$(man1dir) man1ext=$(man1ext) \ - man3dir=$(man3dir) man3ext=$(man3ext) \ - infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ ) -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) .PHONY: basic-clean clean realclean maintainer-clean distclean mostlyclean maybe-clean @@ -900,36 +874,30 @@ basic-clean: cargo clean clean: basic-clean - ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) ( cd builtins && $(MAKE) $(MFLAGS) $@ ) -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ ) -for libdir in ${LIB_SUBDIRS}; do \ (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\ done -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) $(RM) $(CREATED_SUPPORT) cargo clean mostlyclean: basic-clean - ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) ( cd builtins && $(MAKE) $(MFLAGS) $@ ) -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ ) -for libdir in ${LIB_SUBDIRS}; do \ (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\ done -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) distclean: basic-clean maybe-clean - ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) ( cd builtins && $(MAKE) $(MFLAGS) $@ ) -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ ) -for libdir in ${LIB_SUBDIRS}; do \ (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\ done -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) $(RM) $(CREATED_CONFIGURE) tags TAGS $(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES) pathnames.h @@ -937,14 +905,12 @@ maintainer-clean: basic-clean @echo This command is intended for maintainers to use. @echo It deletes files that may require special tools to rebuild. $(RM) y.tab.c y.tab.h parser-built tags TAGS - ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) ( cd builtins && $(MAKE) $(MFLAGS) $@ ) ( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ ) -for libdir in ${LIB_SUBDIRS}; do \ (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\ done -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) $(RM) $(CREATED_CONFIGURE) $(CREATED_MAKEFILES) $(RM) $(CREATED_SUPPORT) Makefile pathnames.h @@ -980,7 +946,6 @@ dist: force @echo $(Program) $(srcdir)/support/mkdist -m $(srcdir)/MANIFEST -s $(srcdir) -r ${PACKAGE} -t $(PACKAGE_VERSION) xdist: force - ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) ( cd po && $(MAKE) $(MFLAGS) $@ ) depend: depends diff --git a/bash-5.1/builtins/pushd.def b/bash-5.1/builtins/pushd.def index de1bb2df..033b3b30 100644 --- a/bash-5.1/builtins/pushd.def +++ b/bash-5.1/builtins/pushd.def @@ -414,6 +414,7 @@ int dirs_builtin (list) WORD_LIST *list; { +return r_dirs_builtin(list); int flags, desired_index, index_flag, vflag; intmax_t i; char *temp, *w; diff --git a/bash-5.1/builtins_rust/alias/src/lib.rs b/bash-5.1/builtins_rust/alias/src/lib.rs index 0bc7078c..c9e53be3 100644 --- a/bash-5.1/builtins_rust/alias/src/lib.rs +++ b/bash-5.1/builtins_rust/alias/src/lib.rs @@ -65,7 +65,6 @@ pub static AL_REUSABLE:i32 = 0x01; #[no_mangle] pub unsafe extern "C" fn r_alias_builtin(mut list: *mut WordList) -> libc::c_int { - println!("alias_builtin run!"); let mut any_failed; let mut offset; let mut pflag ; @@ -160,7 +159,6 @@ pub unsafe extern "C" fn r_alias_builtin(mut list: *mut WordList) -> libc::c_int } #[no_mangle] pub unsafe extern "C" fn r_unalias_builtin(mut list: *mut WordList) -> libc::c_int { - println!("alias_builtin run!"); let mut alias: *mut AliasT; let mut opt: libc::c_int; let mut aflag: libc::c_int; @@ -174,7 +172,7 @@ pub unsafe extern "C" fn r_unalias_builtin(mut list: *mut WordList) -> libc::c_i if !(opt != -(1 as libc::c_int)) { break; } - match opt as u8{ + match opt as u8 { b'a' => { aflag = 1 as libc::c_int; } diff --git a/bash-5.1/builtins_rust/bind/src/lib.rs b/bash-5.1/builtins_rust/bind/src/lib.rs index 69fd41be..cb162188 100644 --- a/bash-5.1/builtins_rust/bind/src/lib.rs +++ b/bash-5.1/builtins_rust/bind/src/lib.rs @@ -161,8 +161,6 @@ pub extern "C" fn r_bind_builtin(mut list:*mut WordList)->i32{ let mut cmd_seq:*mut c_char; let t:*mut c_char; - println!("r_bind_builtin"); - unsafe{ if no_line_editing != 0{ builtin_warning( 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 54df7d5e..1240b951 100644 --- a/bash-5.1/builtins_rust/break_1/src/lib.rs +++ b/bash-5.1/builtins_rust/break_1/src/lib.rs @@ -9,26 +9,35 @@ use libc::c_long; use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE}; -// 屏蔽警告。 -#[allow(non_camel_case_types)] type intmax_t = c_long; - +/* #[macro_export] macro_rules! ISHELP { ($s:expr) => { - libc::strcmp($s as *const libc::c_char,CString::new("--help").unwrap().as_ptr()) + libc::strcmp($s as *const libc::c_char, CString::new("--help").unwrap().as_ptr()) } } #[macro_export] macro_rules! CHECK_HELPOPT { ($l:expr) => { - if $l !=std::ptr::null_mut() && (*$l).word !=std::ptr::null_mut() && ISHELP!((*(*$l).word).word) == 0 { + if $l !=std::ptr::null_mut() && (*$l).word !=std::ptr::null_mut() && ISHELP!((*(*$l).word).word) ==0 { builtin_help (); return EX_USAGE; } } } +*/ +fn checkhelp(l: *mut WordList) -> i32{ + unsafe { + let tmp=CString::new("--help").unwrap(); + if l!=std::ptr::null_mut() && (*l).word !=std::ptr::null_mut() && + libc::strcmp((*((*l).word)).word, tmp.as_ptr()) == 0 { + builtin_help(); + } + return EX_USAGE; + } +} extern "C" { fn get_numeric_arg(list :*mut WordList, i: i32 , intmax :*mut intmax_t) -> i32; @@ -50,15 +59,16 @@ pub extern "C" fn r_break_builtin(mut list :*mut WordList) -> i32 { //println!("enter r_break_builtin"); let mut newbreak : intmax_t = 1 as intmax_t; unsafe { - CHECK_HELPOPT! (list); + checkhelp(list); + //CHECK_HELPOPT! (list); if check_loop_level() == 0 { return EXECUTION_SUCCESS!(); } get_numeric_arg(list, 1, &mut newbreak as *mut intmax_t); if newbreak <= 0{ - #[warn(temporary_cstring_as_ptr)] - sh_erange ((*(*list).word).word, CString::new("loop count").unwrap().as_ptr() as * mut libc::c_char); + let mut tmp = CString::new("loop count ").unwrap(); + sh_erange ((*(*list).word).word, tmp.as_ptr() as * mut libc::c_char); //set_breaking (get_loop_level()); breaking = loop_level; return EXECUTION_FAILURE!(); @@ -74,21 +84,22 @@ pub extern "C" fn r_break_builtin(mut list :*mut WordList) -> i32 { } #[no_mangle] -pub extern "C" fn r_continue_builtin (list :*mut WordList) -> i32 { +pub extern "C" fn r_continue_builtin (mut list :*mut WordList) -> i32 { let mut newcont : intmax_t = 0 as intmax_t; unsafe { - CHECK_HELPOPT! (list); + //CHECK_HELPOPT! (list); + checkhelp(list); } if check_loop_level() == 0 { return (EXECUTION_SUCCESS!()); } unsafe { - get_numeric_arg(list, 1, newcont as *mut intmax_t); + get_numeric_arg(list, 1, &mut newcont as *mut intmax_t); } unsafe { if newcont <= 0{ - #[warn(temporary_cstring_as_ptr)] - sh_erange ((*(*list).word).word, CString::new("loop count ").unwrap().as_ptr() as * mut libc::c_char); + let mut tmp = CString::new("loop count ").unwrap(); + sh_erange ((*(*list).word).word, tmp.as_ptr() as * mut libc::c_char); //set_breaking(get_loop_level()); breaking = loop_level; return (EXECUTION_FAILURE!()); diff --git a/bash-5.1/builtins_rust/caller/src/lib.rs b/bash-5.1/builtins_rust/caller/src/lib.rs index a888b538..bcc97b3a 100644 --- a/bash-5.1/builtins_rust/caller/src/lib.rs +++ b/bash-5.1/builtins_rust/caller/src/lib.rs @@ -118,8 +118,6 @@ pub extern "C" fn r_caller_builtin(mut list:*mut WordList)->i32{ let mut c_str :CString; - println!("r_caller_builtin"); - unsafe{ CHECK_HELPOPT!(list); @@ -152,7 +150,7 @@ pub extern "C" fn r_caller_builtin(mut list:*mut WordList)->i32{ list = loptend; /* skip over possible `--' */ /* If there is no argument list, then give short form: line filename. */ - if list.is_null(){ + if list.is_null() { lineno_s = array_reference(bash_lineno_a,0); source_s = array_reference(bash_source_a,1); @@ -162,7 +160,6 @@ pub extern "C" fn r_caller_builtin(mut list:*mut WordList)->i32{ else{ c_str = CString::new("NULL").unwrap(); lineno_s = c_str.as_ptr() as *mut c_char; - // lineno_s = CString::new("NULL").unwrap().as_ptr() as *mut c_char; } if !source_s.is_null(){ @@ -171,7 +168,6 @@ pub extern "C" fn r_caller_builtin(mut list:*mut WordList)->i32{ else{ c_str = CString::new("NULL").unwrap(); source_s = c_str.as_ptr() as *mut c_char; - // source_s = CString::new("NULL").unwrap().as_ptr() as *mut c_char; } let lineno_s_str = CStr::from_ptr(lineno_s).to_str().unwrap().to_owned(); let source_s_str = CStr::from_ptr(source_s).to_str().unwrap().to_owned(); diff --git a/bash-5.1/builtins_rust/colon/src/lib.rs b/bash-5.1/builtins_rust/colon/src/lib.rs index 393088e9..a5b8ae8b 100644 --- a/bash-5.1/builtins_rust/colon/src/lib.rs +++ b/bash-5.1/builtins_rust/colon/src/lib.rs @@ -14,12 +14,10 @@ mod tests { #[no_mangle] pub extern "C" fn r_colon_builtin(ignore: *mut WordList )->i32 { - println!("in r_colon_builtin"); 0 } #[no_mangle] pub extern "C" fn r_false_builtin(ignore: *mut WordList) -> i32 { - println!("in r_false_builtin"); 1 } diff --git a/bash-5.1/builtins_rust/common/Cargo.toml b/bash-5.1/builtins_rust/common/Cargo.toml index 374f067f..12b06063 100644 --- a/bash-5.1/builtins_rust/common/Cargo.toml +++ b/bash-5.1/builtins_rust/common/Cargo.toml @@ -1,14 +1,15 @@ [package] name = "rcommon" version = "0.1.0" -edition = "2021" +edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libc = "0.2" -nix = "0.24" -unic-langid = "0.9.0" +libc = "*" +nix = "*" +unic-langid = "*" + [lib] crate-type = ["staticlib","rlib"] name = "rcommon" diff --git a/bash-5.1/builtins_rust/common/src/lib.rs b/bash-5.1/builtins_rust/common/src/lib.rs index 50f96f76..a40a9d12 100644 --- a/bash-5.1/builtins_rust/common/src/lib.rs +++ b/bash-5.1/builtins_rust/common/src/lib.rs @@ -1732,7 +1732,7 @@ pub extern "C" fn r_builtin_bind_variable(name:*mut c_char,value:*mut c_char,fla /* Like check_unbind_variable, but for use by builtins (only matters for error messages). */ - pub extern "C" fn r_builtin_unbind_variable(vname:*const c_char)->i32{ +pub extern "C" fn r_builtin_unbind_variable(vname:*const c_char)->i32{ let v:*mut SHELL_VAR; unsafe{ @@ -1771,4 +1771,4 @@ pub extern "C" fn get_local_str()-> Vec{ let langid : LanguageIdentifier = lang.parse().expect("wrong language"); let locales = vec![langid.into()]; return locales; - } \ No newline at end of file + } diff --git a/bash-5.1/builtins_rust/declare/src/lib.rs b/bash-5.1/builtins_rust/declare/src/lib.rs index 6da37b12..7c70152f 100644 --- a/bash-5.1/builtins_rust/declare/src/lib.rs +++ b/bash-5.1/builtins_rust/declare/src/lib.rs @@ -568,9 +568,9 @@ pub extern "C" fn r_declare_find_variable (name:* const c_char, mkglobal:i32, ch } } -unsafe fn DECLARE_OPTS()->* const c_char +unsafe fn DECLARE_OPTS()-> CString { - return CString::new("+acfgilnprtuxAFGI").unwrap().as_ptr(); + return CString::new("+acfgilnprtuxAFGI").unwrap(); } unsafe fn savestring(x:* const c_char)->* mut c_char @@ -662,7 +662,8 @@ pub extern "C" fn r_declare_internal (list:* mut WordList, local_var:i32)->i32 unsafe { reset_internal_getopt (); - opt = internal_getopt (list, DECLARE_OPTS() as * mut c_char); + let tmp = DECLARE_OPTS().as_ptr(); + opt = internal_getopt (list, tmp as * mut c_char); while opt != -1 { if list_opttype == '+' as i32 { flags= &mut flags_off; @@ -677,7 +678,7 @@ pub extern "C" fn r_declare_internal (list:* mut WordList, local_var:i32)->i32 the loop in subst.c:shell_expand_word_list() */ match optChar { 'a'=>{ *flags |= att_array!();} - 'A'=>{ *flags |= att_assoc!();} + 'A'=>{ *flags |= att_assoc!();} 'p'=>{ pflag+=1;} 'F'=>{ nodefs+=1; *flags |= att_function!(); @@ -725,7 +726,7 @@ pub extern "C" fn r_declare_internal (list:* mut WordList, local_var:i32)->i32 return EX_USAGE; } } - internal_getopt (list, DECLARE_OPTS() as * mut c_char); + internal_getopt (list, tmp as * mut c_char); } let mut llist:* mut WordList = loptend.clone(); diff --git a/bash-5.1/builtins_rust/echo/src/lib.rs b/bash-5.1/builtins_rust/echo/src/lib.rs index 59056708..3302a38b 100644 --- a/bash-5.1/builtins_rust/echo/src/lib.rs +++ b/bash-5.1/builtins_rust/echo/src/lib.rs @@ -76,7 +76,6 @@ pub static mut xpg_echo:i32 = 0; // 也有可能是1 #[no_mangle] pub extern "C" fn r_echo_builtin(mut list:*mut WordList)->i32{ - println!("r_echo_builtin"); let mut display_return:i32; let mut do_v9:i32; let mut i:i32; diff --git a/bash-5.1/builtins_rust/eval/Cargo.toml b/bash-5.1/builtins_rust/eval/Cargo.toml index ee63c0c4..d1622760 100644 --- a/bash-5.1/builtins_rust/eval/Cargo.toml +++ b/bash-5.1/builtins_rust/eval/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libc = "0.2" +libc = "*" rcommon = {path = "../common"} [lib] diff --git a/bash-5.1/builtins_rust/eval/src/lib.rs b/bash-5.1/builtins_rust/eval/src/lib.rs index a882f3ce..6d80d5e6 100644 --- a/bash-5.1/builtins_rust/eval/src/lib.rs +++ b/bash-5.1/builtins_rust/eval/src/lib.rs @@ -22,7 +22,6 @@ extern "C" { #[no_mangle] pub extern "C" fn r_eval_builtin(mut list:*mut WordList)->i32{ - println!("r_eval_builtin"); unsafe{ if r_no_options(list) != 0{ diff --git a/bash-5.1/builtins_rust/exec/src/lib.rs b/bash-5.1/builtins_rust/exec/src/lib.rs index d2a4aff4..df518d0d 100644 --- a/bash-5.1/builtins_rust/exec/src/lib.rs +++ b/bash-5.1/builtins_rust/exec/src/lib.rs @@ -8,21 +8,6 @@ use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE use nix::errno::errno; use rcommon::r_sh_restricted; -/* -#[repr (C)] -#[derive(Copy,Clone)] -pub struct WordDesc{ - pub word:*mut c_char, - pub flags:c_int, -} - -#[repr (C)] -#[derive(Copy,Clone)] -pub struct WordList{ - pub next:*mut WordList, - pub word:*mut WordDesc, -} -*/ #[repr(C)] struct redirect{ next:*mut redirect, @@ -157,9 +142,6 @@ pub extern "C" fn r_exec_builtin(mut list:*mut WordList)->i32{ let newname:*mut c_char; let com2:*mut c_char; - println!("r_exec_builtin"); - - unsafe{ exec_argv0 = std::ptr::null_mut() as *mut c_char; diff --git a/bash-5.1/builtins_rust/exec_cmd/Cargo.toml b/bash-5.1/builtins_rust/exec_cmd/Cargo.toml index b120c60b..f44bc7e6 100644 --- a/bash-5.1/builtins_rust/exec_cmd/Cargo.toml +++ b/bash-5.1/builtins_rust/exec_cmd/Cargo.toml @@ -2,7 +2,7 @@ authors = ["zhanghuanhuan"] name = "rexec_cmd" version = "0.0.1" -edition = "2021" +edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/bash-5.1/builtins_rust/exit/Cargo.toml b/bash-5.1/builtins_rust/exit/Cargo.toml index 466a0f78..f8ca1674 100644 --- a/bash-5.1/builtins_rust/exit/Cargo.toml +++ b/bash-5.1/builtins_rust/exit/Cargo.toml @@ -7,8 +7,8 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libc = "0.2" -nix = "0.23.0" +libc = "*" +nix = "*" rjobs = {path="../jobs"} rcommon = {path="../common"} diff --git a/bash-5.1/builtins_rust/exit/src/lib.rs b/bash-5.1/builtins_rust/exit/src/lib.rs index 0f74aab5..e5346295 100644 --- a/bash-5.1/builtins_rust/exit/src/lib.rs +++ b/bash-5.1/builtins_rust/exit/src/lib.rs @@ -133,7 +133,6 @@ static mut sourced_logout:i32 = 0; #[no_mangle] pub extern "C" fn r_exit_builtin(list:*mut WordList) -> i32{ - println!("r_exit_builtin"); unsafe{ let c_str = CString::new("--help").unwrap(); let c_ptr = c_str.as_ptr(); @@ -163,7 +162,7 @@ pub extern "C" fn r_exit_builtin(list:*mut WordList) -> i32{ #[no_mangle] pub extern "C" fn r_logout_builtin(list:*mut WordList)->i32{ - unsafe{ + unsafe { let c_str = CString::new("--help").unwrap(); let c_ptr = c_str.as_ptr(); if list != std::ptr::null_mut() && (*list).word != std::ptr::null_mut() && @@ -183,9 +182,7 @@ pub extern "C" fn r_logout_builtin(list:*mut WordList)->i32{ } } -#[no_mangle] -pub extern "C" fn r_exit_or_logout(list:*mut WordList)->i32{ - // let stream:*mut libc::FILE; +pub fn r_exit_or_logout(list:*mut WordList)->i32{ let exit_value:i32; let exit_immediate_okay:i32; let mut stopmsg:i32; @@ -200,16 +197,18 @@ pub extern "C" fn r_exit_or_logout(list:*mut WordList)->i32{ if exit_immediate_okay == 0 { stopmsg = 0; for i in 0..js.j_jobslots { + // println!("jobs: {}", i); if get_job_by_jid!(i) != std::ptr::null_mut() && STOPPED!(i){ stopmsg = JOB_STATE::JSTOPPED as i32; + break; } else if (check_jobs_at_exit != 0) && (stopmsg ==0) && get_job_by_jid!(i) != std::ptr::null_mut() && RUNNING!(i) { stopmsg = JOB_STATE::JRUNNING as i32; + break; } } if stopmsg == JOB_STATE::JSTOPPED as i32 { - // libc::fprintf(stream,CString::new("There are stopped jobs. \n").unwrap().as_ptr()); eprintln!("There are stopped jobs. "); } else if stopmsg == JOB_STATE::JRUNNING as i32{ @@ -244,8 +243,9 @@ pub extern "C" fn r_exit_or_logout(list:*mut WordList)->i32{ } } -#[no_mangle] -pub extern "C" fn r_bash_logout(){ +//#[no_mangle] +//pub extern "C" fn r_bash_logout(){ +pub fn r_bash_logout(){ unsafe{ if login_shell != 0 && sourced_logout == 0 && subshell_environment == 0 { sourced_logout = sourced_logout + 1; diff --git a/bash-5.1/builtins_rust/getopts/src/lib.rs b/bash-5.1/builtins_rust/getopts/src/lib.rs index 1ecc59b3..12491386 100644 --- a/bash-5.1/builtins_rust/getopts/src/lib.rs +++ b/bash-5.1/builtins_rust/getopts/src/lib.rs @@ -3,20 +3,7 @@ extern crate nix; use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE,GETOPT_HELP, r_builtin_usage}; use libc::{c_char, c_long, c_void}; use std::{ffi::CString}; -/* -#[repr(C)] -pub struct WordDesc { - pub word: *mut libc::c_char, - pub flags:libc::c_int -} -#[repr(C)] -#[derive(Copy,Clone)] -pub struct WordList { - next: *mut WordList, - word: *mut WordDesc -} - */ #[repr(u8)] enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select, cm_connection, cm_function_def, cm_until, cm_group, diff --git a/bash-5.1/builtins_rust/hash/Cargo.toml b/bash-5.1/builtins_rust/hash/Cargo.toml index 4c1bd098..94e70327 100644 --- a/bash-5.1/builtins_rust/hash/Cargo.toml +++ b/bash-5.1/builtins_rust/hash/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libc = "0.2" +libc = "*" rread = {path = "../read"} rcommon = {path = "../common"} diff --git a/bash-5.1/builtins_rust/hash/src/lib.rs b/bash-5.1/builtins_rust/hash/src/lib.rs index 698a3f95..f31ff564 100644 --- a/bash-5.1/builtins_rust/hash/src/lib.rs +++ b/bash-5.1/builtins_rust/hash/src/lib.rs @@ -8,22 +8,7 @@ use std::io::{stdout, Write}; use rread::{SHELL_VAR}; use rcommon::{r_find_shell_builtin,r_builtin_usage}; use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE}; -//struct -//结构体 -/* -#[repr (C)] -pub struct WordDesc{ - pub word:*mut c_char, - pub flags:c_int, -} -#[repr (C)] -// #[derive(Copy,Clone)] -pub struct WordList{ - pub next:*mut WordList, - pub word:*mut WordDesc, -} -*/ type PTR_T=c_void; #[repr (C)] pub struct bucket_contents{ diff --git a/bash-5.1/builtins_rust/help/Cargo.toml b/bash-5.1/builtins_rust/help/Cargo.toml index 12282469..9a0cd0fb 100644 --- a/bash-5.1/builtins_rust/help/Cargo.toml +++ b/bash-5.1/builtins_rust/help/Cargo.toml @@ -6,12 +6,12 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libc = "0.2" -nix = "0.24.1" +libc = "*" +nix = "*" rcommon = {path ="../common"} -fluent = "0.16.0" -fluent-bundle = "0.15.2" -fluent-resmgr = "0.0.5" +fluent = "*" +fluent-bundle = "*" +fluent-resmgr = "*" [lib] crate-type = ["staticlib","rlib"] diff --git a/bash-5.1/builtins_rust/history/src/lib.rs b/bash-5.1/builtins_rust/history/src/lib.rs index 54fd1b46..246a68e6 100644 --- a/bash-5.1/builtins_rust/history/src/lib.rs +++ b/bash-5.1/builtins_rust/history/src/lib.rs @@ -16,7 +16,6 @@ pub const DFLAG: c_int = 0x80; #[no_mangle] pub extern "C" fn r_history_builtin(mut list: *mut WordList) -> i32 { - println!("r_history_builtin call"); let mut flags: c_int = 0; let mut opt: c_int; diff --git a/bash-5.1/builtins_rust/jobs/src/lib.rs b/bash-5.1/builtins_rust/jobs/src/lib.rs index 17b62c73..18e88ec7 100644 --- a/bash-5.1/builtins_rust/jobs/src/lib.rs +++ b/bash-5.1/builtins_rust/jobs/src/lib.rs @@ -373,7 +373,6 @@ extern "C" { #[no_mangle] pub extern "C" fn r_execute_list_with_replacements (list:*mut WordList)->i32{ - //println!("r_execute_list_with_replacements"); unsafe{ let mut l:*mut WordList=list; let mut job:i32; @@ -416,7 +415,6 @@ extern "C" { #[no_mangle] pub extern "C" fn r_jobs_builtin(mut list:*mut WordList)->i32 { - println!("r_jobs_builtin"); let mut form:i32; let mut execute:i32=0; let mut state:i32; @@ -517,7 +515,6 @@ pub extern "C" fn r_disown_builtin (list:* mut WordList)->libc::c_int { let mut set:nix::sys::signal::SigSet=nix::sys::signal::SigSet::empty(); let mut oset:nix::sys::signal::SigSet =nix::sys::signal::SigSet::empty(); let mut pid_value:c_long=0; - //println!("r_disown_builtin"); unsafe { reset_internal_getopt (); let mut c_str_ahr = CString::new("ahr").unwrap(); // from a &str, creates a new allocation diff --git a/bash-5.1/builtins_rust/kill/src/lib.rs b/bash-5.1/builtins_rust/kill/src/lib.rs index 0a6f2374..c47bd9b7 100644 --- a/bash-5.1/builtins_rust/kill/src/lib.rs +++ b/bash-5.1/builtins_rust/kill/src/lib.rs @@ -8,7 +8,6 @@ include!(concat!("intercdep.rs")); #[no_mangle] pub extern "C" fn r_kill_builtin(mut list: *mut WordList) -> i32 { - println!("r_kill_builtin call"); unsafe { let mut word: *mut c_char; diff --git a/bash-5.1/builtins_rust/mapfile/src/lib.rs b/bash-5.1/builtins_rust/mapfile/src/lib.rs index c4d9530d..4bb49f9a 100644 --- a/bash-5.1/builtins_rust/mapfile/src/lib.rs +++ b/bash-5.1/builtins_rust/mapfile/src/lib.rs @@ -13,7 +13,6 @@ static mut delim: c_int = 0; #[no_mangle] pub extern "C" fn r_mapfile_builtin(mut list: *mut WordList) -> i32 { - println!("r_mapfile_builtin call"); let mut opt: c_int; let mut code: c_int; diff --git a/bash-5.1/builtins_rust/printf/src/lib.rs b/bash-5.1/builtins_rust/printf/src/lib.rs index 429860b0..76c65a41 100644 --- a/bash-5.1/builtins_rust/printf/src/lib.rs +++ b/bash-5.1/builtins_rust/printf/src/lib.rs @@ -61,7 +61,6 @@ unsafe fn savestring(x:* mut c_char)->* mut c_char #[no_mangle] pub extern "C" fn r_printf_builtin(mut list: *mut WordList) -> i32 { - println!("r_printf_builtin call"); let mut ch: c_int; let mut fieldwidth: c_int; diff --git a/bash-5.1/builtins_rust/pushd/src/lib.rs b/bash-5.1/builtins_rust/pushd/src/lib.rs index 08d04fa5..4355cfe1 100644 --- a/bash-5.1/builtins_rust/pushd/src/lib.rs +++ b/bash-5.1/builtins_rust/pushd/src/lib.rs @@ -23,14 +23,6 @@ enum r_instruction { r_move_input, r_move_output, r_move_input_word, r_move_output_word, r_append_err_and_out } -/* -#[repr(C)] -#[derive(Copy,Clone)] -pub union REDIRECTEE { - dest:libc::c_int, - filename:* mut WordDesc -} -*/ #[repr(C)] pub union REDIRECT { diff --git a/bash-5.1/builtins_rust/read/src/lib.rs b/bash-5.1/builtins_rust/read/src/lib.rs index d5ae2945..bbc3c10e 100644 --- a/bash-5.1/builtins_rust/read/src/lib.rs +++ b/bash-5.1/builtins_rust/read/src/lib.rs @@ -46,7 +46,6 @@ static mut default_buffered_input : c_int = -1; #[no_mangle] pub extern "C" fn r_read_builtin(mut list: *mut WordList) -> i32 { - println!("r_read_builtin call"); let mut varname :*mut c_char = libc::PT_NULL as *mut c_char; let mut size : c_int = 0; diff --git a/bash-5.1/builtins_rust/rlet/src/lib.rs b/bash-5.1/builtins_rust/rlet/src/lib.rs index 56186ed0..629da2ef 100644 --- a/bash-5.1/builtins_rust/rlet/src/lib.rs +++ b/bash-5.1/builtins_rust/rlet/src/lib.rs @@ -6,7 +6,6 @@ include!(concat!("intercdep.rs")); #[no_mangle] pub extern "C" fn r_let_builtin(mut list: *mut WordList) -> i32 { - println!("r_let_builtin call"); unsafe { let mut ret: c_long = 0; let mut expok: c_int = 0; @@ -40,7 +39,6 @@ unsafe { #[no_mangle] pub extern "C" fn r_exp_builtin(mut list: *mut WordList) -> i32 { - println!("r_exp_builtin call"); unsafe { let mut expok: c_int = 0; @@ -61,4 +59,4 @@ unsafe fn is_option(s: *mut c_char, c: u8) -> bool { let str = CStr::from_ptr(s).to_bytes_with_nul(); return str[0] == b'-' && str[1] == c && str[2] != 0 -} \ No newline at end of file +} diff --git a/bash-5.1/builtins_rust/rreturn/src/lib.rs b/bash-5.1/builtins_rust/rreturn/src/lib.rs index a08a40d2..f05ecc58 100644 --- a/bash-5.1/builtins_rust/rreturn/src/lib.rs +++ b/bash-5.1/builtins_rust/rreturn/src/lib.rs @@ -4,7 +4,6 @@ include!(concat!("intercdep.rs")); #[no_mangle] pub extern "C" fn r_return_builtin(list: *mut WordList) -> i32 { - println!("r_return_builtin call"); unsafe { if !list.is_null() && !(*list).word.is_null() && diff --git a/bash-5.1/builtins_rust/set/src/lib.rs b/bash-5.1/builtins_rust/set/src/lib.rs index 8caab34f..c7bf273a 100644 --- a/bash-5.1/builtins_rust/set/src/lib.rs +++ b/bash-5.1/builtins_rust/set/src/lib.rs @@ -868,7 +868,7 @@ extern "C" { static mut interactive_shell : i32; static mut history_lines_this_session : i32; static mut rl_editing_mode : i32; - static mut list_optopt :i32; + static mut list_optopt :i8; static mut loptend:*mut WordList; static assoc_expand_once:i32; static mut stdin : libc::FILE; @@ -916,7 +916,6 @@ unsafe fn find_minus_o_option (mut name : *mut libc::c_char) -> i32 { let ooo = o_options[j]; //println! ("i is {}, j is {}",i,j); if STREQ(name, o_options[j as usize].name) { - //println! ("qqqqqqqqqqqq"); return i; } } @@ -1426,7 +1425,7 @@ unsafe fn reset_shell_options () { unsafe { builtin_usage (); } - if unsafe {list_optopt} == b'?' as libc::c_char as i32 { + if unsafe {list_optopt} == b'?' as libc::c_char as i8 { return EXECUTION_SUCCESS!(); } else { @@ -1440,10 +1439,10 @@ unsafe fn reset_shell_options () { } return EX_USAGE; } - unsafe { - builtin_usage (); - } - return EX_USAGE; + // unsafe { + // builtin_usage (); + // } + // return EX_USAGE; } } // opt = unsafe {internal_getopt(list, optflags.as_ptr() as *mut libc::c_char)}; @@ -1637,7 +1636,7 @@ pub extern "C" fn r_unset_builtin(mut list: *mut WordList) -> i32 { 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"); + //println!("enter r_unset by huanhuan"); let mut c_str_fnv = CString::new("fnv").unwrap(); unsafe { reset_internal_getopt(); diff --git a/bash-5.1/builtins_rust/setattr/src/lib.rs b/bash-5.1/builtins_rust/setattr/src/lib.rs index 3fa36f73..e8a9cce8 100644 --- a/bash-5.1/builtins_rust/setattr/src/lib.rs +++ b/bash-5.1/builtins_rust/setattr/src/lib.rs @@ -6,13 +6,11 @@ include!(concat!("intercdep.rs")); #[no_mangle] pub extern "C" fn r_export_builtin(list: *mut WordList) -> c_int { - println!("r_export_builtin call"); return set_or_show_attributes(list, att_exported, 0); } #[no_mangle] pub extern "C" fn r_readonly_builtin(list: *mut WordList) -> c_int { - println!("r_readonly_builtin call"); return set_or_show_attributes(list, att_readonly, 0); } @@ -539,4 +537,4 @@ unsafe { unsafe fn cmp_two(a: usize, b: usize) -> bool { return a == b; -} \ No newline at end of file +} diff --git a/bash-5.1/builtins_rust/shift/src/lib.rs b/bash-5.1/builtins_rust/shift/src/lib.rs index ae2d00a0..47e92555 100644 --- a/bash-5.1/builtins_rust/shift/src/lib.rs +++ b/bash-5.1/builtins_rust/shift/src/lib.rs @@ -7,7 +7,6 @@ pub static print_shift_error: c_int = 0; #[no_mangle] pub extern "C" fn r_shift_builtin(list: *mut WordList) -> i32 { - println!("r_shift_builtin call"); unsafe { if !list.is_null() && !(*list).word.is_null() && diff --git a/bash-5.1/builtins_rust/shopt/src/lib.rs b/bash-5.1/builtins_rust/shopt/src/lib.rs index 2f4ed512..5bf35b1e 100644 --- a/bash-5.1/builtins_rust/shopt/src/lib.rs +++ b/bash-5.1/builtins_rust/shopt/src/lib.rs @@ -992,7 +992,7 @@ pub unsafe extern "C" fn r_shopt_builtin(mut list: *mut WordList) -> i32 { flags & QFLAG, ); } else if flags & (SFLAG | UFLAG) == 0 { // shopt [args] - println!("shopt ===list all "); + //println!("shopt ===list all "); rval = r_list_shopts(list, flags); } else { // shopt -su rval = list_some_shopts( @@ -1082,7 +1082,7 @@ unsafe extern "C" fn toggle_shopts( list: *mut WordList, _quiet: i32, ) -> i32 { - printf(CString::new(" set command: %s mode=%d").expect("").as_ptr() ,(*(*list).word).word, mode); + //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; diff --git a/bash-5.1/builtins_rust/source/src/lib.rs b/bash-5.1/builtins_rust/source/src/lib.rs index 7ce136b0..76371ffd 100644 --- a/bash-5.1/builtins_rust/source/src/lib.rs +++ b/bash-5.1/builtins_rust/source/src/lib.rs @@ -23,14 +23,6 @@ enum r_instruction { r_move_input, r_move_output, r_move_input_word, r_move_output_word, r_append_err_and_out } -/* -#[repr(C)] -#[derive(Copy,Clone)] -pub union REDIRECTEE { - dest:libc::c_int, - filename:* mut WordDesc -} -*/ #[repr(C)] pub union REDIRECT { diff --git a/bash-5.1/builtins_rust/suspend/src/lib.rs b/bash-5.1/builtins_rust/suspend/src/lib.rs index bce08787..574c8b4d 100644 --- a/bash-5.1/builtins_rust/suspend/src/lib.rs +++ b/bash-5.1/builtins_rust/suspend/src/lib.rs @@ -7,7 +7,6 @@ pub static mut old_cont: *mut SigHandler = PT_NULL as *mut SigHandler; #[no_mangle] pub extern "C" fn r_suspend_builtin(mut list: *mut WordList) -> i32 { - println!("r_suspend_builtin call"); let mut opt: c_int; let mut force: c_int = 0; @@ -54,4 +53,4 @@ unsafe { unsafe fn suspend_continue(sig: c_int) { set_signal_handler(libc::SIGCONT, old_cont); -} \ No newline at end of file +} diff --git a/bash-5.1/builtins_rust/test/src/lib.rs b/bash-5.1/builtins_rust/test/src/lib.rs index 2f622d2f..0112ec18 100644 --- a/bash-5.1/builtins_rust/test/src/lib.rs +++ b/bash-5.1/builtins_rust/test/src/lib.rs @@ -4,7 +4,6 @@ include!(concat!("intercdep.rs")); #[no_mangle] pub extern "C" fn r_test_builtin(list: *mut WordList) -> i32 { - println!("r_test_builtin call"); let result: c_int; let mut argc: c_int = 0; diff --git a/bash-5.1/builtins_rust/times/src/lib.rs b/bash-5.1/builtins_rust/times/src/lib.rs index 0e2323d7..c5da3126 100644 --- a/bash-5.1/builtins_rust/times/src/lib.rs +++ b/bash-5.1/builtins_rust/times/src/lib.rs @@ -4,7 +4,6 @@ include!(concat!("intercdep.rs")); #[no_mangle] pub extern "C" fn r_times_builtin(list: *mut WordList) -> i32 { - println!("r_times_builtin call"); unsafe { diff --git a/bash-5.1/builtins_rust/trap/src/lib.rs b/bash-5.1/builtins_rust/trap/src/lib.rs index f5dddb3b..cdc9a5fb 100644 --- a/bash-5.1/builtins_rust/trap/src/lib.rs +++ b/bash-5.1/builtins_rust/trap/src/lib.rs @@ -8,7 +8,6 @@ include!(concat!("intercdep.rs")); #[no_mangle] pub extern "C" fn r_trap_builtin(mut list: *mut WordList) -> i32 { - println!("r_trap_builtin call"); let mut list_signal_names: c_int = 0; let mut display: c_int = 0; diff --git a/bash-5.1/builtins_rust/umask/Cargo.toml b/bash-5.1/builtins_rust/umask/Cargo.toml index 3ec52c40..882c0d87 100644 --- a/bash-5.1/builtins_rust/umask/Cargo.toml +++ b/bash-5.1/builtins_rust/umask/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libc = "0.2" +libc = "*" rcommon = {path = "../common"} diff --git a/bash-5.1/builtins_rust/umask/src/lib.rs b/bash-5.1/builtins_rust/umask/src/lib.rs index e45a50f7..399070d0 100644 --- a/bash-5.1/builtins_rust/umask/src/lib.rs +++ b/bash-5.1/builtins_rust/umask/src/lib.rs @@ -143,14 +143,6 @@ macro_rules! S_IXUGO { }; } -// #[macro_export] -// macro_rules! DIGIT{ -// ($c:expr) => { -// c >= '0' && c <= '9' -// } -// } - -// //C库 extern "C" { @@ -194,7 +186,6 @@ unsafe fn member(c:*mut c_char,s:*mut c_char) -> bool{ of -S means display the umask in a symbolic mode. */ pub extern "C" fn r_umask_builtin(mut list:*mut WordList) ->i32{ - println!("r_umask_builtin"); let mut print_symbolically:i32; let mut opt:i32; let umask_value:i32; diff --git a/bash-5.1/configure b/bash-5.1/configure index fd4e2113..60033ad7 100755 --- a/bash-5.1/configure +++ b/bash-5.1/configure @@ -637,7 +637,6 @@ DEBUG RELSTATUS BASHVERS headersdir -loadablesdir BUILD_DIR incdir PROFILE_FLAGS @@ -793,6 +792,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -925,6 +925,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1177,6 +1178,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1314,7 +1324,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1467,6 +1477,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -4778,7 +4789,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4824,7 +4835,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4848,7 +4859,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4893,7 +4904,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4917,7 +4928,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -7828,6 +7839,8 @@ main () if (*(data + i) != *(data3 + i)) return 14; close (fd); + free (data); + free (data3); return 0; } _ACEOF @@ -15088,6 +15101,8 @@ main () if (*(data + i) != *(data3 + i)) return 14; close (fd); + free (data); + free (data3); return 0; } _ACEOF @@ -20474,8 +20489,8 @@ CFLAGS="$CFLAGS ${STYLE_CFLAGS}" # if test "$ac_cv_func_dlopen" = "yes" && test -f ${srcdir}/support/shobj-conf then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking shared object configuration for loadable builtins" >&5 -$as_echo_n "checking shared object configuration for loadable builtins... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking shared object configuration for builtins" >&5 +$as_echo_n "checking shared object configuration for builtins... " >&6; } eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c "${host_cpu}" -o "${host_os}" -v "${host_vendor}"` @@ -20501,8 +20516,6 @@ case "$srcdir" in for ld in readline glob tilde malloc sh termcap; do # libdirs test -d lib/$ld || mkdir lib/$ld done - test -d examples/loadables || mkdir examples/loadables # loadable builtins - test -d examples/loadables/perl || mkdir examples/loadables/perl ;; esac @@ -20528,11 +20541,6 @@ fi -# directory where we install dynamically loadable builtins -if test -z "$loadablesdir"; then - loadablesdir='${libdir}/bash' -fi - if test -z "$headersdir"; then headersdir='$(includedir)/$(PACKAGE_NAME)' fi @@ -20559,7 +20567,7 @@ fi #AC_SUBST(ALLOCA_SOURCE) #AC_SUBST(ALLOCA_OBJECT) -ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/Makefile.inc examples/loadables/perl/Makefile support/rash.pc support/rashbug.sh" +ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile support/Makefile po/Makefile.in support/rash.pc support/rashbug.sh" ac_config_commands="$ac_config_commands default" @@ -21280,12 +21288,8 @@ do "lib/sh/Makefile") CONFIG_FILES="$CONFIG_FILES lib/sh/Makefile" ;; "lib/termcap/Makefile") CONFIG_FILES="$CONFIG_FILES lib/termcap/Makefile" ;; "lib/tilde/Makefile") CONFIG_FILES="$CONFIG_FILES lib/tilde/Makefile" ;; - "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "support/Makefile") CONFIG_FILES="$CONFIG_FILES support/Makefile" ;; "po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; - "examples/loadables/Makefile") CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile" ;; - "examples/loadables/Makefile.inc") CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile.inc" ;; - "examples/loadables/perl/Makefile") CONFIG_FILES="$CONFIG_FILES examples/loadables/perl/Makefile" ;; "support/rash.pc") CONFIG_FILES="$CONFIG_FILES support/rash.pc" ;; "support/rashbug.sh") CONFIG_FILES="$CONFIG_FILES support/rashbug.sh" ;; "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; diff --git a/bash-5.1/configure.ac b/bash-5.1/configure.ac index 2d2a0590..dc6dd53e 100644 --- a/bash-5.1/configure.ac +++ b/bash-5.1/configure.ac @@ -1216,7 +1216,7 @@ CFLAGS="$CFLAGS ${STYLE_CFLAGS}" # if test "$ac_cv_func_dlopen" = "yes" && test -f ${srcdir}/support/shobj-conf then - AC_MSG_CHECKING(shared object configuration for loadable builtins) + AC_MSG_CHECKING(shared object configuration for builtins) eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c "${host_cpu}" -o "${host_os}" -v "${host_vendor}"` AC_SUBST(SHOBJ_CC) AC_SUBST(SHOBJ_CFLAGS) @@ -1241,8 +1241,6 @@ case "$srcdir" in for ld in readline glob tilde malloc sh termcap; do # libdirs test -d lib/$ld || mkdir lib/$ld done - test -d examples/loadables || mkdir examples/loadables # loadable builtins - test -d examples/loadables/perl || mkdir examples/loadables/perl ;; esac @@ -1268,11 +1266,6 @@ AC_SUBST(BUILD_DIR) AC_SUBST(datarootdir) AC_SUBST(localedir) -# directory where we install dynamically loadable builtins -if test -z "$loadablesdir"; then - loadablesdir='${libdir}/bash' -fi -AC_SUBST(loadablesdir) if test -z "$headersdir"; then headersdir='$(includedir)/$(PACKAGE_NAME)' fi @@ -1302,10 +1295,8 @@ AC_SUBST(LOCAL_DEFS) AC_OUTPUT([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \ lib/intl/Makefile \ lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \ - lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in \ - examples/loadables/Makefile examples/loadables/Makefile.inc \ - examples/loadables/perl/Makefile \ - support/bash.pc support/rashbug.sh], + lib/tilde/Makefile support/Makefile po/Makefile.in \ + support/rash.pc support/rashbug.sh], [ # Makefile uses this timestamp file to record whether config.h is up to date. echo timestamp > stamp-h diff --git a/bash-5.1/execute_cmd.c b/bash-5.1/execute_cmd.c index 8fae15e6..4325518d 100644 --- a/bash-5.1/execute_cmd.c +++ b/bash-5.1/execute_cmd.c @@ -5500,7 +5500,7 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out, if (command) { - printf("command is %s ========== ======= \n",command); + //printf("command is %s ========== ======= \n",command); /* If we're optimizing out the fork (implicit `exec'), decrement the shell level like `exec' would do. */ #if 0 /* TAG: bash-5.2 psmith 10/11/2020 */ @@ -5814,7 +5814,7 @@ shell_execve (command, args, env) char *command; char **args, **env; { - printf("wwwwwwwwwwwwwwwwwwwwwwwwww===========\n"); + //printf("wwwwwwwwwwwwwwwwwwwwwwwwww===========\n"); int larray, i, fd; char sample[HASH_BANG_BUFSIZ]; int sample_len; diff --git a/bash-5.1/support/rash.pc b/bash-5.1/support/rash.pc index 43e72d15..480ecd95 100644 --- a/bash-5.1/support/rash.pc +++ b/bash-5.1/support/rash.pc @@ -5,7 +5,7 @@ exec_prefix=${prefix} includedir=${prefix}/include libdir=${exec_prefix}/lib -loadablesdir=${libdir}/bash +loadablesdir=@loadablesdir@ headersdir=${includedir}/rash LOCAL_CFLAGS = diff --git a/record.txt b/record.txt index e0498025..a20a15e7 100644 --- a/record.txt +++ b/record.txt @@ -47,3 +47,4 @@ 69 70 71 +72 -- Gitee