From b1c0dd5ffcb696b646b1ea9a8c6b05cdbe165b32 Mon Sep 17 00:00:00 2001 From: dsl Date: Fri, 9 Mar 2007 19:16:47 +0000 Subject: [PATCH] Replace hexprint with a version that is much faster for values > 15. Since I managed to commit my alternate scheme for zeropad, delete the commented out lines and replace the only other use. I've not deleted the function itself though. --- etc/MAKEDEV.tmpl | 23 +++++++++-------------- etc/etc.vax/MAKEDEV.conf | 5 +++-- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/etc/MAKEDEV.tmpl b/etc/MAKEDEV.tmpl index fd6ce9334631..b0ada6feb49a 100644 --- a/etc/MAKEDEV.tmpl +++ b/etc/MAKEDEV.tmpl @@ -1,5 +1,5 @@ #!/bin/sh - -# $NetBSD: MAKEDEV.tmpl,v 1.80 2007/03/09 13:57:54 dsl Exp $ +# $NetBSD: MAKEDEV.tmpl,v 1.81 2007/03/09 19:16:47 dsl Exp $ # # Copyright (c) 2003,2007 The NetBSD Foundation, Inc. # All rights reserved. @@ -340,16 +340,14 @@ zeropad() # hexprint() { - case $1 in - [0-9]) echo $1 ;; - 10) echo a ;; - 11) echo b ;; - 12) echo c ;; - 13) echo d ;; - 14) echo e ;; - 15) echo f ;; - *) echo $(hexprint $(($1 / 16)))$(hexprint $(($1 % 16))) ;; - esac + val="$(($1 + 0))" + hex= + set -- 0 1 2 3 4 5 6 7 8 9 a b c d e f + while [ "$val" -gt 0 ]; do + eval hex=\$$(($val % 16 + 1))\$hex + val="$(($val / 16))" + done + echo "${hex:-0}" } setup() @@ -791,7 +789,6 @@ ttyCY*) eminor=$(($minor + $off)) while [ $minor -lt $eminor ] do - # nminor=$(zeropad 3 $minor) nminor=000$minor nminor=${nminor#${nminor%???}} mkdev t$name$nminor c $chr $(($minor + $dialin )) "" "" $u_uucp @@ -807,7 +804,6 @@ ttyCZ*) eminor=$(($minor + $off)) while [ $minor -lt $eminor ] do - # nminor=$(zeropad 4 $minor) nminor=0000$minor nminor=${nminor#${nminor%????}} mkdev t$name$nminor c $chr $(($minor + $dialin )) "" "" $u_uucp @@ -830,7 +826,6 @@ tty[0-9]|tty0[0-9]) tty0*|tty1*|tty[0-9]) unit=${i#tty} - # ounit=$(zeropad 2 $unit) ounit=00$unit ounit=${ounit#${ounit%??}} mkdev tty$ounit c %com_chr% $(($unit + $dialin )) "" "" $u_uucp diff --git a/etc/etc.vax/MAKEDEV.conf b/etc/etc.vax/MAKEDEV.conf index 599dcc0aa461..19b54bda86cf 100644 --- a/etc/etc.vax/MAKEDEV.conf +++ b/etc/etc.vax/MAKEDEV.conf @@ -1,4 +1,4 @@ -# $NetBSD: MAKEDEV.conf,v 1.10 2007/01/15 23:35:12 hubertf Exp $ +# $NetBSD: MAKEDEV.conf,v 1.11 2007/03/09 19:16:48 dsl Exp $ all_md) makedev mt0 mt1 ts0 ts1 st0 st1 uk0 ss0 cd0 vt0 @@ -96,7 +96,8 @@ dz*) while [ $i -lt 8 ] do oi=$(($unit * 8 + $i)) - zoi=$(zeropad 2 $oi) + zoi=00$oi + zoi=${zoi#${zoi%??}} mkdev tty$zoi c 1 $oi i=$(($i + 1)) done