138494Sobrien#!@PERL@
238494Sobrien#
338494Sobrien# fix an old-syntax amd map to new one
438494Sobrien#
538494Sobrien# takes any number of files on the command line, and produces
638494Sobrien# a fixed map on stdout.
738494Sobrien#
8174294Sobrien# Package:	am-utils-6.x
938494Sobrien# Author:	Erez Zadok <ezk@cs.columbia.edu>
1038494Sobrien#
1138494Sobrien
1238494Sobrien##############################################################################
1338494Sobrien### MAINTAINER EDITABLE SECTION
1438494Sobrien
1538494Sobrien# Mappings of old names to new ones:
1638494Sobrien# Update when needed, do not forget commas but not on the last entry!
1738494Sobrien# For your convenience, this is the complete list of all OSs that were
1838494Sobrien# supported by amd-upl102, in their old names:
1938494Sobrien#
2038494Sobrien#	386bsd acis43 aix3 aoi aux bsd43 bsd44 bsdi11
2138494Sobrien#	concentrix dgux fpx4 freebsd hcx hlh42 hpux irix3 irix4 irix5 isc3
2238494Sobrien#	linux mach2 mach3 netbsd news4 next osf1 pyrOSx riscix riscos
2338494Sobrien#	rtu6 sos3 sos4 sos5 stellix svr4 u2_2 u3_0 u4_0 u4_2 u4_3 u4_4
2438494Sobrien#	umax43 utek utx32 xinu43
2538494Sobrien#
2638494Sobrien%mappings = (
2738494Sobrien	"sos4",		"sunos4",
2838494Sobrien	"sos5",		"sunos5",
2938494Sobrien	"freebsd",	"freebsd2"
3038494Sobrien);
3138494Sobrien
3238494Sobrien##############################################################################
3338494Sobrien### DO NOT EDIT ANYTHING BELOW
3438494Sobrien
3538494Sobrien# This is a trivial parser and works as follows:
3638494Sobrien# (1) read each line
3738494Sobrien# (2) search of regexps that start with '=', continue with a word to replace
3838494Sobrien#     and end with a non-value name (whitespace, ';', or newline
3938494Sobrienwhile (<>) {
4038494Sobrien    # skip trivial lines
4138494Sobrien    if ($_ =~ /^$/  ||  $_ =~ /^#/) {
4238494Sobrien	print;
4338494Sobrien	next;
4438494Sobrien    }
4538494Sobrien    # modify the line if needed
4638494Sobrien    foreach $m (keys %mappings) {
4738494Sobrien	$val = $mappings{$m};
4838494Sobrien	$_ =~ s/=$m([^a-zA-Z0-9_])/=$val$1/g;
4938494Sobrien    }
5038494Sobrien    # print the (possibly) modified line
5138494Sobrien    print;
5238494Sobrien}
53