#! /bin/awk -f
#
# |-----------------------------------------------------------|
# | Copyright (c) 1991, 1990 MIPS Computer Systems, Inc.      |
# | All Rights Reserved                                       |
# |-----------------------------------------------------------|
# |          Restricted Rights Legend                         |
# | Use, duplication, or disclosure by the Government is      |
# | subject to restrictions as set forth in                   |
# | subparagraph (c)(1)(ii) of the Rights in Technical        |
# | Data and Computer Software Clause of DFARS 252.227-7013.  |
# |         MIPS Computer Systems, Inc.                       |
# |         950 DeGuigne Avenue                               |
# |         Sunnyvale, California 94088-3650, USA             |
# |-----------------------------------------------------------|
#
# $Header: version.awk,v 1.3.2.1 92/06/24 13:39:24 marker Exp $
BEGIN {
	maxfields = 4;
	max = 0; strmax = "";
	for (i = 1; i <= maxfields; i++) {
		power[i] = exp(log(10)*(maxfields-i));
	}
}
{
	if (NF >= 3) {
		version = "";
		if ( $3 == "*rcsid" ) {
			version = $7;
		} 
		if ( $2 == "*" ) {
			version = $5;
		}
		if ( version == "" ) {
			continue;
		}
		sum = 0;
		num = split(version, string, ".")
		for (i = 1; i <= num; i++) {
			sum += string[i]*power[i];
		}
		if ( sum > max ) {
			max = sum;
			strmax = version;
		}
	}
}
END {
	print "char *version = \"" strmax "\";" > "version.c"
	print "Gated version is " strmax "."
}
