* usr/lib/byobu/cpu_freq, usr/lib/byobu/include/shutil: LP: #909325

- use a leading zero on fpdiv operations, for consistency with
    awk-based math
This commit is contained in:
Dustin Kirkland 2011-12-29 12:27:25 -06:00
commit 0fd8716579
3 changed files with 6 additions and 3 deletions

3
debian/changelog vendored
View file

@ -4,6 +4,9 @@ byobu (5.1) unreleased; urgency=low
- switch the order of the listed backends - switch the order of the listed backends
* debian/control: LP: #909221 * debian/control: LP: #909221
- depend on tmux, recommend screen - depend on tmux, recommend screen
* usr/lib/byobu/cpu_freq, usr/lib/byobu/include/shutil: LP: #909325
- use a leading zero on fpdiv operations, for consistency with
awk-based math
-- Dustin Kirkland <kirkland@ubuntu.com> Sat, 24 Dec 2011 17:35:04 -0600 -- Dustin Kirkland <kirkland@ubuntu.com> Sat, 24 Dec 2011 17:35:04 -0600

View file

@ -31,12 +31,12 @@ __cpu_freq() {
freq="$_RET" freq="$_RET"
else else
if egrep -q -s -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo; then if egrep -q -s -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo; then
freq=$(egrep -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo | awk -F"[:.]" '{ printf "%.1f", $2 / 1000 }') freq=$(egrep -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo | awk -F"[:.]" '{ printf "%01.1f", $2 / 1000 }')
else else
# Must scale frequency by number of processors, if counting bogomips # Must scale frequency by number of processors, if counting bogomips
count=$(getconf _NPROCESSORS_ONLN 2>/dev/null || grep -ci "^processor" /proc/cpuinfo) count=$(getconf _NPROCESSORS_ONLN 2>/dev/null || grep -ci "^processor" /proc/cpuinfo)
freq=$(egrep -i -m 1 "^bogomips" /proc/cpuinfo | awk -F"[:.]" '{ print $2 }') freq=$(egrep -i -m 1 "^bogomips" /proc/cpuinfo | awk -F"[:.]" '{ print $2 }')
freq=$(echo "$freq" "$count" | awk '{printf "%.1f\n", $1/$2/1000}') freq=$(echo "$freq" "$count" | awk '{printf "%01.1f\n", $1/$2/1000}')
fi fi
fi fi
color b c W; printf "%s" "$freq"; color -; color c W; printf "%s" "$ICON_GHz"; color -- color b c W; printf "%s" "$freq"; color -; color c W; printf "%s" "$ICON_GHz"; color --

View file

@ -180,7 +180,7 @@ fpdiv() {
n=${n%?} n=${n%?}
whole=${n%${chunk}} whole=${n%${chunk}}
part=${n#${whole}} part=${n#${whole}}
_RET=${whole}${part:+.${part}} _RET=${whole:-0}${part:+.${part}}
return return
} }