From b398f33c49d2fbc2e9e8b39ade644c718b8630db Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Tue, 1 Mar 2022 21:10:38 +0100 Subject: [PATCH] Another round of accumulated minor fixes and cleanups Only notable changes listed below. **/Mamfile: - Do not bother redirecting standard error for 'cmp -s' to /dev/null. Normally, 'cmp -s' on Linux, macOS, *BSD, or Solaris do not not print any message. If it does, something unusual is going on and I would want to see the message. - Since we now require a POSIX shell, we can use '!'. src/cmd/ksh93/include/defs.h, src/cmd/ksh93/sh/init.c: - Remove SH_TYPE_PROFILE symbol, unused after the removal of the SHOPT_PFSH code. (re: eabd6453) src/cmd/ksh93/sh/io.c: - piperead(), slowread(): Replace redundant sffileno() calls by the variables already containing their results. (re: 50d342e4) src/cmd/ksh93/bltins/mkservice.c, rc/lib/libcmd/vmstate.c: - If these aren't compiled, define a stub function to silence the ranlib(1) warning that the .o file does not contain symbols. --- src/cmd/ksh93/Mamfile | 15 +- src/cmd/ksh93/bltins/hist.c | 1 - src/cmd/ksh93/bltins/mkservice.c | 4 +- src/cmd/ksh93/bltins/print.c | 3 - src/cmd/ksh93/bltins/read.c | 1 - src/cmd/ksh93/bltins/regress.c | 6 - src/cmd/ksh93/bltins/test.c | 5 - src/cmd/ksh93/bltins/trap.c | 1 - src/cmd/ksh93/bltins/typeset.c | 5 - src/cmd/ksh93/data/builtins.c | 2 +- src/cmd/ksh93/edit/history.c | 15 +- src/cmd/ksh93/include/defs.h | 1 - src/cmd/ksh93/sh.1 | 2 +- src/cmd/ksh93/sh/arith.c | 2 - src/cmd/ksh93/sh/expand.c | 1 - src/cmd/ksh93/sh/fault.c | 2 - src/cmd/ksh93/sh/init.c | 6 +- src/cmd/ksh93/sh/io.c | 11 +- src/cmd/ksh93/sh/jobs.c | 16 - src/cmd/ksh93/sh/lex.c | 2 - src/cmd/ksh93/sh/main.c | 2 - src/cmd/ksh93/sh/name.c | 2 - src/cmd/ksh93/sh/parse.c | 6 - src/cmd/ksh93/sh/path.c | 10 +- src/cmd/ksh93/sh/streval.c | 2 - src/cmd/ksh93/sh/string.c | 3 - src/cmd/ksh93/sh/subshell.c | 1 - src/cmd/ksh93/sh/suid_exec.c | 6 - src/cmd/ksh93/sh/waitevent.c | 2 - src/cmd/ksh93/sh/xec.c | 2 - src/cmd/ksh93/tests/attributes.sh | 24 +- src/cmd/ksh93/tests/builtins.sh | 61 ++- src/cmd/ksh93/tests/comvar.sh | 3 +- src/cmd/ksh93/tests/comvario.sh | 5 +- src/cmd/ksh93/tests/io.sh | 1 + src/lib/libast/Mamfile | 605 ++++++++++++----------------- src/lib/libast/disc/sfdcfilter.c | 2 +- src/lib/libast/disc/sfdcseekable.c | 2 +- src/lib/libcmd/Mamfile | 19 +- src/lib/libcmd/vmstate.c | 4 +- src/lib/libdll/Mamfile | 7 +- src/lib/libsum/Mamfile | 5 +- 42 files changed, 352 insertions(+), 523 deletions(-) diff --git a/src/cmd/ksh93/Mamfile b/src/cmd/ksh93/Mamfile index f92531274..3936ff926 100644 --- a/src/cmd/ksh93/Mamfile +++ b/src/cmd/ksh93/Mamfile @@ -1501,23 +1501,20 @@ make install make ${PACKAGE_ast_INCLUDE}/nval.h prev ${PACKAGE_ast_INCLUDE} prev include/nval.h - exec - if cmp 2>/dev/null -s include/nval.h ${PACKAGE_ast_INCLUDE}/nval.h - exec - then : - exec - else ${STDCP} include/nval.h ${PACKAGE_ast_INCLUDE}/nval.h + exec - if ! cmp -s include/nval.h ${PACKAGE_ast_INCLUDE}/nval.h + exec - then ${STDCP} include/nval.h ${PACKAGE_ast_INCLUDE}/nval.h exec - fi done ${PACKAGE_ast_INCLUDE}/nval.h generated make ${PACKAGE_ast_INCLUDE}/shell.h prev include/shell.h - exec - if cmp 2>/dev/null -s include/shell.h ${PACKAGE_ast_INCLUDE}/shell.h - exec - then : - exec - else ${STDCP} include/shell.h ${PACKAGE_ast_INCLUDE}/shell.h + exec - if ! cmp -s include/shell.h ${PACKAGE_ast_INCLUDE}/shell.h + exec - then ${STDCP} include/shell.h ${PACKAGE_ast_INCLUDE}/shell.h exec - fi done ${PACKAGE_ast_INCLUDE}/shell.h generated make ${PACKAGE_ast_INCLUDE}/history.h prev include/history.h - exec - if cmp 2>/dev/null -s include/history.h ${PACKAGE_ast_INCLUDE}/history.h - exec - then : - exec - else ${STDCP} include/history.h ${PACKAGE_ast_INCLUDE}/history.h + exec - if ! cmp -s include/history.h ${PACKAGE_ast_INCLUDE}/history.h + exec - then ${STDCP} include/history.h ${PACKAGE_ast_INCLUDE}/history.h exec - fi done ${PACKAGE_ast_INCLUDE}/history.h generated make ${INSTALLROOT}/bin/suid_exec diff --git a/src/cmd/ksh93/bltins/hist.c b/src/cmd/ksh93/bltins/hist.c index 562828f7b..fb290a29c 100644 --- a/src/cmd/ksh93/bltins/hist.c +++ b/src/cmd/ksh93/bltins/hist.c @@ -297,7 +297,6 @@ int b_hist(int argc,char *argv[], Shbltin_t *context) * given a file containing a command and a string of the form old=new, * execute the command with the string old replaced by new */ - static void hist_subst(const char *command,int fd,char *replace) { register char *newp=replace; diff --git a/src/cmd/ksh93/bltins/mkservice.c b/src/cmd/ksh93/bltins/mkservice.c index 551bb6d8e..9bce66840 100644 --- a/src/cmd/ksh93/bltins/mkservice.c +++ b/src/cmd/ksh93/bltins/mkservice.c @@ -25,7 +25,9 @@ * AT&T Labs */ -#if SHOPT_MKSERVICE +#if !SHOPT_MKSERVICE +void _STUB_b_mkservice(){} +#else static const char mkservice_usage[] = "[-?\n@(#)$Id: mkservice (AT&T Research) 2001-06-13 $\n]" diff --git a/src/cmd/ksh93/bltins/print.c b/src/cmd/ksh93/bltins/print.c index 94d0bed1b..f4772f4da 100644 --- a/src/cmd/ksh93/bltins/print.c +++ b/src/cmd/ksh93/bltins/print.c @@ -163,7 +163,6 @@ static int infof(Opt_t* op, Sfio_t* sp, const char* s, Optdisc_t* dp) * argc==0 when called from echo * argc==-1 when called from printf */ - int b_print(int argc, char *argv[], Shbltin_t *context) { register Sfio_t *outfile; @@ -397,7 +396,6 @@ printf_v: * if is non-zero then \ is not a special character. * returns 0 for \c otherwise 1. */ - static int echolist(Sfio_t *outfile, int raw, char *argv[]) { register char *cp; @@ -1054,7 +1052,6 @@ static int extend(Sfio_t* sp, void* v, Sffmt_t* fe) * Otherwise, puts null-terminated result on stack, but doesn't freeze it * returns length of output. */ - static int fmtvecho(const char *string, struct printf *pp) { register const char *cp = string, *cpmax; diff --git a/src/cmd/ksh93/bltins/read.c b/src/cmd/ksh93/bltins/read.c index d029b5adb..745211ca3 100644 --- a/src/cmd/ksh93/bltins/read.c +++ b/src/cmd/ksh93/bltins/read.c @@ -212,7 +212,6 @@ static void timedout(void *handle) * is union of -A, -r, -s, and contains delimiter if not '\n' * is the number of milliseconds until timeout */ - int sh_readline(char **names, volatile int fd, int flags, ssize_t size, long timeout) { register ssize_t c; diff --git a/src/cmd/ksh93/bltins/regress.c b/src/cmd/ksh93/bltins/regress.c index 9f8db6919..83e862c6f 100644 --- a/src/cmd/ksh93/bltins/regress.c +++ b/src/cmd/ksh93/bltins/regress.c @@ -132,7 +132,6 @@ void sh_regress_init(void) /* * regress info trace output */ - void sh_regress(unsigned int index, const char* intercept, const char* info, unsigned int line, const char* file) { char* name; @@ -148,7 +147,6 @@ void sh_regress(unsigned int index, const char* intercept, const char* info, uns /* * EGID intercepts */ - static gid_t intercept_sgid = 0; static gid_t intercept_egid = -1; static gid_t intercept_rgid = -1; @@ -191,7 +189,6 @@ int setgid(gid_t gid) /* * EUID intercepts */ - static uid_t intercept_suid = 0; static uid_t intercept_euid = -1; static uid_t intercept_ruid = -1; @@ -234,7 +231,6 @@ int setuid(uid_t uid) /* * p_suid intercept */ - static uid_t intercept_p_suid = 0x7fffffff; uid_t sh_regress_p_suid(unsigned int line, const char* file) @@ -246,7 +242,6 @@ uid_t sh_regress_p_suid(unsigned int line, const char* file) /* * p_suid intercept */ - static char* intercept_etc = 0; char* sh_regress_etc(const char* path, unsigned int line, const char* file) @@ -258,7 +253,6 @@ char* sh_regress_etc(const char* path, unsigned int line, const char* file) /* * __regress__ builtin */ - int b___regress__(int argc, char** argv, Shbltin_t *context) { int n; diff --git a/src/cmd/ksh93/bltins/test.c b/src/cmd/ksh93/bltins/test.c index a3fd8d26c..a0c071d00 100644 --- a/src/cmd/ksh93/bltins/test.c +++ b/src/cmd/ksh93/bltins/test.c @@ -27,7 +27,6 @@ * */ - #include "defs.h" #include #include @@ -560,7 +559,6 @@ int test_binop(register int op,const char *left,const char *right) /* * returns the modification time of f1 - modification time of f2 */ - static time_t test_time(const char *file1,const char *file2) { Time_t t1, t2; @@ -582,7 +580,6 @@ static time_t test_time(const char *file1,const char *file2) /* * return true if inode of two files are the same */ - int test_inode(const char *file1,const char *file2) { struct stat stat1,stat2; @@ -597,7 +594,6 @@ int test_inode(const char *file1,const char *file2) * This version of access checks against the effective UID/GID * The static buffer statb is shared with test_mode. */ - int sh_access(register const char *name, register int mode) { struct stat statb; @@ -685,7 +681,6 @@ skip: * If is null, then the previous stat buffer is used. * The mode bits are zero if the file doesn't exist. */ - static int test_mode(register const char *file) { struct stat statb; diff --git a/src/cmd/ksh93/bltins/trap.c b/src/cmd/ksh93/bltins/trap.c index dc69eea69..383efc6bd 100644 --- a/src/cmd/ksh93/bltins/trap.c +++ b/src/cmd/ksh93/bltins/trap.c @@ -316,7 +316,6 @@ int b_suspend(int argc,char *argv[],Shbltin_t *context) /* * Given the name or number of a signal return the signal number */ - static int sig_number(const char *string) { const Shtable_t *tp; diff --git a/src/cmd/ksh93/bltins/typeset.c b/src/cmd/ksh93/bltins/typeset.c index 844a3c97e..e11319905 100644 --- a/src/cmd/ksh93/bltins/typeset.c +++ b/src/cmd/ksh93/bltins/typeset.c @@ -1024,7 +1024,6 @@ static int maxlib; * always move to head of search list * return: 0: already loaded 1: first load */ - int sh_addlib(void* dll, char* name, Pathcomp_t* pp) { register int n; @@ -1391,7 +1390,6 @@ static int unall(int argc, char **argv, register Dt_t *troot) sh_subfork(); /* avoid affecting the parent shell's alias table */ nv_delete(np,troot,nofree_attr); } - } else if(troot==sh.alias_tree) r = 1; @@ -1404,7 +1402,6 @@ static int unall(int argc, char **argv, register Dt_t *troot) /* * print out the name and value of a name-value pair */ - static int print_namval(Sfio_t *file,register Namval_t *np,register int flag, struct tdata *tp) { register char *cp; @@ -1549,7 +1546,6 @@ static void print_attribute(register Namval_t *np,void *data) * print the nodes in tree which have attributes set * if