Skip to content

Commit

Permalink
Some more minor cleanups
Browse files Browse the repository at this point in the history
src/cmd/INIT/mamake.c:
- Remove a superfluous test for strict() mode; it's known to be
  true there. (re: 29ab3b1, 60bda12)

src/lib/libast/include/ast.h:
- Add safety parentheses for mb2wc() macro.

src/cmd/ksh93/tests/*.sh:
- Timing adjustments for very slow ksh binaries (as in, compiled
  with AddressSanitizer).
  • Loading branch information
McDutchie committed Dec 31, 2023
1 parent 991b13a commit c40a5fa
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/cmd/INIT/mamake.c
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@ make(Rule_t* r)
{
bindfile(q);
if (!(q->flags & (RULE_dontcare | RULE_exists)))
dont(q, 0, strict() ? state.keepgoing : 1);
dont(q, 0, state.keepgoing);
}
}
else if (*v)
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/ksh93/tests/basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,9 @@ s=SECONDS
set -o pipefail
for ((i=0; i < 30; i++))
do print hello
sleep .01
done | "$binsleep" .1
(( (SECONDS-s) < .2 )) || err_exit 'early termination not causing broken pipe'
sleep .02
done | "$binsleep" .2
(( (SECONDS-s) < .4 )) || err_exit 'early termination not causing broken pipe'

got=$({ trap 'print trap' 0; print -n | "$bincat"; } & wait "$!")
[[ $got == trap ]] || err_exit "trap on exit not correctly triggered (expected 'trap', got $(printf %q "$got"))"
Expand Down
1 change: 1 addition & 0 deletions src/cmd/ksh93/tests/coprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ do
$cat |&
!
chmod +x $file
wait
sleep 1 |&
$file 2> /dev/null || err_exit "parent $cat coprocess prevents script coprocess"
exec 5<&p 6>&p
Expand Down
10 changes: 6 additions & 4 deletions src/cmd/ksh93/tests/nameref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,18 @@ i=$($SHELL -c 'nameref foo=bar; bar[2]=(x=3 y=4); nameref x=foo[2].y;print -r --
) == *foo=hello* ]] || err_exit 'unable to display compound variable from name reference of local variable'
#set -x
for c in '=' '[' ']' '\' "'" '"' '<' '=' '('
do [[ $($SHELL 2> /dev/null <<- ++EOF++
do got=$($SHELL 2> /dev/null <<- ++EOF++
i=\\$c;typeset -A a; a[\$i]=foo;typeset -n x=a[\$i]; print "\$x"
++EOF++
) != foo ]] && err_exit 'nameref x=a[$c] '"not working for c=$c"
)
[[ $got != foo ]] && err_exit 'nameref x=a[$c] '"not working for c=$c (expected 'foo', got $(printf %q "$got"))"
done
for c in '=' '[' ']' '\' "'" '"' '<' '=' '('
do [[ $($SHELL 2> /dev/null <<- ++EOF++
do got=$($SHELL 2> /dev/null <<- ++EOF++
i=\\$c;typeset -A a; a[\$i]=foo;b=a[\$i];typeset -n x=\$b; print "\$x"
++EOF++
) != foo ]] && err_exit 'nameref x=$b with b=a[$c] '"not working for c=$c"
)
[[ $got != foo ]] && err_exit 'nameref x=$b with b=a[$c] '"not working for c=$c (expected 'foo', got $(printf %q "$got"))"
done
unset -n foo x
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 @@ -860,7 +860,7 @@ done
EOF
"$SHELL" -i "$tmp/backtick_crash.ksh" 2>/dev/null & # run test as bg job
test_pid=$!
(sleep 10; kill -s KILL "$test_pid" 2>/dev/null) & # another bg job to kill frozen test job
(sleep 20; kill -s KILL "$test_pid" 2>/dev/null) & # another bg job to kill frozen test job
sleep_pid=$!
{ wait "$test_pid"; } 2>/dev/null # get job's exit status, suppressing signal messages
((!(e = $?))) || err_exit "backtick comsub crash/freeze (got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libast/include/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ typedef struct
#define mbcoll() ( ast.mb_xfrm != 0 )
#define mbwide() ( mbmax() > 1 )

#define mb2wc(w,p,n) ( *ast.mb_towc)(&w, (char*)p, n )
#define mb2wc(w,p,n) ( (*ast.mb_towc)(&w, (char*)p, n) )
#define mbchar(p) mbnchar(p, mbmax())
#define mbnchar(p,n) ( mbwide() ? ( (ast.tmp_int = (*ast.mb_towc)(&ast.tmp_wchar, (char*)(p), n)) > 0 ? \
( (p+=ast.tmp_int),ast.tmp_wchar) : (p+=ast.mb_sync+1,ast.tmp_int) ) : (*(unsigned char*)(p++)) )
Expand Down

0 comments on commit c40a5fa

Please sign in to comment.