unified build scheme: add a "unified" template for VMS descrip.mms
[openssl.git] / VMS / translatesyms.pl
1 #! /usr/bin/perl
2
3 # This script will translate any SYMBOL_VECTOR item that has a translation
4 # in CXX$DEMANGLER_DB.  The latter is generated by and CC/DECC command that
5 # uses the qualifier /REPOSITORY with the build directory as value.  When
6 # /NAMES=SHORTENED has been used, this file will hold the translations from
7 # the original symbols to the shortened variants.
8 #
9 # CXX$DEMAGLER_DB. is an ISAM file, but with the magic of RMS, it can be
10 # read as a text file, with each record as one line.
11 #
12 # The lines will have the following syntax for any symbol found that's longer
13 # than 31 characters:
14 #
15 # LONG_symbol_34567890123{cksum}$LONG_symbol_34567890123_more_than_31_chars
16 #
17 # $ is present at the end of the shortened symbol name, and is preceded by a
18 # 7 character checksum.  The $ makes it easy to separate the shortened name
19 # from the original one.
20
21 use strict;
22 use warnings;
23
24 usage() if scalar @ARGV < 1;
25
26 my %translations = ();
27
28 open DEMANGLER_DATA, $ARGV[0]
29     or die "Couldn't open $ARGV[0]: $!\n";
30 while(<DEMANGLER_DATA>) {
31     chomp;
32     (my $translated, my $original) = split /\$/;
33     $translations{$original} = $translated.'$';
34 }
35 close DEMANGLER_DATA;
36
37 $| = 1;                         # Autoflush
38 while(<STDIN>) {
39     s@
40       ((?:[A-Za-z0-9_]+)\/)?([A-Za-z0-9_]+)=(PROCEDURE|DATA)
41      @
42       if (defined($translations{$2})) {
43           my $trans = $translations{$2};
44           my $trans_uc = uc $trans;
45           if (defined($1) && $trans ne $trans_uc) {
46               "$trans_uc/$trans=$3"
47           } else {
48               "$trans=$3"
49           }
50       } else {
51           $&
52       }
53      @gxe;
54     print $_;
55 }