16f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#!/usr/bin/perl
26f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*
36f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*******************************************************************************
46f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*   Copyright (C) 2001-2012, International Business Machines
56f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*   Corporation and others.  All Rights Reserved.
66f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*******************************************************************************
76f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*
86f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*   file name:  genren.pl
96f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*   encoding:   US-ASCII
106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*   tab size:   8 (not used)
116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*   indentation:4
126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*
136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*   Created by: Vladimir Weinstein
146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*   07/19/2001
156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*
166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*  Used to generate renaming headers.
176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#*  Run on UNIX platforms (linux) in order to catch all the exports
186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orguse POSIX qw(strftime);
206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org$headername = 'urename.h';
226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org$path = substr($0, 0, rindex($0, "/")+1)."../../common/unicode/uversion.h";
246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org$nmopts = '-Cg -f s';
266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org$post = '';
276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org$mode = 'POSIX';
296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org(-e $path) || die "Cannot find uversion.h";
316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgopen(UVERSION, $path);
336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgwhile(<UVERSION>) {
356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(/\#define U_ICU_VERSION_SUFFIX/) {
366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        chop;
376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        s/\#define U_ICU_VERSION_SUFFIX //;
386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        $U_ICU_VERSION_SUFFIX = "$_";
396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        last;
406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgwhile($ARGV[0] =~ /^-/) { # detects whether there are any arguments
446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    $_ = shift @ARGV;      # extracts the argument for processing
456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /^-v/ && ($VERBOSE++, next);                      # verbose
466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /^-h/ && (&printHelpMsgAndExit, next);               # help
476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /^-o/ && (($headername = shift (@ARGV)), next);   # output file
486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /^-n/ && (($nmopts = shift (@ARGV)), next);   # nm opts
496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /^-p/ && (($post = shift (@ARGV)), next);   # nm opts
506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /^-x/ && (($mode = shift (@ARGV)), next);   # nm opts
516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /^-S/ && (($U_ICU_VERSION_SUFFIX = shift(@ARGV)), next); # pick the suffix
526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    warn("Invalid option $_\n");
536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    &printHelpMsgAndExit;
546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgunless(@ARGV > 0) {
576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    warn "No libraries, exiting...\n";
586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    &printHelpMsgAndExit;
596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#$headername = "uren".substr($ARGV[0], 6, index(".", $ARGV[0])-7).".h";
626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org$HEADERDEF = uc($headername);  # this is building the constant for #define
646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org$HEADERDEF =~ s/\./_/;
656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    open HEADER, ">$headername"; # opening a header file
686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#We will print our copyright here + warnings
706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org$YEAR = strftime "%Y",localtime;
726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprint HEADER <<"EndOfHeaderComment";
746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/*
756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*******************************************************************************
766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   Copyright (C) 2002-$YEAR, International Business Machines
776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   Corporation and others.  All Rights Reserved.
786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*******************************************************************************
796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*
806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   file name:  $headername
816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   encoding:   US-ASCII
826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   tab size:   8 (not used)
836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   indentation:4
846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*
856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   Created by: Perl script tools/genren.pl written by Vladimir Weinstein
866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*
876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*  Contains data for renaming ICU exports.
886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*  Gets included by umachine.h
896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*
906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*  THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT
916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*  YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!
926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*/
936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifndef $HEADERDEF
956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define $HEADERDEF
966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* U_DISABLE_RENAMING can be defined in the following ways:
986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *   - when running configure, e.g.
996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *        runConfigureICU Linux --disable-renaming
1006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *   - by changing the default setting of U_DISABLE_RENAMING in uconfig.h
1016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
1026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/uconfig.h"
1046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#if !U_DISABLE_RENAMING
1066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* We need the U_ICU_ENTRY_POINT_RENAME definition. There's a default one in unicode/uvernum.h we can use, but we will give
1086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org   the platform a chance to define it first.
1096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org   Normally (if utypes.h or umachine.h was included first) this will not be necessary as it will already be defined.
1106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
1116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifndef U_ICU_ENTRY_POINT_RENAME
1136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/umachine.h"
1146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
1156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* If we still don't have U_ICU_ENTRY_POINT_RENAME use the default. */
1176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifndef U_ICU_ENTRY_POINT_RENAME
1186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/uvernum.h"
1196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
1206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* Error out before the following defines cause very strange and unexpected code breakage */
1226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifndef U_ICU_ENTRY_POINT_RENAME
1236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#error U_ICU_ENTRY_POINT_RENAME is not defined - cannot continue. Consider defining U_DISABLE_RENAMING if renaming should not be used.
1246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
1256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgEndOfHeaderComment
1276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org$fileCount = 0;
1296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org$itemCount = 0;
1306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org$symbolCount = 0;
1316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgfor(;@ARGV; shift(@ARGV)) {
1336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    $fileCount++;
1346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    @NMRESULT = `nm $nmopts $ARGV[0] $post`;
1356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if($?) {
1366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        warn "Couldn't do 'nm' for $ARGV[0], continuing...\n";
1376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        next; # Couldn't do nm for the file
1386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
1396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if($mode =~ /POSIX/) {
1406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        splice @NMRESULT, 0, 6;
1416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } elsif ($mode =~ /Mach-O/) {
1426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#        splice @NMRESULT, 0, 10;
1436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
1446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    foreach (@NMRESULT) { # Process every line of result and stuff it in $_
1456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        $itemCount++;
1466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        if($mode =~ /POSIX/) {
1476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            &verbose("  $_");
1486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            ($_, $address, $type) = split(/\|/);
1496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            chop $qtype;
1506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } elsif ($mode =~ /Mach-O/) {
1516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            ($address, $type, $_) = split(/ /);
1526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            if(/^_(.*)$/) {
1536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                $_ = $1;
1546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } else {
1556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                next;
1566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            }
1576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } else {
1586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            die "Unknown mode $mode";
1596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        }
1606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        &verbose( "type: \"$type\" ");
1616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        if(!($type =~ /[UAwW?]/)) {
1626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            if(/@@/) { # These would be imports
1636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                &verbose( "Import: $_ \"$type\"\n");
1646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                &verbose( "C++ method: $_\n");
1656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } elsif (/^[^\(]*::/) { # C++ methods, stuff class name in associative array
1666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org	        ##  DON'T match    ...  (   foo::bar ...   want :: to be to the left of paren
1676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                ## icu::CharString::~CharString(void) -> CharString
1686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                @CppName = split(/::/); ## remove scope stuff
1696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                if(@CppName>1) {
1716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                    ## MessageFormat virtual table -> MessageFormat
1726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                    if(! ($CppName[0] =~ /icu/ )) {
1736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                        # *** WARNING Bad namespace (not 'icu') on ShoeSize::ShoeSize()
1746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                        warn "*** WARNING Bad namespace (not 'icu') on $_\n";
1756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                        next;
1766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                    }
1776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                    &verbose ( "(Chopping scope $CppName[0] )");
1786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                    @CppName = split(/ /, $CppName[1]); ## remove debug stuff
1796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                }
1806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                ## ures_getUnicodeStringByIndex(UResourceBundle -> ures_getUnicodeStringByIndex
1816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                @CppName = split(/\(/, $CppName[0]); ## remove function args
1826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                if($CppName[0] =~ /^operator/) {
1836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                    &verbose ("Skipping C++ function: $_\n");
1846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                } elsif($CppName[0] =~ /^~/) {
1856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                    &verbose ("Skipping C++ destructor: $_\n");
1866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                } else {
1876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                    &verbose( "Skipping C++ class: '$CppName[0]': $_ \n");
1886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                    # $CppClasses{$CppName[0]}++;
1896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                    # $symbolCount++;
1906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                }
1916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org	    } elsif ( my ($cfn) = m/^([A-Za-z0-9_]*)\(.*/ ) {
1926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org		&verbose ( "$ARGV[0]:  got global C++ function  $cfn with '$_'\n" );
1936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                $CFuncs{$cfn}++;
1946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org		$symbolCount++;
1956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } elsif ( /\(/) { # These are strange functions
1966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                print STDERR "$ARGV[0]: Not sure what to do with '$_'\n";
1976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org	    } elsif ( /^_init/ ) {
1986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org		&verbose( "$ARGV[0]: Skipped initializer $_\n" );
1996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org	    } elsif ( /^_fini/ ) {
2006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org		&verbose( "$ARGV[0]: Skipped finilizer $_\n" );
2016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } elsif ( /icu_/) {
2026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                print STDERR "$ARGV[0]: Skipped strange mangled function $_\n";
2036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } elsif ( /^vtable for /) {
2046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                print STDERR "$ARGV[0]: Skipped vtable $_\n";
2056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } elsif ( /^typeinfo/) {
2066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                print STDERR "$ARGV[0]: Skipped typeinfo $_\n";
2076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } elsif ( /operator\+/ ) {
2086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                print STDERR "$ARGV[0]: Skipped ignored function $_\n";
2096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } else { # This is regular C function
2106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                &verbose( "C func: $_\n");
2116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                @funcname = split(/[\(\s+]/);
2126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                $CFuncs{$funcname[0]}++;
2136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org		$symbolCount++;
2146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            }
2156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } else {
2166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            &verbose( "Skipped: $_ $1\n");
2176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        }
2186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
2196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
2206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgif( $fileCount == 0 ) {
2226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  die "Error: $itemCount lines from $fileCount files processed, but $symbolCount symbols were found.\n";
2236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
2246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgif( $symbolCount == 0 ) {
2266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  die "Error: $itemCount lines from $fileCount files processed, but $symbolCount symbols were found.\n";
2276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
2286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprint " Loaded $symbolCount symbols from $itemCount lines in $fileCount files.\n";
2306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprint HEADER "\n/* C exports renaming data */\n\n";
2326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgforeach(sort keys(%CFuncs)) {
2336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    print HEADER "#define $_ U_ICU_ENTRY_POINT_RENAME($_)\n";
2346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#    print HEADER "#define $_ $_$U_ICU_VERSION_SUFFIX\n";
2356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
2366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprint HEADER "\n#endif\n";
2386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprint HEADER "\n#endif\n";
2396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgclose HEADER;
2416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgsub verbose {
2436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if($VERBOSE) {
2446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        print STDERR @_;
2456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
2466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
2476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgsub printHelpMsgAndExit {
2506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    print STDERR <<"EndHelpText";
2516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgUsage: $0 [OPTIONS] LIBRARY_FILES
2526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  Options:
2536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    -v - verbose
2546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    -h - help
2556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    -o - output file name (defaults to 'urename.h'
2566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    -S - suffix (defaults to _MAJOR_MINOR of current ICU version)
2576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgWill produce a renaming .h file
2586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgEndHelpText
2606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    exit 0;
2626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
264