1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Use shell functions for printing hex instead of printf(1) so that

printf(1) can be dropped from the system shell as a shell builtin.
This commit is contained in:
Sheldon Hearn 2001-11-19 11:41:51 +00:00
parent 633621512e
commit b695d548a3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=86603
2 changed files with 68 additions and 4 deletions

View File

@ -32,6 +32,37 @@
# first before contemplating any changes here. If you do need to change
# this file for some reason, we would like to know about it.
hexdigit () {
if [ $1 -lt 10 ]; then
echo $1
else
case $1 in
10) echo a ;;
11) echo b ;;
12) echo c ;;
13) echo d ;;
14) echo e ;;
15) echo f ;;
esac
fi
}
hexprint () {
val=$1
str=''
dig=`hexdigit $((${val} & 15))`
str=${dig}${str}
val=$((${val} >> 4))
while [ ${val} -gt 0 ]; do
dig=`hexdigit $((${val} & 15))`
str=${dig}${str}
val=$((${val} >> 4))
done
echo ${str}
}
# IPv6 startup
network6_pass1() {
@ -336,8 +367,9 @@ network6_stf_setup() {
IFS=".$IFS"
set ${stf_interface_ipv4addr}
IFS="$OIFS"
ipv4_in_hexformat=`printf "%x:%x\n" \
$(($1*256 + $2)) $(($3*256 + $4))`
hexfrag1=`hexprint $(($1*256 + $2))`
hexfrag2=`hexprint $(($3*256 + $4))`
ipv4_in_hexformat="${hexfrag1}:${hexfrag2}"
case ${stf_interface_ipv6_ifid} in
[Aa][Uu][Tt][Oo] | '')
for i in ${ipv6_network_interfaces}; do

View File

@ -32,6 +32,37 @@
# first before contemplating any changes here. If you do need to change
# this file for some reason, we would like to know about it.
hexdigit () {
if [ $1 -lt 10 ]; then
echo $1
else
case $1 in
10) echo a ;;
11) echo b ;;
12) echo c ;;
13) echo d ;;
14) echo e ;;
15) echo f ;;
esac
fi
}
hexprint () {
val=$1
str=''
dig=`hexdigit $((${val} & 15))`
str=${dig}${str}
val=$((${val} >> 4))
while [ ${val} -gt 0 ]; do
dig=`hexdigit $((${val} & 15))`
str=${dig}${str}
val=$((${val} >> 4))
done
echo ${str}
}
# IPv6 startup
network6_pass1() {
@ -336,8 +367,9 @@ network6_stf_setup() {
IFS=".$IFS"
set ${stf_interface_ipv4addr}
IFS="$OIFS"
ipv4_in_hexformat=`printf "%x:%x\n" \
$(($1*256 + $2)) $(($3*256 + $4))`
hexfrag1=`hexprint $(($1*256 + $2))`
hexfrag2=`hexprint $(($3*256 + $4))`
ipv4_in_hexformat="${hexfrag1}:${hexfrag2}"
case ${stf_interface_ipv6_ifid} in
[Aa][Uu][Tt][Oo] | '')
for i in ${ipv6_network_interfaces}; do