mirror of
https://github.com/drwetter/testssl.sh.git
synced 2025-01-01 06:19:44 +01:00
Print consecutive spaces faster
This commit adds a new function, print_n_spaces(), which prints a sequence of (up to 80) space characters. This new function is used to replace a few places in testssl.sh in which a sequence of space characters is printed by calling 'out " "' in a loop. The new function is much faster than the current code, so it will make testssl.sh run slightly faster.
This commit is contained in:
parent
18dfa26e48
commit
fc310301f1
26
testssl.sh
26
testssl.sh
@ -1555,6 +1555,14 @@ prepare_logging() {
|
|||||||
|
|
||||||
################### END all file output functions #########################
|
################### END all file output functions #########################
|
||||||
|
|
||||||
|
# prints a string of n spaces (n < 80)
|
||||||
|
print_n_spaces() {
|
||||||
|
local -i n="$1"
|
||||||
|
local spaces=" "
|
||||||
|
|
||||||
|
out "${spaces:0:n}"
|
||||||
|
}
|
||||||
|
|
||||||
# prints out multiple lines in $1, left aligned by spaces in $2
|
# prints out multiple lines in $1, left aligned by spaces in $2
|
||||||
out_row_aligned() {
|
out_row_aligned() {
|
||||||
local first=true
|
local first=true
|
||||||
@ -1638,14 +1646,12 @@ out_row_aligned_max_width_by_entry() {
|
|||||||
|
|
||||||
print_fixed_width() {
|
print_fixed_width() {
|
||||||
local text="$1"
|
local text="$1"
|
||||||
local -i i len width="$2"
|
local -i len width="$2"
|
||||||
local print_function="$3"
|
local print_function="$3"
|
||||||
|
|
||||||
len=${#text}
|
len=${#text}
|
||||||
$print_function "$text"
|
$print_function "$text"
|
||||||
for (( i=len; i <= width; i++ )); do
|
print_n_spaces "$((width-len+1))"
|
||||||
out " "
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# saves $TMPFILE or file supplied in $2 under name "$TEMPDIR/$NODEIP.$1".
|
# saves $TMPFILE or file supplied in $2 under name "$TEMPDIR/$NODEIP.$1".
|
||||||
@ -3570,9 +3576,7 @@ neat_list(){
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
len=${#kx}
|
len=${#kx}
|
||||||
for (( i=len; i<10; i++ )); do
|
print_n_spaces "$((10-len))"
|
||||||
out " "
|
|
||||||
done
|
|
||||||
out "$(printf -- " %-12s%-8s " "$enc" "$strength")"
|
out "$(printf -- " %-12s%-8s " "$enc" "$strength")"
|
||||||
if [[ "$COLOR" -le 2 ]]; then
|
if [[ "$COLOR" -le 2 ]]; then
|
||||||
if [[ "$DISPLAY_CIPHERNAMES" == rfc ]]; then
|
if [[ "$DISPLAY_CIPHERNAMES" == rfc ]]; then
|
||||||
@ -4984,13 +4988,9 @@ run_client_simulation() {
|
|||||||
pr_cipher_quality "$cipher"
|
pr_cipher_quality "$cipher"
|
||||||
fi
|
fi
|
||||||
if [[ "$DISPLAY_CIPHERNAMES" =~ openssl ]]; then
|
if [[ "$DISPLAY_CIPHERNAMES" =~ openssl ]]; then
|
||||||
for (( j=${#cipher}; j < 34; j++ )); do
|
print_n_spaces "$((34-${#cipher}))"
|
||||||
out " "
|
|
||||||
done
|
|
||||||
else
|
else
|
||||||
for (( j=${#cipher}; j < 50; j++ )); do
|
print_n_spaces "$((50-${#cipher}))"
|
||||||
out " "
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
if [[ -n "$what_dh" ]]; then
|
if [[ -n "$what_dh" ]]; then
|
||||||
[[ -n "$curve" ]] && curve="($curve)"
|
[[ -n "$curve" ]] && curve="($curve)"
|
||||||
|
Loading…
Reference in New Issue
Block a user