Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/conf It is silly to parse the comment in the header file...



details:   https://anonhg.NetBSD.org/src/rev/d1171bf3a12c
branches:  trunk
changeset: 579837:d1171bf3a12c
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Mar 27 23:27:31 2005 +0000

description:
It is silly to parse the comment in the header file to determine the
version number, when it is trivial to compute it directly. Also if
you are going to fork awk to do some work, do all of it there.

diffstat:

 sys/conf/osrelease.sh |  23 ++++++++---------------
 1 files changed, 8 insertions(+), 15 deletions(-)

diffs (36 lines):

diff -r 214cc7d54ef2 -r d1171bf3a12c sys/conf/osrelease.sh
--- a/sys/conf/osrelease.sh     Sun Mar 27 23:12:55 2005 +0000
+++ b/sys/conf/osrelease.sh     Sun Mar 27 23:27:31 2005 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-#      $NetBSD: osrelease.sh,v 1.108 2004/09/14 15:19:35 simonb Exp $
+#      $NetBSD: osrelease.sh,v 1.109 2005/03/27 23:27:31 christos Exp $
 #
 # Copyright (c) 1997 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -38,17 +38,10 @@
 #
 
 # We use the number specified in <sys/param.h>
-
-AWK=${AWK:-awk}
-GREP=${GREP:-grep}
-PARAMH="`dirname $0`"/../sys/param.h
-release=`$AWK '/^#define[      ]*__NetBSD_Version__/ { print $6 }' $PARAMH`
-
-case $1 in
--s)
-       echo $release | sed -e 's,\.,,g'
-       ;;
-*)
-       echo $release
-       ;;
-esac
+${AWK:-awk} -v FLAG="$1" '
+/^#define[     ]*__NetBSD_Version__/ {
+       major = ($3 / 100000000);
+       minor = ($3 / 1000000) % 100;
+       patch = ($3 / 100) % 100;
+       printf((FLAG == "-s") ? "%d%d%d\n" : "%d.%d.%d\n", major, minor, patch);
+}' "$(dirname $0)"/../sys/param.h



Home | Main Index | Thread Index | Old Index