mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 06:23:19 -07:00
* usr/lib/byobu/uptime: fix string bug in uptime introduced by smoser's
changes * usr/lib/byobu/.shutil: fix rounding across a decimal point in fpdiv() * usr/lib/byobu/swap: update to address fix in fpdiv * usr/lib/byobu/mem_used: use fpdiv to round free memory properly
This commit is contained in:
commit
61c1009fc3
4 changed files with 29 additions and 12 deletions
13
debian/changelog
vendored
13
debian/changelog
vendored
|
@ -12,6 +12,19 @@ byobu (4.3-0ubuntu1) oneiric; urgency=low
|
|||
|
||||
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 24 May 2011 22:29:00 -0500
|
||||
|
||||
byobu (4.3) unreleased; urgency=low
|
||||
|
||||
[ Dustin Kirkland ]
|
||||
* usr/lib/byobu/uptime: fix string bug in uptime introduced by smoser's
|
||||
changes
|
||||
|
||||
[ Scott Moser ]
|
||||
* usr/lib/byobu/.shutil: fix rounding across a decimal point in fpdiv()
|
||||
* usr/lib/byobu/swap: update to address fix in fpdiv
|
||||
* usr/lib/byobu/mem_used: use fpdiv to round free memory properly
|
||||
|
||||
-- Dustin Kirkland <kirkland@ubuntu.com> Mon, 23 May 2011 19:21:36 -0500
|
||||
|
||||
byobu (4.2-0ubuntu1) oneiric; urgency=low
|
||||
|
||||
[ Dustin Kirkland ]
|
||||
|
|
|
@ -41,18 +41,23 @@ find_script() {
|
|||
# third argument indicates how many digits after the decimal
|
||||
fpdiv() {
|
||||
local a=$1 b=$2 pres=${3:-3}
|
||||
local i=0 mp="10" whole="" part=""
|
||||
local i=0 mp="10" whole="" part="" chunk="" n=0
|
||||
while i=$(($i+1)) && [ $i -le $pres ]; do
|
||||
mp="${mp}0"
|
||||
chunk="${chunk}?"
|
||||
done
|
||||
whole=$(($a/$b))
|
||||
part=$((((($a%$b)*${mp})/$b)))
|
||||
if [ $part -eq 0 ]; then
|
||||
part=${part#1};
|
||||
elif [ $((${part}%(${mp}/10))) -ge 5 ]; then
|
||||
part=$(($part+5))
|
||||
fi
|
||||
_RET="${whole}.${part%?}"
|
||||
|
||||
n=$(((${mp}*${a})/${b}))
|
||||
|
||||
# round up if necessary
|
||||
[ $(($n%${mp})) -ge $((${mp}/2)) ] && n=$(($n+5))
|
||||
|
||||
# drop the last digit, which was only there for rounding
|
||||
n=${n%?}
|
||||
whole=${n%${chunk}}
|
||||
part=${n#${whole}}
|
||||
_RET=${whole}${part:+.${part}}
|
||||
return
|
||||
}
|
||||
|
||||
# rtrim(string,chars)
|
||||
|
|
|
@ -51,8 +51,7 @@ meminfo_used() {
|
|||
fo_buffers=$(($kb_main_used - $buffers_plus_cached))
|
||||
fo_cached=$(($kb_main_free + $buffers_plus_cached))
|
||||
|
||||
#fpdiv $((100*${fo_buffers})) "${total}" 0; _RET=${_RET%.}; return
|
||||
_RET=$(((100*${fo_buffers}) / ${total}))
|
||||
fpdiv $((100*${fo_buffers})) "${total}" 0;
|
||||
}
|
||||
|
||||
if [ -r /proc/meminfo ]; then
|
||||
|
|
|
@ -49,7 +49,7 @@ swap_info() {
|
|||
unit="GB"
|
||||
elif [ $mem -ge 1024 ]; then
|
||||
fpdiv "${mem}" 1024 0
|
||||
mem=${_RET%.}
|
||||
mem=${_RET}
|
||||
unit="MB"
|
||||
else
|
||||
mem="$mem"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue