Skip to content

Commit

Permalink
Yet another round of maintenance and minor cleanups
Browse files Browse the repository at this point in the history
Notable changes:

bin/package, src/cmd/INIT/package.sh:
- Use POSIX 'hash -r' instead of a dummy assignment to PATH to
  empty the command lookup hash table. (re: 20f8557)
- Since we will not restore nmake and mamake is working fine for
  us, eliminate the redundant "make with mamake" announcement.

src/cmd/ksh93/sh/xec.c:
- De-obfuscate ARG_OPTIMIZE flag use. (re: 9ad96a4)

src/lib/libast/features/sys:
- Since we always use our own AST spawnveg(3) and not any
  non-existent native OS implementation thereof, emit the
  prototype directly instead of probing for the need for it.

src/cmd/ksh93/tests/{comvario,enum}.sh:
- Move a backported enum test to enum.sh. (re: cfc8744)
  • Loading branch information
McDutchie committed Jan 22, 2024
1 parent 370fd17 commit 08714c3
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 75 deletions.
9 changes: 3 additions & 6 deletions bin/package
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ command=${0##*/}
case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in
0123) USAGE=$'
[-?
@(#)$Id: '$command$' (ksh 93u+m) 2024-01-14 $
@(#)$Id: '$command$' (ksh 93u+m) 2024-01-22 $
]
[-author?Glenn Fowler <[email protected]>]
[-author?Contributors to https://github.com/ksh93/ksh]
Expand Down Expand Up @@ -543,7 +543,7 @@ SEE ALSO
pkgadd(1), pkgmk(1), rpm(1), sh(1), tar(1), optget(3)

IMPLEMENTATION
version package (ksh 93u+m) 2024-01-14
version package (ksh 93u+m) 2024-01-22
author Glenn Fowler <[email protected]>
author Contributors to https://github.com/ksh93/ksh
copyright (c) 1994-2012 AT&T Intellectual Property
Expand Down Expand Up @@ -2375,9 +2375,7 @@ checkaout() # cmd ...
fi
$exec $CC $CCFLAGS -o $INSTALLROOT/bin/$i $INITROOT/$i.c || return
test -f $i.o && $exec rm -f $i.o
i=$PATH
PATH=/bin
PATH=$i
hash -r
;;
esac
done
Expand Down Expand Up @@ -3086,7 +3084,6 @@ make|view)

# build with mamake

note "make with mamake"
case $target in
'') target="install" ;;
esac
Expand Down
1 change: 0 additions & 1 deletion src/cmd/INIT/mkreq-maplib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ do # for each lib name also add '-'
done

# Setup.
set -o noglob
trap 'set +o noglob; rm -rf "$req".exe*' 0

######### Main ##########
Expand Down
9 changes: 3 additions & 6 deletions src/cmd/INIT/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ command=${0##*/}
case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in
0123) USAGE=$'
[-?
@(#)$Id: '$command$' (ksh 93u+m) 2024-01-14 $
@(#)$Id: '$command$' (ksh 93u+m) 2024-01-22 $
]
[-author?Glenn Fowler <[email protected]>]
[-author?Contributors to https://github.com/ksh93/ksh]
Expand Down Expand Up @@ -543,7 +543,7 @@ SEE ALSO
pkgadd(1), pkgmk(1), rpm(1), sh(1), tar(1), optget(3)
IMPLEMENTATION
version package (ksh 93u+m) 2024-01-14
version package (ksh 93u+m) 2024-01-22
author Glenn Fowler <[email protected]>
author Contributors to https://github.com/ksh93/ksh
copyright (c) 1994-2012 AT&T Intellectual Property
Expand Down Expand Up @@ -2375,9 +2375,7 @@ checkaout() # cmd ...
fi
$exec $CC $CCFLAGS -o $INSTALLROOT/bin/$i $INITROOT/$i.c || return
test -f $i.o && $exec rm -f $i.o
i=$PATH
PATH=/bin
PATH=$i
hash -r
;;
esac
done
Expand Down Expand Up @@ -3086,7 +3084,6 @@ make|view)

# build with mamake

note "make with mamake"
case $target in
'') target="install" ;;
esac
Expand Down
17 changes: 12 additions & 5 deletions src/cmd/INIT/proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,23 @@
# compiling older AST code (with Mamfiles containing proto commands) using the
# current INIT system. This stub ignores all options, then invokes 'cat'.

usage()
{
echo 'Usage: proto [-dfhinprstvzP+S] [-C directory] [-e package] [-l file]'
echo ' [-o "name='\''value'\'' ..."] [-L file] file ...'
exit 2
} >&2

while getopts ':dfhinprstvzPSC:e:l:o:L:' opt
do case $opt in
:) usage
;;
\?) case $OPTARG in
+) ;;
*) echo "proto: $OPTARG: unknown option"
echo 'Usage: proto [-dfhinprstvzP+S] [-C directory] [-e package] [-l file]'
echo ' [-o "name='\''value'\'' ..."] [-L file] file ...'
exit 2
*) echo "proto: $OPTARG: unknown option" >&2
usage
;;
esac >&2
esac
;;
esac
done
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/bltins/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
* *
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/data/variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
* *
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/edit/emacs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
* *
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/include/argnod.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
* *
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/include/lexstates.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
* *
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/include/name.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
* *
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/include/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
* *
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
* *
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/sh/nvdisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
* *
Expand Down
50 changes: 22 additions & 28 deletions src/cmd/ksh93/sh/xec.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,12 +455,6 @@ static int p_switch(struct regnod *reg)
}
return n;
}
# define OPTIMIZE_FLAG (ARG_OPTIMIZE)
# define OPTIMIZE (flags&OPTIMIZE_FLAG)
#else
# define OPTIMIZE_FLAG (0)
# define OPTIMIZE (0)
# define sh_tclear(x)
#endif /* SHOPT_OPTIMIZE */

