1 package WinVersionTranslator
;
3 # ************************************************************
4 # Description : Translate the version value for Windows.
5 # Windows can not handle letters in the version
6 # and truncates anything after \d+\.\d+. We
7 # will convert letters to numbers, retain
8 # trailing numbers and everything else will be
15 # Author : Chad Elliott
16 # Create Date : 10/7/2004
17 # ************************************************************
19 # ************************************************************
21 # ************************************************************
25 # ************************************************************
27 # ************************************************************
32 ## See if the version contains something other than numbers followed by
33 ## a decimal point and numbers.
34 if ($version =~ /^(\d+\.\d+)([^\d].*)$/) {
37 my $length = length($post);
39 ## Convert the non-conforming value to all numbers
40 for(my $i = 0; $i < $length; ++$i) {
41 my $ch = substr($post, $i, 1);
42 if ($ch =~ /[a-z]/i) {
43 my $digit = ord(lc($ch)) - ord('a');
54 ## If we have a good version number we need to make sure that the
55 ## minor version number does not exceed the value of a short unsigned
57 if ($version =~ /(\d+)\.(\d+)/) {
58 my($major, $minor) = ($1, $2);
60 while($minor > 65535) {
61 $minor = substr($minor, 0, length($minor) - 1);
63 $version = $major . '.' . $minor;