src/tests: clean up duplicate code
This commit is contained in:
@@ -24,14 +24,8 @@
|
||||
# would be predicted as ")" before being replaced by the
|
||||
# correct character.
|
||||
#
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
. $(dirname $0)/e2e-test-subrs
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
@@ -39,65 +33,6 @@ if [ $# -eq 0 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
sleepf()
|
||||
{
|
||||
(sleep .1 || sleep 1) > /dev/null 2>&1
|
||||
}
|
||||
|
||||
seq()
|
||||
{
|
||||
if [ $# -lt 1 -o $# -gt 3 ]; then
|
||||
echo "bad args" >&2
|
||||
fi
|
||||
first=$1
|
||||
incr=1
|
||||
last=0
|
||||
case $# in
|
||||
3)
|
||||
incr=$2
|
||||
last=$3
|
||||
;;
|
||||
2)
|
||||
last=$2
|
||||
;;
|
||||
1)
|
||||
;;
|
||||
esac
|
||||
while :; do
|
||||
printf '%d\n' $first
|
||||
first=$(expr $first + $incr)
|
||||
if [ $first -gt $last ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
chr()
|
||||
{
|
||||
printf "\\$(printf %03o $1)"
|
||||
}
|
||||
|
||||
utf8cp()
|
||||
{
|
||||
if [ $1 -gt $((0x10ffff)) ]; then
|
||||
fail "illegal Unicode code point %x\n" $1
|
||||
elif [ $1 -lt $((0x80)) ]; then
|
||||
chr $1
|
||||
elif [ $1 -lt $((0x800)) ]; then
|
||||
chr $(( (($1 >> 6) & 0x1f) | 0xc0 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
elif [ $1 -lt $((0x10000)) ]; then
|
||||
chr $(( (($1 >> 12) & 0x0f) | 0xe0 ))
|
||||
chr $(( (($1 >> 6) & 0x3f) | 0x80 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
elif [ $1 -lt $((0x200000)) ]; then
|
||||
chr $(( (($1 >> 18) & 0x03) | 0xf0 ))
|
||||
chr $(( (($1 >> 12) & 0x3f) | 0x80 ))
|
||||
chr $(( (($1 >> 6) & 0x3f) | 0x80 ))
|
||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
||||
fi
|
||||
}
|
||||
|
||||
tmux_commands()
|
||||
{
|
||||
for x in $(seq 1 5); do
|
||||
|
||||
Reference in New Issue
Block a user