static void out_pattern(Sfio_t *iop, const char *cp, int n)
Expand Down Expand Up @@ -875,7 +869,7 @@ int sh_exec(const Shnode_t *t, int flags)
{
int type = t->tre.tretyp;
char *com0 = 0;
int errorflg = (flags&sh_state(SH_ERREXIT))|OPTIMIZE;
int errorflg = (flags&sh_state(SH_ERREXIT))|(flags & ARG_OPTIMIZE);
int execflg = (flags&sh_state(SH_NOFORK));
int execflg2 = (flags&sh_state(SH_FORKED));
int mainloop = (flags&sh_state(SH_INTERACTIVE));
Expand Down Expand Up @@ -922,7 +916,7 @@ int sh_exec(const Shnode_t *t, int flags)
type &= (COMMSK|COMSCAN);
sh_stats(STAT_SCMDS);
error_info.line = t->com.comline-sh.st.firstline;
com = sh_argbuild(&argn,&(t->com),OPTIMIZE);
com = sh_argbuild(&argn,&(t->com),flags & ARG_OPTIMIZE);
echeck = 1;
if(t->tre.tretyp&COMSCAN)
{
Expand Down Expand Up @@ -1231,7 +1225,7 @@ int sh_exec(const Shnode_t *t, int flags)
bp->data = t->com.comstate;
bp->sigset = 0;
bp->notify = 0;
bp->flags = (OPTIMIZE!=0);
bp->flags = ((flags & ARG_OPTIMIZE)!=0);
if(sh.subshell && nv_isattr(np,BLT_NOSFIO))
sh_subtmpfile();
if(argn)
Expand Down Expand Up @@ -1394,7 +1388,7 @@ int sh_exec(const Shnode_t *t, int flags)
}
namespace = enter_namespace(namespace);
#endif /* SHOPT_NAMESPACE */
sh_funct(np,argn,com,t->com.comset,(flags&~OPTIMIZE_FLAG));
sh_funct(np,argn,com,t->com.comset,(flags&~ARG_OPTIMIZE));
}
#if SHOPT_NAMESPACE
enter_namespace(namespace);
Expand Down Expand Up @@ -1763,7 +1757,7 @@ int sh_exec(const Shnode_t *t, int flags)
*/
case TPAR:
echeck = 1;
flags &= ~OPTIMIZE_FLAG;
flags &= ~ARG_OPTIMIZE;
if(!sh.subshell && !sh.st.trapdontexec && (flags&sh_state(SH_NOFORK)))
{
/* This is the last command, so avoid creating a subshell */
Expand Down Expand Up @@ -1915,7 +1909,7 @@ int sh_exec(const Shnode_t *t, int flags)
{
do
{
sh_exec(t->lst.lstlef,errorflg|OPTIMIZE);
sh_exec(t->lst.lstlef,errorflg|(flags & ARG_OPTIMIZE));
t = t->lst.lstrit;
}
while(t->tre.tretyp == TLST);
Expand All @@ -1929,7 +1923,7 @@ int sh_exec(const Shnode_t *t, int flags)
case TAND:
if(type&TTEST)
skipexitset++;
if(sh_exec(t->lst.lstlef,OPTIMIZE)==0)
if(sh_exec(t->lst.lstlef, flags & ARG_OPTIMIZE)==0)
sh_exec(t->lst.lstrit,flags);
break;

Expand All @@ -1939,7 +1933,7 @@ int sh_exec(const Shnode_t *t, int flags)
case TORF:
if(type&TTEST)
skipexitset++;
if(sh_exec(t->lst.lstlef,OPTIMIZE)!=0)
if(sh_exec(t->lst.lstlef, flags & ARG_OPTIMIZE)!=0)
sh_exec(t->lst.lstrit,flags);
break;

Expand All @@ -1951,7 +1945,7 @@ int sh_exec(const Shnode_t *t, int flags)
char **args;
int nargs;
Namval_t *np;
int flag = errorflg|OPTIMIZE_FLAG;
int flag = errorflg|ARG_OPTIMIZE;
struct dolnod *argsav = NULL;
struct comnod *tp;
char *cp, *trap, *null_pointer = NULL;
Expand Down Expand Up @@ -2048,7 +2042,7 @@ int sh_exec(const Shnode_t *t, int flags)
sh_debug(trap,NULL,NULL,av,0);
}
sh_exec(t->for_.fortre,flag);
flag &= ~OPTIMIZE_FLAG;
flag &= ~ARG_OPTIMIZE;
if(t->tre.tretyp&COMSCAN)
{
if((cp=nv_getval(sh_scoped(REPLYNOD))) && *cp==0)
Expand Down Expand Up @@ -2085,7 +2079,7 @@ int sh_exec(const Shnode_t *t, int flags)
case TWH:
{
volatile int r=0;
int first = OPTIMIZE_FLAG;
int first = ARG_OPTIMIZE;
Shnode_t *tt = t->wh.whtre;
#if SHOPT_FILESCAN
Sfio_t *iop=0;
Expand Down Expand Up @@ -2138,7 +2132,7 @@ int sh_exec(const Shnode_t *t, int flags)
if(sh.st.breakcnt==0 && t->wh.whinc)
sh_exec((Shnode_t*)t->wh.whinc,first);
first = 0;
errorflg &= ~OPTIMIZE_FLAG;
errorflg &= ~ARG_OPTIMIZE;
#if SHOPT_FILESCAN
sh.offsets[0] = -1;
sh.offsets[1] = 0;
Expand Down Expand Up @@ -2182,7 +2176,7 @@ int sh_exec(const Shnode_t *t, int flags)
error_info.line = t->ar.arline-sh.st.firstline;
arg[0] = "((";
if(!(t->ar.arexpr->argflag&ARG_RAW))
arg[1] = sh_macpat(t->ar.arexpr,OPTIMIZE|ARG_ARITH);
arg[1] = sh_macpat(t->ar.arexpr,(flags & ARG_OPTIMIZE)|ARG_ARITH);
else
arg[1] = t->ar.arexpr->argval;
arg[2] = "))";
Expand All @@ -2205,7 +2199,7 @@ int sh_exec(const Shnode_t *t, int flags)
* Conditional block: if ... fi
*/
case TIF:
if(sh_exec(t->if_.iftre,OPTIMIZE)==0)
if(sh_exec(t->if_.iftre, flags & ARG_OPTIMIZE)==0)
sh_exec(t->if_.thtre,flags);
else if(t->if_.eltre)
sh_exec(t->if_.eltre, flags);
Expand All @@ -2219,7 +2213,7 @@ int sh_exec(const Shnode_t *t, int flags)
case TSW:
{
const int eflag = flags & sh_state(SH_ERREXIT);
char *r = sh_macpat(t->sw.swarg,OPTIMIZE);
char *r = sh_macpat(t->sw.swarg, flags & ARG_OPTIMIZE);
error_info.line = t->sw.swline - sh.st.firstline;
if(sh.st.trap[SH_DEBUGTRAP])
{
Expand All @@ -2239,7 +2233,7 @@ int sh_exec(const Shnode_t *t, int flags)
const unsigned char raw = rex->argflag & ARG_RAW;
char *s;
if(rex->argflag&ARG_MAC)
s = sh_macpat(rex,OPTIMIZE|ARG_EXP);
s = sh_macpat(rex,(flags & ARG_OPTIMIZE)|ARG_EXP);
else
s = rex->argval;
if(raw && strcmp(r,s)==0 || !raw && strmatch(r,s))
Expand Down Expand Up @@ -2274,7 +2268,7 @@ int sh_exec(const Shnode_t *t, int flags)
#endif
if(type!=TTIME)
{
sh_exec(t->par.partre,OPTIMIZE);
sh_exec(t->par.partre, flags & ARG_OPTIMIZE);
sh.exitval = !sh.exitval;
break;
}
Expand All @@ -2294,7 +2288,7 @@ int sh_exec(const Shnode_t *t, int flags)
}
#endif
sh_onstate(SH_TIMING);
sh_exec(t->par.partre,sh_isstate(SH_ERREXIT)|OPTIMIZE);
sh_exec(t->par.partre,sh_isstate(SH_ERREXIT)|(flags & ARG_OPTIMIZE));
if(!timer_on)
sh_offstate(SH_TIMING);
}
Expand Down Expand Up @@ -2535,7 +2529,7 @@ int sh_exec(const Shnode_t *t, int flags)
echeck = 1;
if((type&TPAREN)==TPAREN)
{
sh_exec(t->lst.lstlef,OPTIMIZE);
sh_exec(t->lst.lstlef, flags & ARG_OPTIMIZE);
n = !sh.exitval;
}
else
Expand All @@ -2545,9 +2539,9 @@ int sh_exec(const Shnode_t *t, int flags)
char *trap;
char *argv[6];
n = type>>TSHIFT;
left = sh_macpat(&(t->lst.lstlef->arg),OPTIMIZE);
left = sh_macpat(&(t->lst.lstlef->arg), flags & ARG_OPTIMIZE);
if(type&TBINARY)
right = sh_macpat(&(t->lst.lstrit->arg),((n==TEST_PEQ||n==TEST_PNE)?ARG_EXP:0)|OPTIMIZE);
right = sh_macpat(&(t->lst.lstrit->arg),((n==TEST_PEQ||n==TEST_PNE)?ARG_EXP:0)|(flags & ARG_OPTIMIZE));
if(trap=sh.st.trap[SH_DEBUGTRAP])
argv[0] = (type&TNEGATE)?((char*)e_tstbegin):"[[";
if(sh_isoption(SH_XTRACE))
Expand Down Expand Up @@ -2634,7 +2628,7 @@ int sh_exec(const Shnode_t *t, int flags)
}
if(!skipexitset)
exitset();
if(!(OPTIMIZE))
if(!(flags & ARG_OPTIMIZE))
{
if(sav != stkptr(sh.stk,0))
stkset(sh.stk,sav,0);
Expand Down
Loading

0 comments on commit 08714c3

Please sign in to comment.