$headername = 'urename.h';
$path = substr($0, 0, rindex($0, "/")+1)."../../common/unicode/uversion.h";
(-e $path) || die "Cannot find uversion.h";
open(UVERSION, $path);
while(<UVERSION>) {
if(/\ chop;
s/\ $U_ICU_VERSION_SUFFIX = "$_";
last;
}
}
while($ARGV[0] =~ /^-/) { $_ = shift @ARGV; /^-v/ && ($VERBOSE++, next); /^-h/ && (&printHelpMsgAndExit, next); /^-o/ && (($headername = shift (@ARGV)), next); /^-S/ && (($U_ICU_VERSION_SUFFIX = shift(@ARGV)), next); warn("Invalid option $_\n");
&printHelpMsgAndExit;
}
unless(@ARGV > 0) {
warn "No libraries, exiting...\n";
&printHelpMsgAndExit;
}
$HEADERDEF = uc($headername); $HEADERDEF =~ s/\./_/;
open HEADER, ">$headername";
print HEADER <<"EndOfHeaderComment";
/*
*******************************************************************************
* Copyright (C) 2002-2004, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*
* file name: $headername
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
*
* Created by: Perl script written by Vladimir Weinstein
*
* Contains data for renaming ICU exports.
* Gets included by umachine.h
*
* THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT
* YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!
*/
/* Uncomment the following line to disable renaming on platforms
that do not use Autoconf. */
/*
EndOfHeaderComment
for(;@ARGV; shift(@ARGV)) {
@NMRESULT = `nm -Cg -f s $ARGV[0]`;
if($?) {
warn "Couldn't do 'nm' for $ARGV[0], continuing...\n";
next; }
splice @NMRESULT, 0, 6;
foreach (@NMRESULT) { ($_, $address, $type) = split(/\|/);
&verbose( "type: \"$type\" ");
if(!($type =~ /[UAwW?]/)) {
if(/@@/) { &verbose( "Import: $_ \"$type\"\n");
} elsif (/::/) { &verbose( "C++ method: $_\n");
@CppName = split(/::/); if(@CppName>1) {
@CppName = split(/ /, $CppName[1]); }
@CppName = split(/\(/, $CppName[0]); $CppClasses{$CppName[0]}++;
} elsif ( /\(/) { print STDERR "$_\n";
} elsif ( /icu_/) {
print STDERR "Skipped strange mangled function $_\n";
} else { &verbose( "C func: $_\n");
@funcname = split(/[\(\s+]/);
$CFuncs{$funcname[0]}++;
}
} else {
&verbose( "Skipped: $_ $1\n");
}
}
}
print HEADER "\n/* C exports renaming data */\n\n";
foreach(sort keys(%CFuncs)) {
print HEADER "#define $_ $_$U_ICU_VERSION_SUFFIX\n";
}
print HEADER "/* C++ class names renaming defines */\n\n";
print HEADER "#ifdef XP_CPLUSPLUS\n";
print HEADER "#if !U_HAVE_NAMESPACE\n\n";
foreach(sort keys(%CppClasses)) {
print HEADER "#define $_ $_$U_ICU_VERSION_SUFFIX\n";
}
print HEADER "\n#endif\n";
print HEADER "#endif\n";
print HEADER "\n#endif\n";
print HEADER "\n#endif\n";
close HEADER;
sub verbose {
if($VERBOSE) {
print STDERR @_;
}
}
sub printHelpMsgAndExit {
print STDERR <<"EndHelpText";
Usage: $0 [OPTIONS] LIBRARY_FILES
Options:
-v - verbose
-h - help
-o - output file name (defaults to 'urename.h'
-S - suffix (defaults to _MAJOR_MINOR of current ICU version)
Will produce a renaming .h file
EndHelpText
exit 0;
}