Skip to content

Commit

Permalink
a few more miscellaneous cleanups
Browse files Browse the repository at this point in the history
src/cmd/ksh93/sh/array.c: nv_putsub():
- Remove some dead code. The expression 'n=ap->maxi-ap->maxi'
  subtracts ap->maxi from itself, so it always yields zero, so that
  memset() call is never executed. This nonsense was added in 93p+
  2004-08-11.

src/cmd/INIT/mkdeps.sh:
- Fix name of error_out() function. Good thing it virtually never
  gets called... (re: 71c4095)

src/cmd/INIT/include/link_ar.mam:
- Avoid noisy log: disable xtrace while figuring out which obsolete
  *.o files to delete from the library archive. (re: 57f51b6)

src/cmd/ksh93/tests/{arith,comvario,math,subshell}.sh:
- More whitespace indentation fixes.
  • Loading branch information
McDutchie committed Dec 4, 2024
1 parent 57f51b6 commit e506353
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
6 changes: 4 additions & 2 deletions src/cmd/INIT/include/link_ar.mam
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@ exec - fi || exit
note * Sometimes, obsolete object files can interfere due to intercepts, so
note * delete any old object files that we no longer build from the archive

exec - set +x # avoid noisy log
exec - to_delete=
exec - for o in $(ar -t %{@})
exec - do case $o in
exec - *.o) case ' %{^} ' in
exec - *" $o "*)
exec - ;;
exec - *) to_delete="${to_delete-} $o"
exec - *) to_delete="$to_delete $o"
exec - ;;
exec - esac
exec - ;;
exec - esac
exec - done
exec - case ${to_delete:+y} in
exec - y) ar -d %{@} $to_delete
exec - y) set -x
exec - ar -d %{@} $to_delete
exec - ;;
exec - esac
2 changes: 1 addition & 1 deletion src/cmd/INIT/mkdeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ note()
printf "$0: %s\\n" "$@" >&2
}

err_out()
error_out()
{
note "$@"
exit 3
Expand Down
2 changes: 0 additions & 2 deletions src/cmd/ksh93/sh/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,8 +1222,6 @@ Namval_t *nv_putsub(Namval_t *np,char *sp,long mode)
ap->header.nelem++;
}
}
if(n=ap->maxi-ap->maxi)
memset(&ap->val[size], 0, n * sizeof(void*));
}
else if(!(sp = ap->val[size]) || sp==Empty)
{
Expand Down
16 changes: 8 additions & 8 deletions src/cmd/ksh93/tests/arith.sh
Original file line number Diff line number Diff line change
Expand Up @@ -982,14 +982,14 @@ float x
# Test for a bug with short integers that causes core dumps
# (backported from ksh93v- 2013-08-07).
"$SHELL" <<- \EOF || err_exit 'detected short integer bug that causes core dumps'
typeset -s -i -a t
typeset -s -i p
(( p=2**17 )) # tape start position
(( t[p]+=13))
while (( t[p] != 0 ))
do ((t[p]-=1 , p+=1))
done
exit 0
typeset -s -i -a t
typeset -s -i p
(( p=2**17 )) # tape start position
(( t[p]+=13))
while (( t[p] != 0 ))
do ((t[p]-=1 , p+=1))
done
exit 0
EOF

# ======
Expand Down
16 changes: 8 additions & 8 deletions src/cmd/ksh93/tests/comvario.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function count_brackets
(( bracketstat.bopen=0 , bracketstat.bclose=0 ))

for (( i=0 ; i < ${#x} ; i++ )) ; do
c="${x:i:1}"
c="${x:i:1}"
[[ "$c" == '(' ]] && (( bracketstat.bopen++ ))
[[ "$c" == ')' ]] && (( bracketstat.bclose++ ))
done
Expand Down Expand Up @@ -132,7 +132,7 @@ s=${
float my_nan=-nan
)
[a_hexfloat]=(
typeset -X my_hexfloat=1.1
typeset -X my_hexfloat=1.1
)
)
)
Expand Down Expand Up @@ -197,7 +197,7 @@ s=${
float my_nan=-nan
)
[a_hexfloat]=(
typeset -X my_hexfloat=1.1
typeset -X my_hexfloat=1.1
)
)
)
Expand Down Expand Up @@ -274,7 +274,7 @@ compound x=(
float my_nan=-nan
)
[a_hexfloat]=(
typeset -X my_hexfloat=1.1
typeset -X my_hexfloat=1.1
)
)
)
Expand Down Expand Up @@ -389,7 +389,7 @@ function test6
nameref test=tests[testid]
typeset testname="test2/${testid}"

