mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix more compiler warnings, typos and other minor issues (#260)
Many of these changes are minor typo fixes. The other changes (which are mostly compiler warning fixes) are: NEWS: - The --globcasedetect shell option works on older Linux kernels when used with FAT32/VFAT file systems, so remove the note about it only working with 5.2+ kernels. src/cmd/ksh93/COMPATIBILITY: - Update the documentation on function scoping with an addition from ksh93v- (this does apply to ksh93u+). src/cmd/ksh93/edit/emacs.c: - Check for '_AST_ksh_release', not 'AST_ksh_release'. src/cmd/INIT/mamake.c, src/cmd/INIT/ratz.c, src/cmd/INIT/release.c, src/cmd/builtin/pty.c: - Add more uses of UNREACHABLE() and noreturn, this time for the build system and pty. src/cmd/builtin/pty.c, src/cmd/builtin/array.c, src/cmd/ksh93/sh/name.c, src/cmd/ksh93/sh/nvtype.c, src/cmd/ksh93/sh/suid_exec.c: - Fix six -Wunused-variable warnings (the name.c nv_arrayptr() fixes are also in ksh93v-). - Remove the unused 'tableval' function to fix a -Wunused-function warning. src/cmd/ksh93/sh/lex.c: - Remove unused 'SHOPT_DOS' code, which isn't enabled anywhere. https://github.com/att/ast/issues/272#issuecomment-354363112 src/cmd/ksh93/bltins/misc.c, src/cmd/ksh93/bltins/trap.c, src/cmd/ksh93/bltins/typeset.c: - Add dictionary generator function declarations for former aliases that are now builtins (re:1fbbeaa1,ef1621c1,3ba4900e). - For consistency with the rest of the codebase, use '(void)' instead of '()' for print_cpu_times. src/cmd/ksh93/sh/init.c, src/lib/libast/path/pathshell.c: - Move the otherwise unused EXE macro to pathshell() and only search for 'sh.exe' on Windows. src/cmd/ksh93/sh/xec.c, src/lib/libast/include/ast.h: - Add an empty definition for inline when compiling with C89. This allows the timeval_to_double() function to be inlined. src/cmd/ksh93/include/shlex.h: - Remove the unused 'PIPESYM2' macro. src/cmd/ksh93/tests/pty.sh: - Add '# err_exit #' to count the regression test added in commit113a9392. src/lib/libast/disc/sfdcdio.c: - Move diordwr, dioread, diowrite and dioexcept behind '#ifdef F_DIOINFO' to fix one -Wunused-variable warning and multiple -Wunused-function warnings (sfdcdio() only uses these functions when F_DIOINFO is defined). src/lib/libast/string/fmtdev.c: - Fix two -Wimplicit-function-declaration warnings on Linux by including sys/sysmacros.h in fmtdev().
This commit is contained in:
parent
ecf260c282
commit
a065558291
96 changed files with 299 additions and 282 deletions
|
|
@ -132,7 +132,7 @@ y=* z=[
|
|||
s[$y]=1
|
||||
s[$z]=2
|
||||
if (( ${#s[@]} != 2 ))
|
||||
then err_exit 'number of elements of is not 2'
|
||||
then err_exit 'number of elements of s is not 2'
|
||||
fi
|
||||
(( s[$z] = s[$z] + ${s[$y]} ))
|
||||
if [[ ${s[$z]} != 3 ]]
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ if [[ ! -d . ]]
|
|||
then err_exit "-d: . should be a directory file"
|
||||
fi
|
||||
if [[ -f /dev/null ]]
|
||||
then err_exit "-f: /dev/null should not be an ordinary file"
|
||||
then err_exit "-f: /dev/null should not be an ordinary file"
|
||||
fi
|
||||
chmod 000 $file
|
||||
|
||||
|
|
@ -132,26 +132,26 @@ fi
|
|||
[[ -z '' && -z '' && -z '' ]] || err_exit "three ors not working"
|
||||
(exit 8)
|
||||
if [[ $? -ne 8 || $? -ne 8 ]]
|
||||
then err_exit 'value $? within [[...]]'
|
||||
then err_exit 'value $? within [[ ... ]]'
|
||||
fi
|
||||
x='(x'
|
||||
if [[ '(x' != '('* ]]
|
||||
then err_exit " '(x' does not match '('* within [[...]]"
|
||||
then err_exit " '(x' does not match '('* within [[ ... ]]"
|
||||
fi
|
||||
if [[ '(x' != "("* ]]
|
||||
then err_exit ' "(x" does not match "("* within [[...]]'
|
||||
then err_exit ' "(x" does not match "("* within [[ ... ]]'
|
||||
fi
|
||||
if [[ '(x' != \(* ]]
|
||||
then err_exit ' "(x" does not match \(* within [[...]]'
|
||||
then err_exit ' "(x" does not match \(* within [[ ... ]]'
|
||||
fi
|
||||
if [[ 'x(' != *'(' ]]
|
||||
then err_exit " 'x(' does not match '('* within [[...]]"
|
||||
then err_exit " 'x(' does not match '('* within [[ ... ]]"
|
||||
fi
|
||||
if [[ 'x&' != *'&' ]]
|
||||
then err_exit " 'x&' does not match '&'* within [[...]]"
|
||||
then err_exit " 'x&' does not match '&'* within [[ ... ]]"
|
||||
fi
|
||||
if [[ 'xy' == *'*' ]]
|
||||
then err_exit " 'xy' matches *'*' within [[...]]"
|
||||
then err_exit " 'xy' matches *'*' within [[ ... ]]"
|
||||
fi
|
||||
if [[ 3 > 4 ]]
|
||||
then err_exit '3 < 4'
|
||||
|
|
@ -252,7 +252,7 @@ i=hell
|
|||
[[ hell0 == $i[0] ]] || err_exit 'pattern $i[0] interpreted as array ref'
|
||||
test '(' = ')' && err_exit '"test ( = )" should not be true'
|
||||
[[ $($SHELL -c 'case F in ~(Eilr)[a-z0-9#]) print ok;;esac' 2> /dev/null) == ok ]] || err_exit '~(Eilr) not working in case command'
|
||||
[[ $($SHELL -c "case Q in ~(Fi)q | \$'\E') print ok;;esac" 2> /dev/null) == ok ]] || err_exit '~(Fi)q | \E not working in case command'
|
||||
[[ $($SHELL -c "case Q in ~(Fi)q | \$'\E') print ok;;esac" 2> /dev/null) == ok ]] || err_exit '~(Fi)q | \E not working in case command'
|
||||
|
||||
locales=$'\n'$(command -p locale -a 2>/dev/null)$'\n'
|
||||
for l in C C.UTF-8 en_US.ISO8859-1 en_US.ISO8859-15 en_US.UTF-8
|
||||
|
|
@ -330,7 +330,7 @@ unset x
|
|||
unset x y z foo bar
|
||||
|
||||
{ x=$($SHELL -c '[[ (( $# -eq 0 )) ]] && print ok') 2> /dev/null;}
|
||||
[[ $x == ok ]] || err_exit '((...)) inside [[...]] not treated as nested ()'
|
||||
[[ $x == ok ]] || err_exit '((...)) inside [[ ... ]] not treated as nested ()'
|
||||
|
||||
[[ -e /dev/fd/ ]] || err_exit '/dev/fd/ does not exits'
|
||||
[[ -e /dev/tcp/ ]] || err_exit '/dev/tcp/ does not exist'
|
||||
|
|
@ -400,11 +400,11 @@ done
|
|||
|
||||
# ======
|
||||
# Tests from ksh93v- for the -eq operator
|
||||
[[ 010 -eq 10 ]] || err_exit '010 is not 10 in [[...]]'
|
||||
[[ 010 -eq 10 ]] || err_exit '010 is not 10 in [[ ... ]]'
|
||||
|
||||
unset foo
|
||||
foo=10
|
||||
([[ foo -eq 10 ]]) || err_exit 'foo -eq 10 fails in [[...]] with foo=10'
|
||||
([[ foo -eq 10 ]]) || err_exit 'foo -eq 10 fails in [[ ... ]] with foo=10'
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
|
|||
|
|
@ -226,11 +226,11 @@ if (( $(printf 'x\0y' | wc -c) != 3 ))
|
|||
then err_exit 'printf \0 not working'
|
||||
fi
|
||||
if [[ $(printf "%bx%s\n" 'f\to\cbar') != $'f\to' ]]
|
||||
then err_exit 'printf %bx%s\n not working'
|
||||
then err_exit 'printf %bx%s\n not working'
|
||||
fi
|
||||
alpha=abcdefghijklmnop
|
||||
if [[ $(printf "%10.*s\n" 5 $alpha) != ' abcde' ]]
|
||||
then err_exit 'printf %10.%s\n not working'
|
||||
then err_exit 'printf %10.%s\n not working'
|
||||
fi
|
||||
float x2=.0000625
|
||||
if [[ $(printf "%10.5E\n" x2) != 6.25000E-05 ]]
|
||||
|
|
@ -748,11 +748,11 @@ foo=BUG command eval ':'
|
|||
# 'whence -f' should ignore functions
|
||||
foo_bar() { true; }
|
||||
actual="$(whence -f foo_bar)"
|
||||
whence -f foo_bar >/dev/null && err_exit "'whence -f' doesn't ignore functions (got '$(printf %q "$actual")')"
|
||||
whence -f foo_bar >/dev/null && err_exit "'whence -f' doesn't ignore functions (got $(printf %q "$actual"))"
|
||||
|
||||
# whence -vq/type -q must be tested as well
|
||||
actual="$(type -f foo_bar 2>&1)"
|
||||
type -f foo_bar >/dev/null 2>&1 && err_exit "'type -f' doesn't ignore functions (got '$(printf %q "$actual")')"
|
||||
type -f foo_bar >/dev/null 2>&1 && err_exit "'type -f' doesn't ignore functions (got $(printf %q "$actual"))"
|
||||
type -qf foo_bar && err_exit "'type -qf' doesn't ignore functions"
|
||||
|
||||
# Test the exit status of 'whence -q'
|
||||
|
|
@ -1060,7 +1060,7 @@ exp=1
|
|||
[[ $got == $exp ]] || err_exit "'kill %' has the wrong exit status (expected '$exp'; got '$got')"
|
||||
|
||||
# ======
|
||||
# 'cd -' should recognize the value of an overriden $OLDPWD variable
|
||||
# 'cd -' should recognize the value of an overridden $OLDPWD variable
|
||||
# https://github.com/ksh93/ksh/pull/249
|
||||
# https://github.com/att/ast/issues/8
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ if [[ ${newrec.name} != "${rec.name}" ]]
|
|||
then err_exit 'copying a compound object not working'
|
||||
fi
|
||||
if (( newrec.born.day != 16 ))
|
||||
then err_exit 'copying integer field of compound object not working'
|
||||
then err_exit 'copying integer field of compound object not working'
|
||||
fi
|
||||
p_t=(
|
||||
integer z=0
|
||||
|
|
@ -511,7 +511,7 @@ expected=$'(\n\ttypeset -A subtree=(\n\t\t[a_node]=(\n\t\t\tone=hello\n\t\t\ttwo
|
|||
typeset -C -A array
|
||||
float array[12].amount=2.9
|
||||
expected='typeset -C -A array=([12]=(typeset -l -E amount=2.9))'
|
||||
[[ $(typeset -p array) == "$expected" ]] || err_exit 'typeset with compound variable with compound variable array not working'
|
||||
[[ $(typeset -p array) == "$expected" ]] || err_exit 'typeset with compound variable with compound variable array not working'
|
||||
|
||||
typeset -T foo_t=(
|
||||
function diff
|
||||
|
|
|
|||
|
|
@ -991,7 +991,7 @@ caller() {
|
|||
bar() { caller;}
|
||||
set -- $(bar)
|
||||
[[ $1 == $2 ]] && err_exit ".sh.inline optimization bug"
|
||||
( $SHELL -c ' function foo { typeset x=$1;print $1;};z=();z=($(foo bar)) ') 2> /dev/null || err_exit 'using a function to set an array in a command sub fails'
|
||||
( $SHELL -c ' function foo { typeset x=$1;print $1;};z=();z=($(foo bar)) ') 2> /dev/null || err_exit 'using a function to set an array in a command sub fails'
|
||||
|
||||
{
|
||||
got=$(
|
||||
|
|
@ -1153,7 +1153,7 @@ func2
|
|||
}
|
||||
foo
|
||||
EOF
|
||||
} 2> /dev/null || err_exit 'problem with unset -f foo within function foo'
|
||||
} 2> /dev/null || err_exit "problem with 'unset -f foo' within function foo"
|
||||
|
||||
val=$($SHELL 2> /dev/null <<- \EOF
|
||||
.sh.fun.set() { set -x; }
|
||||
|
|
|
|||
|
|
@ -776,7 +776,7 @@ got=$(umask 777; set +x; { cat <(echo ok); } 2>&1)
|
|||
|
||||
# ======
|
||||
# https://github.com/att/ast/issues/1336
|
||||
# Use the /proc psuedo filesystem on Linux as a convenient way to force a write I/O error.
|
||||
# Use the /proc pseudo filesystem on Linux as a convenient way to force a write I/O error.
|
||||
if [[ $(uname) == Linux ]]
|
||||
then
|
||||
actual=$($SHELL -c 'echo > /proc/self/uid_map; echo okay' 2>&1)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ function x.set
|
|||
[[ ${.sh.value} ]] && print hello
|
||||
}
|
||||
if [[ $(.foo.bar.set) != $(x.set) ]]
|
||||
then err_exit "function references not working"
|
||||
then err_exit "function references not working"
|
||||
fi
|
||||
if [[ $(typeset +n) != x ]]
|
||||
then err_exit "typeset +n doesn't list names of reference variables"
|
||||
|
|
|
|||
|
|
@ -765,12 +765,14 @@ touch $'XXX\xc3\xa1' $'XXX\xc3\xab' &&
|
|||
tst $LINENO <<"!"
|
||||
L autocomplete should not fill partial multibyte characters
|
||||
# https://github.com/ksh93/ksh/issues/223
|
||||
|
||||
d 15
|
||||
p :test-1:
|
||||
w : XX\t
|
||||
r ^:test-1: : XXX\r\n$
|
||||
!
|
||||
|
||||
# err_exit #
|
||||
((SHOPT_VSH)) && tst $LINENO <<"!"
|
||||
L Using b, B, w and W commands in vi mode
|
||||
# https://github.com/att/ast/issues/1467
|
||||
|
|
|
|||
|
|
@ -85,11 +85,11 @@ if [[ $z != 'a{b}c' ]]
|
|||
then err_exit '"${z="a{b}c"}" not correct'
|
||||
fi
|
||||
if [[ $(print -r -- "a\*b") != 'a\*b' ]]
|
||||
then err_exit '$(print -r -- "a\*b") differs from a\*b'
|
||||
then err_exit '$(print -r -- "a\*b") differs from a\*b'
|
||||
fi
|
||||
unset x
|
||||
if [[ $(print -r -- "a\*b$x") != 'a\*b' ]]
|
||||
then err_exit '$(print -r -- "a\*b$x") differs from a\*b'
|
||||
then err_exit '$(print -r -- "a\*b$x") differs from a\*b'
|
||||
fi
|
||||
x=hello
|
||||
set -- ${x+foo bar bam}
|
||||
|
|
@ -306,19 +306,19 @@ re='@(?*)/@(?*)/@(?*)'
|
|||
string='\3'
|
||||
[[ ${subject/${re}/${string}} != words ]] && err_exit 'string replacement with $string not working with string=\3'
|
||||
[[ $(print -r "${subject/${re}/${string}}") != words ]] && err_exit 'string replacement with $string not working with string=\3 using print'
|
||||
[[ ${subject/${re}/"${string}"} != '\3' ]] && err_exit 'string replacement with "$string" not working with string=\3'
|
||||
[[ $(print -r "${subject/${re}/"${string}"}") != '\3' ]] && err_exit 'string replacement with "$string" not working with string=\3 using print'
|
||||
[[ ${subject/${re}/"${string}"} != '\3' ]] && err_exit 'string replacement with "$string" not working with string=\3'
|
||||
[[ $(print -r "${subject/${re}/"${string}"}") != '\3' ]] && err_exit 'string replacement with "$string" not working with string=\3 using print'
|
||||
string='\\3'
|
||||
[[ ${subject/${re}/${string}} != '\3' ]] && err_exit 'string replacement with $string not working with string=\\3'
|
||||
[[ ${subject/${re}/"${string}"} != '\\3' ]] && err_exit 'string replacement with "$string" not working with string=\\3'
|
||||
[[ ${subject/${re}/"${string}"} != '\\3' ]] && err_exit 'string replacement with "$string" not working with string=\\3'
|
||||
[[ ${subject/${re}/\4} != '\4' ]] && err_exit 'string replacement with \4 not working'
|
||||
[[ ${subject/${re}/'\4'} != '\4' ]] && err_exit 'string replacement with '\4' not working'
|
||||
string='\4'
|
||||
[[ ${subject/${re}/${string}} != '\4' ]] && err_exit 'string replacement with $string not working with string=\4'
|
||||
[[ ${subject/${re}/"${string}"} != '\4' ]] && err_exit 'string replacement with "$string" not working with string=\4'
|
||||
[[ ${subject/${re}/"${string}"} != '\4' ]] && err_exit 'string replacement with "$string" not working with string=\4'
|
||||
string='&foo'
|
||||
[[ ${subject/${re}/${string}} != '&foo' ]] && err_exit 'string replacement with $string not working with string=&foo'
|
||||
[[ ${subject/${re}/"${string}"} != '&foo' ]] && err_exit 'string replacement with "$string" not working with string=&foo'
|
||||
[[ ${subject/${re}/"${string}"} != '&foo' ]] && err_exit 'string replacement with "$string" not working with string=&foo'
|
||||
{
|
||||
x=x
|
||||
x=${x:-`id | sed 's/^[^(]*(\([^)]*\)).*/\1/'`}
|
||||
|
|
|
|||
|
|
@ -84,11 +84,11 @@ if [[ $z != 'a{b}c' ]]
|
|||
then err_exit '"${z="a{b}c"}" not correct'
|
||||
fi
|
||||
if [[ $(print -r -- "a\*b") != 'a\*b' ]]
|
||||
then err_exit '$(print -r -- "a\*b") differs from a\*b'
|
||||
then err_exit '$(print -r -- "a\*b") differs from a\*b'
|
||||
fi
|
||||
unset x
|
||||
if [[ $(print -r -- "a\*b$x") != 'a\*b' ]]
|
||||
then err_exit '$(print -r -- "a\*b$x") differs from a\*b'
|
||||
then err_exit '$(print -r -- "a\*b$x") differs from a\*b'
|
||||
fi
|
||||
x=hello
|
||||
set -- ${x+foo bar bam}
|
||||
|
|
@ -157,10 +157,10 @@ fi
|
|||
# The following caused a syntax error on earlier versions
|
||||
foo=foo x=-
|
||||
if [[ `eval print \\${foo$x}` != foo* ]]
|
||||
then err_exit '`eval print \\${foo$x}`' not working
|
||||
then err_exit '`eval print \\${foo$x}`' not working
|
||||
fi
|
||||
if [[ "`eval print \\${foo$x}`" != foo* ]]
|
||||
then err_exit '"`eval print \\${foo$x}`"' not working
|
||||
then err_exit '"`eval print \\${foo$x}`"' not working
|
||||
fi
|
||||
if ( [[ $() != '' ]] )
|
||||
then err_exit '$() not working'
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ do if print foo | grep bar
|
|||
then break
|
||||
fi
|
||||
done
|
||||
(( d==2000 )) || err_exit "trap '' CHLD causes side effects d=$d"
|
||||
(( d==2000 )) || err_exit "trap '' CHLD causes side effects d=$d"
|
||||
trap - CHLD
|
||||
|
||||
x=$($SHELL 2> /dev/null -ic '/dev/null/notfound; sleep .05 & sleep .1;jobs')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue