diff --git a/src/math/bh_charcalc.sh b/src/math/bh_charcalc.sh index 96e51b8..4cef36c 100644 --- a/src/math/bh_charcalc.sh +++ b/src/math/bh_charcalc.sh @@ -7,20 +7,19 @@ bh_charcalc() { local i case $2 in - +|-) - for i in $(echo "$1" | sed 's/./& /g'); do - char=$(bh_asc2dec $i) - res=$(($char $2 $3)) - echo -n $(bh_dec2asc $res) - done - echo - ;; - '*') - for (( i=0; i<$3; i++ )); do - res="$res$1" - done - echo $res - ;; + +|-) + for i in $(echo "$1" | sed 's/./& /g'); do + char=$(bh_str2dec $i) + res=$(($char $2 $3)) + echo -n $(bh_dec2asc $res) + done + echo + ;; + '*') + for (( i=0; i<$3; i++ )); do + res="$res$1" + done + echo $res + ;; esac - } diff --git a/src/strings/bh_asc2dec.sh b/src/strings/bh_asc2dec.sh deleted file mode 100644 index 47f398a..0000000 --- a/src/strings/bh_asc2dec.sh +++ /dev/null @@ -1,5 +0,0 @@ -bh_asc2dec() { - (( $# < 1 )) && return 1 - - printf "%d\n" "'$1" -} diff --git a/src/strings/bh_str2dec.sh b/src/strings/bh_str2dec.sh index c4adf61..7f4e9f3 100644 --- a/src/strings/bh_str2dec.sh +++ b/src/strings/bh_str2dec.sh @@ -4,3 +4,10 @@ bh_str2dec() { echo -n "$1" | hexdump -ve '/1 "%d "' | sed 's/\(.*\) /\1/' echo } + +bh_asc2dec() { + echo "WARNING: bh_asc2dec() is depcreated and will be removed in the next release. Use bh_str2dec() instead." + (( $# < 1 )) && return 1 + + bh_str2dec $1 +}