out.stderr="${ { out.stdout="${ ${SHELL} -c "${test.cmd}" ; (( out.res=$? )) ; }" ; } 2>&1 ; }"
out.stderr="${ { out.stdout="${ ${SHELL} -c "${test.cmd}" ; (( out.res=$? )) ; }" ; } 2>&1 ; }"

(( out.res == 0 )) || err_exit "${testname}: Test shell returned with exit code ${out.res}"
[[ "${out.stdout}" == ${test.stdoutpattern} ]] || err_exit "${testname}: Expected match for ${test.stdoutpattern}, got $(printf "%q\n" "${out.stdout}")"
Expand Down Expand Up @@ -421,7 +421,7 @@ function test_3D_array_read_C
for (( i=0 ; i < ${#tests[@]} ; i++ )) ; do
out.stderr="${ { out.stdout="${ ${SHELL} -o nounset -c "${tests[i]}" ; (( out.res=$? )) ; }" ; } 2>&1 ; }"

[[ "${out.stdout}" == '' ]] || err_exit "$0/${i}: Expected empty stdout, got $(printf '%q\n' "${out.stdout}")"
[[ "${out.stdout}" == '' ]] || err_exit "$0/${i}: Expected empty stdout, got $(printf '%q\n' "${out.stdout}")"
[[ "${out.stderr}" == '' ]] || err_exit "$0/${i}: Expected empty stderr, got $(printf '%q\n' "${out.stderr}")"
done

Expand All @@ -441,7 +441,7 @@ function test_access_2Darray_in_type_in_compound
for (( i=0 ; i < ${#tests[@]} ; i++ )) ; do
out.stderr="${ { out.stdout="${ ${SHELL} -o nounset -c "${tests[i]}" ; (( out.res=$? )) ; }" ; } 2>&1 ; }"

[[ "${out.stdout}" == '' ]] || err_exit "$0/${i}: Expected empty stdout, got $(printf '%q\n' "${out.stdout}")"
[[ "${out.stdout}" == '' ]] || err_exit "$0/${i}: Expected empty stdout, got $(printf '%q\n' "${out.stdout}")"
[[ "${out.stderr}" == '' ]] || err_exit "$0/${i}: Expected empty stderr, got $(printf '%q\n' "${out.stderr}")"
done

Expand Down Expand Up @@ -498,7 +498,7 @@ print -v c2
out.stderr="${ { out.stdout="${ ${SHELL} -o nounset -c "${test}" ; (( out.res=$? )) ; }" ; } 2>&1 ; }"

[[ "${out.stdout}" != '' ]] || err_exit "$0: Expected nonempty stdout."
[[ "${out.stderr}" == '' ]] || err_exit "$0: Expected empty stderr, got $(printf '%q\n' "${out.stderr}")"
[[ "${out.stderr}" == '' ]] || err_exit "$0: Expected empty stderr, got $(printf '%q\n' "${out.stderr}")"

return 0
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/ksh93/tests/math.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ function test_arithmetic_expression_access_array_element_through_nameref
out.stderr="${ { out.stdout="${ ${SHELL} -o nounset -o errexit -c "${cmd}" ; (( out.res=$? )) ; }" ; } 2>&1 ; }"
((xtrace)) && set -x

[[ "${out.stdout}" == ${tst.stdoutpattern} ]] || err_exit "${testname}: Expected stdout to match $(printf '%q\n' "${tst.stdoutpattern}"), got $(printf '%q\n' "${out.stdout}")"
[[ "${out.stderr}" == '' ]] || err_exit "${testname}: Expected empty stderr, got $(printf '%q\n' "${out.stderr}")"
[[ "${out.stdout}" == ${tst.stdoutpattern} ]] || err_exit "${testname}: Expected stdout to match $(printf '%q\n' "${tst.stdoutpattern}"), got $(printf '%q\n' "${out.stdout}")"
[[ "${out.stderr}" == '' ]] || err_exit "${testname}: Expected empty stderr, got $(printf '%q\n' "${out.stderr}")"
(( out.res == 0 )) || err_exit "${testname}: Unexpected exit code ${out.res}"
done
done
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/tests/subshell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ e2=$( (ulimit -t unlimited 2>/dev/null; f() { return 267; }; f); echo $? )
# effects of .sh.value on shared-state command substitutions.
function foo
{
.sh.value=bam
.sh.value=bam
}
got=${ foo; }
[[ $got ]] && err_exit "setting .sh.value in a function affects shared-state command substitution output when it shouldn't print anything" \
Expand Down

0 comments on commit e506353

Please sign in to comment.