diff --git a/src/cmd/ksh93/TYPES b/src/cmd/ksh93/TYPES index 8a02131fa35e..ac478b1ab1fe 100644 --- a/src/cmd/ksh93/TYPES +++ b/src/cmd/ksh93/TYPES @@ -1,11 +1,10 @@ +### User-defined variable types in ksh93 ### -The ability for users to define types has been added to ksh93t. -Here is a quick summary of how types are defined and used in ksh93t. -This is still a work in progress so some changes and additions -are likely. +The ability for users to define types is available as of ksh version 93t. +Here is an overview of how types are defined and used in ksh93. -A type can be defined either by a shared library or by using the new -typeset -T option to the shell. The method for defining types via +A type can be defined either by a shared library or by using the -T option +option to the shell's typeset command. The method for defining types via a shared library is not described here. However, the source file bltins/enum.c is an example of a builtin that creates enumeration types. diff --git a/src/cmd/ksh93/bltins/cd_pwd.c b/src/cmd/ksh93/bltins/cd_pwd.c index 5cc3d4fc4d0c..eaf49f15e60c 100644 --- a/src/cmd/ksh93/bltins/cd_pwd.c +++ b/src/cmd/ksh93/bltins/cd_pwd.c @@ -221,7 +221,7 @@ int b_cd(int argc, char *argv[],Shbltin_t *context) if(*dp && (*dp!='.'||dp[1]) && strchr(dir,'/')) sfputr(sfstdout,dir,'\n'); nv_putval(opwdnod,oldpwd,NV_RDONLY); - free((void*)sh.pwd); + free(sh.pwd); if(*dir == '/') { size_t len = strlen(dir); diff --git a/src/cmd/ksh93/bltins/misc.c b/src/cmd/ksh93/bltins/misc.c index 7b1ab4fc2c47..cb7e883bf239 100644 --- a/src/cmd/ksh93/bltins/misc.c +++ b/src/cmd/ksh93/bltins/misc.c @@ -148,7 +148,7 @@ int b_exec(int argc,char *argv[], Shbltin_t *context) sh_onstate(SH_EXEC); if(sh.subshell && !sh.subshare) { - struct dolnod *dp = stkalloc(sh.stk, sizeof(struct dolnod) + ARG_SPARE*sizeof(char*) + argc*sizeof(char*));; + struct dolnod *dp = stkalloc(sh.stk, sizeof(struct dolnod) + ARG_SPARE*sizeof(char*) + argc*sizeof(char*)); struct comnod *t = stkalloc(sh.stk,sizeof(struct comnod)); memset(t, 0, sizeof(struct comnod)); dp->dolnum = argc; diff --git a/src/cmd/ksh93/bltins/whence.c b/src/cmd/ksh93/bltins/whence.c index 0d07a566c7b4..a440c44a5ab9 100644 --- a/src/cmd/ksh93/bltins/whence.c +++ b/src/cmd/ksh93/bltins/whence.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * @@ -322,7 +322,7 @@ static int whence(char **argv, int flags) sfputr(sfstdout,is_pathbound_builtin ? "builtin" : "file",'\n'); else sfputr(sfstdout,sh_fmtq(cp),'\n'); - free((char*)cp); + free(cp); } else if(aflag<=1) { diff --git a/src/cmd/ksh93/edit/history.c b/src/cmd/ksh93/edit/history.c index c3e2b8a0aca1..63576020199b 100644 --- a/src/cmd/ksh93/edit/history.c +++ b/src/cmd/ksh93/edit/history.c @@ -378,7 +378,7 @@ void hist_close(History_t *hp) sfclose(hp->auditfp); } #endif /* SHOPT_AUDIT */ - free((char*)hp); + free(hp); hist_ptr = 0; sh.hist_ptr = 0; #if SHOPT_ACCTFILE @@ -480,7 +480,7 @@ static History_t* hist_trim(History_t *hp, int n) } hist_cancel(hist_new); sfclose(hist_old->histfp); - free((char*)hist_old); + free(hist_old); return hist_ptr = hist_new; } diff --git a/src/cmd/ksh93/include/argnod.h b/src/cmd/ksh93/include/argnod.h index c52008e81ccc..dfeda66c2847 100644 --- a/src/cmd/ksh93/include/argnod.h +++ b/src/cmd/ksh93/include/argnod.h @@ -74,7 +74,7 @@ struct dolnod int dolmax; /* size of dolval array */ int dolnum; /* number of elements */ int dolbot; /* current first element */ - struct dolnod *dolnxt; /* used when list are chained */ + struct dolnod *dolnxt; /* used when lists are chained */ char *dolval[1]; /* array of value pointers */ }; diff --git a/src/cmd/ksh93/include/shnodes.h b/src/cmd/ksh93/include/shnodes.h index caace0ecfda3..a2d95679368b 100644 --- a/src/cmd/ksh93/include/shnodes.h +++ b/src/cmd/ksh93/include/shnodes.h @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/cmd/ksh93/sh/array.c b/src/cmd/ksh93/sh/array.c index e7022075e752..5485f2bb06d7 100644 --- a/src/cmd/ksh93/sh/array.c +++ b/src/cmd/ksh93/sh/array.c @@ -783,7 +783,7 @@ static void array_copytree(Namval_t *np, Namval_t *mp) nv_offattr(np,NV_ARRAY); nv_clone(np,mp,0); if(np->nvalue.cp && !nv_isattr(np,NV_NOFREE)) - free((void*)np->nvalue.cp); + free(np->nvalue.cp); np->nvalue.cp = 0; np->nvalue.up = &mp->nvalue; fp->nofree &= ~1; diff --git a/src/cmd/ksh93/sh/fcin.c b/src/cmd/ksh93/sh/fcin.c index f5c6622f82dc..91d0d6092504 100644 --- a/src/cmd/ksh93/sh/fcin.c +++ b/src/cmd/ksh93/sh/fcin.c @@ -55,7 +55,7 @@ int fcfopen(Sfio_t* f) n = sfvalue(f); fcrestore(&save); sfread(f,buff,0); - _Fcin.fcoff = sftell(f);; + _Fcin.fcoff = sftell(f); buff = (char*)sfreserve(f,SFIO_UNBOUND,SFIO_LOCKR); _Fcin.fclast = (_Fcin.fcptr=_Fcin.fcbuff=(unsigned char*)buff)+n; if(sffileno(f) >= 0) diff --git a/src/cmd/ksh93/sh/main.c b/src/cmd/ksh93/sh/main.c index 64aadb4d2a73..4bd97845d295 100644 --- a/src/cmd/ksh93/sh/main.c +++ b/src/cmd/ksh93/sh/main.c @@ -804,7 +804,7 @@ static void fixargs(char **argv, int mode) /* Move the environment to make space for a larger command line buffer */ for(i=0; environ[i]; i++) { - buffsize += strlen(environ[i]) + 1;; + buffsize += strlen(environ[i]) + 1; environ[i] = sh_strdup(environ[i]); } } diff --git a/src/cmd/ksh93/sh/name.c b/src/cmd/ksh93/sh/name.c index 25d383b872f5..df36f4783a91 100644 --- a/src/cmd/ksh93/sh/name.c +++ b/src/cmd/ksh93/sh/name.c @@ -1666,7 +1666,7 @@ void nv_putval(Namval_t *np, const char *string, int flags) if(flags&(NV_NOREF|NV_NOFREE)) { if(np->nvalue.cp && np->nvalue.cp!=sp && !nv_isattr(np,NV_NOFREE)) - free((void*)np->nvalue.cp); + free(np->nvalue.cp); np->nvalue.cp = (char*)sp; nv_setattr(np,(flags&~NV_RDONLY)|NV_NOFREE); return; @@ -1939,7 +1939,7 @@ void nv_putval(Namval_t *np, const char *string, int flags) { if(tofree) { - free((void*)tofree); + free(tofree); nv_offattr(np,NV_NOFREE); } up->cp = sp; @@ -2042,7 +2042,7 @@ void nv_putval(Namval_t *np, const char *string, int flags) if(flags&NV_APPEND) stkseek(sh.stk,offset); if(tofree && tofree!=Empty && tofree!=AltEmpty) - free((void*)tofree); + free(tofree); } if(!was_local && ((flags&NV_EXPORT) || nv_isattr(np,NV_EXPORT))) env_change(); @@ -2484,7 +2484,7 @@ void _nv_unset(Namval_t *np,int flags) if(up && up->cp) { if(up->cp!=Empty && up->cp!=AltEmpty && !nv_isattr(np, NV_NOFREE)) - free((void*)up->cp); + free(up->cp); up->cp = 0; } done: diff --git a/src/cmd/ksh93/sh/nvtype.c b/src/cmd/ksh93/sh/nvtype.c index 10e0799ac317..8b302a406f8d 100644 --- a/src/cmd/ksh93/sh/nvtype.c +++ b/src/cmd/ksh93/sh/nvtype.c @@ -1133,7 +1133,7 @@ Namval_t *nv_mktype(Namval_t **nodes, int numnodes) else if(nv_isattr(np,NV_LJUST|NV_RJUST)) memset((char*)nq->nvalue.cp,' ',dsize); if(!j) - free((void*)np->nvalue.cp); + free(np->nvalue.cp); } if(!nq->nvalue.cp && nq->nvfun== &pp->childfun.fun) { @@ -1327,7 +1327,7 @@ int nv_settype(Namval_t* np, Namval_t *tp, int flags) np->nvalue.up = 0; nv_clone(tp,np,flags|NV_NOFREE); if(np->nvalue.cp && np->nvalue.cp!=Empty && !nv_isattr(np,NV_NOFREE)) - free((void*)np->nvalue.cp); + free(np->nvalue.cp); np->nvalue.up = 0; nofree = ap->hdr.nofree; ap->hdr.nofree = 0; diff --git a/src/cmd/ksh93/sh/path.c b/src/cmd/ksh93/sh/path.c index cda76140379d..10b9700a1d1e 100644 --- a/src/cmd/ksh93/sh/path.c +++ b/src/cmd/ksh93/sh/path.c @@ -212,7 +212,7 @@ char *path_pwd(void) { if(*sh.pwd=='/') return (char*)sh.pwd; - free((void*)sh.pwd); + free(sh.pwd); } /* First see if PWD variable is correct */ pwdnod = sh_scoped(PWDNOD); diff --git a/src/cmd/ksh93/sh/subshell.c b/src/cmd/ksh93/sh/subshell.c index a6223117e603..38268abc5633 100644 --- a/src/cmd/ksh93/sh/subshell.c +++ b/src/cmd/ksh93/sh/subshell.c @@ -364,7 +364,7 @@ static void nv_restore(struct subshell *sp) else mp->nvalue = np->nvalue; if(nofree && np->nvfun && !np->nvfun->nofree) - free((char*)np->nvfun); + free(np->nvfun); np->nvfun = 0; if(nv_isattr(mp,NV_EXPORT)) { @@ -836,7 +836,7 @@ Sfio_t *sh_subshell(Shnode_t *t, volatile int flags, int comsub) else if(sp->pwd && strcmp(sp->pwd,sh.pwd)) path_newdir(sh.pathlist); if(sh.pwd) - free((void*)sh.pwd); + free(sh.pwd); sh.pwd = sp->pwd; #if _lib_fchdir if(sp->pwdclose) @@ -918,7 +918,7 @@ Sfio_t *sh_subshell(Shnode_t *t, volatile int flags, int comsub) case 2: /* reinit PWD as it will be wrong */ if(sh.pwd) - free((void*)sh.pwd); + free(sh.pwd); sh.pwd = NULL; path_pwd(); errno = saveerrno; diff --git a/src/cmd/ksh93/sh/tdump.c b/src/cmd/ksh93/sh/tdump.c index 9b31fb299a18..e36db90340bb 100644 --- a/src/cmd/ksh93/sh/tdump.c +++ b/src/cmd/ksh93/sh/tdump.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1982-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/cmd/ksh93/tests/attributes.sh b/src/cmd/ksh93/tests/attributes.sh index 55083c3eb23d..52ed9f0a31a5 100755 --- a/src/cmd/ksh93/tests/attributes.sh +++ b/src/cmd/ksh93/tests/attributes.sh @@ -2,7 +2,7 @@ # # # This software is part of the ast package # # Copyright (c) 1982-2012 AT&T Intellectual Property # -# Copyright (c) 2020-2023 Contributors to ksh 93u+m # +# Copyright (c) 2020-2024 Contributors to ksh 93u+m # # and is licensed under the # # Eclipse Public License, Version 2.0 # # # diff --git a/src/cmd/ksh93/tests/builtins.sh b/src/cmd/ksh93/tests/builtins.sh index 0615c900e855..cae2a7dc0554 100755 --- a/src/cmd/ksh93/tests/builtins.sh +++ b/src/cmd/ksh93/tests/builtins.sh @@ -1693,7 +1693,7 @@ exp='\\ \\\\' "(expected $(printf %q "$exp"), got $(printf %q "$got"))" # ====== -case $(PATH=/opt/ast/bin:$PATH; exec cat '--???SECTION' 2>&1) in +case $(PATH=/opt/ast/bin:$PATH; exec cat '--???SECTION' &1) in 1) err_exit "'exec' runs non-external command" ;; esac diff --git a/src/lib/libast/cdt/dtlist.c b/src/lib/libast/cdt/dtlist.c index 8438ad145dbb..217054b9ff81 100644 --- a/src/lib/libast/cdt/dtlist.c +++ b/src/lib/libast/cdt/dtlist.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * @@ -170,8 +170,7 @@ static void* dtlist(Dt_t* dt, void* obj, int type) goto do_insert; } else if(type&(DT_INSERT|DT_INSTALL|DT_APPEND|DT_ATTACH)) - { - if(!(r = _dtmake(dt, obj, type)) ) + { if(!(r = _dtmake(dt, obj, type)) ) DTRETURN(obj, NULL); dt->data->size += 1; diff --git a/src/lib/libast/cdt/dttree.c b/src/lib/libast/cdt/dttree.c index 4767157524d1..92f82f7307b5 100644 --- a/src/lib/libast/cdt/dttree.c +++ b/src/lib/libast/cdt/dttree.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * @@ -638,10 +638,6 @@ static Dtmethod_t _Dtobag = { dttree, DT_OBAG, treeevent, "Dtobag" }; Dtmethod_t *Dtoset = &_Dtoset; Dtmethod_t *Dtobag = &_Dtobag; -/* backward compatibility */ -#undef Dttree -Dtmethod_t *Dttree = &_Dtoset; - #ifdef NoF NoF(dttree) #endif diff --git a/src/lib/libast/features/lib b/src/lib/libast/features/lib index ef4ca3f9600f..cc774f61a13d 100644 --- a/src/lib/libast/features/lib +++ b/src/lib/libast/features/lib @@ -23,7 +23,7 @@ dat _tzname,tzname lib BSDsetpgrp lib _cleanup -lib bcopy,bzero,catclose,catgets,catopen,confstr,dirread,dup2 +lib bcopy,bzero,confstr,dirread,dup2 lib execlp,execve,execvp,execvpe lib fchmod,fcntl,fmtmsg,fnmatch,fork,fsync lib getconf,getdents,getdirentries,getdtablesize,getdate diff --git a/src/lib/libast/features/nl_types b/src/lib/libast/features/nl_types index 4957294504e0..ca18cb9d4f58 100644 --- a/src/lib/libast/features/nl_types +++ b/src/lib/libast/features/nl_types @@ -57,4 +57,7 @@ tst output{ printf("\n"); return 0; } +}end fail{ + echo "$0: Output block failed to compile. Export IFFEFLAGS=-d1 to debug." >&2 + exit 1 }end diff --git a/src/lib/libast/hash/hashlook.c b/src/lib/libast/hash/hashlook.c index 6ed4abbcb726..4717bf4f2743 100644 --- a/src/lib/libast/hash/hashlook.c +++ b/src/lib/libast/hash/hashlook.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * @@ -191,7 +191,7 @@ hashlook(Hash_table_t* tab, const char* name, long flags, const char* value) if (name) { if (tab->root->local->region) (*tab->root->local->region)(tab->root->local->handle, (char*)name, 0, 0); - else free((char*)name); + else free(name); } } } @@ -233,7 +233,7 @@ hashlook(Hash_table_t* tab, const char* name, long flags, const char* value) { b->hash &= ~HASH_FREENAME; if (tab->root->local->region) (*tab->root->local->region)(tab->root->local->handle, (char*)name, 0, 0); - else free((char*)name); + else free(name); } tab->buckets--; tab->table[n] = b->next; diff --git a/src/lib/libast/regex/regclass.c b/src/lib/libast/regex/regclass.c index 30528a0fb896..b56b74a483d7 100644 --- a/src/lib/libast/regex/regclass.c +++ b/src/lib/libast/regex/regclass.c @@ -228,7 +228,7 @@ regclass(const char* s, char** e) cp->size = 0; if (!streq(cp->name, s)) { - free((char*)cp->name); + free(cp->name); cp->name = 0; } } @@ -241,7 +241,7 @@ regclass(const char* s, char** e) /* mvs.390 needs the (char*) cast -- barf */ if (!(cp->wtype = wctype((char*)cp->name))) { - free((char*)cp->name); + free(cp->name); cp->name = 0; return NULL; } diff --git a/src/lib/libast/sfio/sfmode.c b/src/lib/libast/sfio/sfmode.c index 28624f13279b..058f764fdf48 100644 --- a/src/lib/libast/sfio/sfmode.c +++ b/src/lib/libast/sfio/sfmode.c @@ -255,7 +255,7 @@ static int _sfpmode(Sfio_t* f, int type) p->ndata = f->endb-f->next; if(p->ndata > p->size) { if(p->rdata) - free((char*)p->rdata); + free(p->rdata); if((p->rdata = (uchar*)malloc(p->ndata)) ) p->size = p->ndata; else