mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
iffe: some more tweaks
src/cmd/INIT/iffe.sh: - Remove obsolete $posix_noglob/$posix_glob code to disable and re-enable pathname expansion. Instead, globally disable it using 'set -o noglob'. Except a couple of 'rm' commands, no aspect of this code uses globbing (note: 'case' patterns do not count), nor do any of the shell code feature tests that are eval'ed by iffe. Field splitting is heavily used via unquoted variable expansions; globbing should not interfere. (Concrete example: one of the test notes in src/cmd/ksh93/features/options is "SHOPT_* option probe" and that SHOPT_* is taken as a file name pattern, so could be expanded.) For the rm commands, globbing is turned back on in a subshell. If this breaks something that I've missed, hopefully that will turn up soon. - Remove $show/$SHOW code to massage different versions of 'echo' into acting consistently; instead, use a show_test() function that uses the POSIX-specified printf command. - For debugging level 2 and 3, use much more extensive PS4 prompts taken from modernish (which I wrote), depending on the shell. - Replace the obsolete 'set -' command. In the ancient Bourne shell, this disables the v and x options, so is equivalent to 'set +v +x'. This still works on almost all modern shells, but not yash, and POSIX considers it "unspecified". - Remove a few echo|sed fallbacks I'd missed (re: 215efa15). src/cmd/ksh93/features/math.sh: - Disable pathname expansion here as well. - Pass down an inherited $IFFEFLAGS to recursive iffe invocations.
This commit is contained in:
parent
1a9af9db40
commit
de5bdd12a4
2 changed files with 56 additions and 68 deletions
|
@ -33,9 +33,10 @@ esac
|
|||
case $HOSTTYPE in
|
||||
ibm.*) unset LIBPATH ;; # AIX: avoid failure to link to libiconv
|
||||
esac
|
||||
set -o noglob
|
||||
|
||||
command=iffe
|
||||
version=2021-12-31
|
||||
version=2022-01-09
|
||||
|
||||
compile() # $cc ...
|
||||
{
|
||||
|
@ -170,6 +171,18 @@ pkg() # package
|
|||
pth="$pth . } $*"
|
||||
}
|
||||
|
||||
show_test()
|
||||
{
|
||||
case $shell in
|
||||
ksh) print -n - "$command: test: $* ..." ;;
|
||||
*) printf '%s: test: %s ...' "$command" "$*" ;;
|
||||
esac
|
||||
case $debug in
|
||||
0) ;;
|
||||
*) echo ;; # when debugging, add newline before compiler error messages
|
||||
esac
|
||||
} >&$stderr
|
||||
|
||||
is() # op name
|
||||
{
|
||||
case $verbose in
|
||||
|
@ -217,7 +230,7 @@ is() # op name
|
|||
case $ii in
|
||||
[abcdefghijklmnopqrstuvwxyz]*[abcdefghijklmnopqrstuvwxyz]'{') ii="$ii ... }end" ;;
|
||||
esac
|
||||
$show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr
|
||||
show_test $yy $ii $mm
|
||||
complete=1
|
||||
;;
|
||||
esac
|
||||
|
@ -241,7 +254,7 @@ success()
|
|||
case $complete:$verbose in
|
||||
1:1) case $suspended in
|
||||
1) suspended=0
|
||||
$show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr
|
||||
show_test $yy $ii $mm
|
||||
;;
|
||||
esac
|
||||
complete=0
|
||||
|
@ -270,7 +283,7 @@ failure()
|
|||
case $complete:$verbose in
|
||||
1:1) case $suspended in
|
||||
1) suspended=0
|
||||
$show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr
|
||||
show_test $yy $ii $mm
|
||||
;;
|
||||
esac
|
||||
complete=0
|
||||
|
@ -410,6 +423,8 @@ noisy()
|
|||
|
||||
copy() # "output-file" "data-that-must-not-be-processed-by-echo"
|
||||
{
|
||||
# Some ksh88 clones (pdksh, mksh) lack 'printf' as a built-in utility, so if a
|
||||
# ksh-type shell was detected, use the 'print' built-in for better peformance.
|
||||
case $1 in
|
||||
-) case $shell in
|
||||
ksh) print -r - "$2"
|
||||
|
@ -564,14 +579,6 @@ optimize=1
|
|||
occ=cc
|
||||
one=
|
||||
out=
|
||||
case $( (set -f && set x * && echo $# && set +f) 2>/dev/null ) in
|
||||
2) posix_noglob="set -f" posix_glob="set +f" ;;
|
||||
*) case $( (set -F && set x * && echo $# && set +F) 2>/dev/null ) in
|
||||
2) posix_noglob="set -F" posix_glob="set +F" ;;
|
||||
*) posix_noglob=":" posix_glob=":" ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
puthdr=
|
||||
putlib=
|
||||
pragma=
|
||||
|
@ -1183,17 +1190,6 @@ case " $* " in
|
|||
;;
|
||||
esac
|
||||
|
||||
# prompt complications
|
||||
|
||||
case $(print -n aha </dev/null 2>/dev/null) in
|
||||
aha) show='print -n' SHOW='' ;;
|
||||
*) case $(echo -n aha 2>/dev/null) in
|
||||
-n*) show=echo SHOW='\c' ;;
|
||||
*) show='echo -n' SHOW='' ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
# tmp files cleaned up on exit
|
||||
# status: 0:success 1:failure 2:interrupt
|
||||
|
||||
|
@ -1208,7 +1204,7 @@ case $debug in
|
|||
fi
|
||||
;;
|
||||
esac
|
||||
trap "rm -f $core $tmp*" 0
|
||||
trap "(set +o noglob; exec rm -f $core $tmp*)" 0
|
||||
if (:>$tmp.c) 2>/dev/null
|
||||
then rm -f $tmp.c
|
||||
else echo "$command: cannot create tmp files in current dir" >&2
|
||||
|
@ -1261,18 +1257,14 @@ do case $in in
|
|||
*) case $ini in
|
||||
'') if read lin
|
||||
then line=$((line+1))
|
||||
$posix_noglob
|
||||
set x $lin
|
||||
$posix_glob
|
||||
case $# in
|
||||
1) continue ;;
|
||||
esac
|
||||
else set x
|
||||
fi
|
||||
;;
|
||||
*) $posix_noglob
|
||||
set x $ini
|
||||
$posix_glob
|
||||
*) set x $ini
|
||||
ini=
|
||||
;;
|
||||
esac
|
||||
|
@ -1351,13 +1343,8 @@ do case $in in
|
|||
exit 1
|
||||
;;
|
||||
esac
|
||||
case $shell in
|
||||
ksh) ifelse=${ifstack%%:*}
|
||||
ifstack=${ifstack#*:}
|
||||
;;
|
||||
*) eval $(echo $ifstack | sed 's,\([^:]*\):\(.*\),ifelse=\1 ifstack=\2,')
|
||||
;;
|
||||
esac
|
||||
ifelse=${ifstack%%:*}
|
||||
ifstack=${ifstack#*:}
|
||||
shift
|
||||
;;
|
||||
*) break
|
||||
|
@ -1524,21 +1511,35 @@ do case $in in
|
|||
debug) debug=$arg
|
||||
case $arg in
|
||||
0) exec 2>&$nullout
|
||||
set -
|
||||
show=echo
|
||||
SHOW=
|
||||
set +v +x
|
||||
;;
|
||||
""|1) exec 2>&$stderr
|
||||
set -
|
||||
show=echo
|
||||
SHOW=
|
||||
set +v +x
|
||||
;;
|
||||
2|3) exec 2>&$stderr
|
||||
case $shell in
|
||||
ksh) eval 'PS4="${PS4%+*([ ])}+\$LINENO+ "'
|
||||
# Useful shell-dependent PS4 trace prompts from modernish.
|
||||
# The ${foo#{foo%/*/*}/} substitutions below are to trace just the last two
|
||||
# elements of path names, instead of the full paths which can be very long.
|
||||
case ${ZSH_VERSION:+Zsh}${NETBSD_SHELL:+Netsh}${KSH_VERSION:+Ksh}${BASH_VERSION:+Bash} in
|
||||
Zsh) typeset -F SECONDS
|
||||
PS4='+ [${SECONDS:+${SECONDS%????}s|}${ZSH_SUBSHELL:+S$ZSH_SUBSHELL,}${funcfiletrace:+${funcfiletrace#${funcfiletrace%/*/*}/},}${funcstack:+${funcstack#${funcstack%/*/*}/},}${LINENO:+L$LINENO,}e$?] ' ;;
|
||||
Netsh) PS4='+ [${ToD:+$ToD|}${LINENO:+L$LINENO,}e$?] ' ;;
|
||||
Ksh) case $KSH_VERSION in
|
||||
'Version '*)
|
||||
typeset -F SECONDS
|
||||
PS4='+ [${SECONDS:+${SECONDS%????}s|}${.sh.pid:+P${.sh.pid},}${.sh.subshell:+S${.sh.subshell},}${.sh.file:+${.sh.file#${.sh.file%/*/*}/},}${.sh.fun:+${.sh.fun},}${LINENO:+L$LINENO,}e$?] ' ;;
|
||||
@\(*) PS4='+ [${EPOCHREALTIME:+${EPOCHREALTIME#???????}s|}${BASHPID:+P$BASHPID,}${LINENO:+L$LINENO,}e$?] ' ;;
|
||||
esac ;;
|
||||
Bash) case ${EPOCHREALTIME:+s} in
|
||||
s) PS4='+ [${EPOCHREALTIME:+${EPOCHREALTIME#???????}s|}' ;;
|
||||
'') PS4='+ [${SECONDS:+${SECONDS}s|}' ;;
|
||||
esac
|
||||
PS4=$PS4'${BASHPID:+P$BASHPID,}${BASH_SOURCE:+${BASH_SOURCE#${BASH_SOURCE%/*/*}/},}${FUNCNAME:+$FUNCNAME,}${LINENO:+L$LINENO,}e$?] ' ;;
|
||||
'') case ${SECONDS:+s} in
|
||||
s) PS4='+ [${SECONDS:+${SECONDS}s|}${LINENO:+L$LINENO,}e$?] ' ;;
|
||||
'') PS4='+ [${LINENO:+L$LINENO,}e$?] ' ;;
|
||||
esac ;;
|
||||
esac
|
||||
show=echo
|
||||
SHOW=
|
||||
set -x
|
||||
;;
|
||||
*) echo "$command: $arg: debug levels are 0, 1, 2, 3" >&$stderr
|
||||
|
@ -1609,7 +1610,7 @@ do case $in in
|
|||
continue
|
||||
;;
|
||||
nodebug)exec 2>&$nullout
|
||||
set -
|
||||
set +v +x
|
||||
continue
|
||||
;;
|
||||
nodefine)
|
||||
|
@ -1880,9 +1881,7 @@ do case $in in
|
|||
done
|
||||
case $eof in
|
||||
0) line=$((line+1))
|
||||
$posix_noglob
|
||||
set x $lin
|
||||
$posix_glob
|
||||
case $2 in
|
||||
$v) n=$((n+1))
|
||||
;;
|
||||
|
@ -1977,10 +1976,7 @@ do case $in in
|
|||
ref) cc="$cc $1"
|
||||
occ="$occ $1"
|
||||
case $1 in
|
||||
-L*) case $shell in
|
||||
ksh) x=${1#-L} ;;
|
||||
*) x=$(echo x$1 | sed 's,^x-L,,') ;;
|
||||
esac
|
||||
-L*) x=${1#-L}
|
||||
for y in $libpaths
|
||||
do eval $y=\"\$$y:\$x\$${y}_default\"
|
||||
eval export $y
|
||||
|
@ -3056,10 +3052,7 @@ int x;
|
|||
# set up the candidate lib list
|
||||
|
||||
for x in $lib $deflib
|
||||
do case $shell in
|
||||
ksh) eval 'c=${x#-l}' ;;
|
||||
*) c=$(echo X$x | sed 's,X-l,,') ;;
|
||||
esac
|
||||
do c=${x#-l}
|
||||
case $c in
|
||||
*[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*)
|
||||
c=$(echo '' $c | sed -e 's,.*[\\/],,' -e 's,\.[^.]*$,,' -e 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_],_,g' -e '/^lib./s,^lib,,')
|
||||
|
@ -3104,10 +3097,7 @@ int x;
|
|||
$u) ;;
|
||||
*) case $m in
|
||||
hdr_*|lib_*|sys_*)
|
||||
case $shell in
|
||||
ksh) u=${u#????} ;;
|
||||
*) u=$(echo $u | sed 's/....//') ;;
|
||||
esac
|
||||
u=${u#????}
|
||||
;;
|
||||
esac
|
||||
m=HAVE_${u}
|
||||
|
@ -3120,10 +3110,7 @@ int x;
|
|||
mth) m=HAVE${u}_MATH ;;
|
||||
npt) m=HAVE${u}_DECL ;;
|
||||
pth) m=${u}_PATH
|
||||
case $shell in
|
||||
ksh) m=${m#_} ;;
|
||||
*) m=$(echo $m | sed 's,^_,,') ;;
|
||||
esac
|
||||
m=${m#_}
|
||||
;;
|
||||
nxt) m=HAVE${u}_NEXT ;;
|
||||
siz) m=SIZEOF${u} ;;
|
||||
|
@ -3218,7 +3205,7 @@ $src
|
|||
esac
|
||||
done
|
||||
fi
|
||||
rm -f ${tmp}s.*
|
||||
(set +o noglob; exec rm -f ${tmp}s.*)
|
||||
#...INDENT
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -21,15 +21,16 @@
|
|||
: generate the ksh math builtin table
|
||||
: include math.tab
|
||||
|
||||
# @(#)math.sh (AT&T Research) 2013-08-11
|
||||
# @(#)math.sh (ksh 93u+m) 2022-01-09
|
||||
|
||||
case $ZSH_VERSION in
|
||||
?*) emulate ksh ;;
|
||||
*) (command set -o posix) 2>/dev/null && set -o posix ;;
|
||||
esac
|
||||
set -o noglob
|
||||
|
||||
command=$0
|
||||
iffeflags="-n -v"
|
||||
iffeflags="$IFFEFLAGS -n -v"
|
||||
iffehdrs="ast_float.h"
|
||||
iffelibs="-lm"
|
||||
table=/dev/null
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue