diff --git a/icu4c/source/allinone/allinone.dsw b/icu4c/source/allinone/allinone.dsw index 40b561ac5b1..204360d639b 100644 --- a/icu4c/source/allinone/allinone.dsw +++ b/icu4c/source/allinone/allinone.dsw @@ -102,6 +102,24 @@ Package=<4> ############################################################################### +Project: "gencnval"=..\tools\gencnval\gencnval.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name common + End Project Dependency + Begin Project Dependency + Project_Dep_Name toolutil + End Project Dependency +}}} + +############################################################################### + Project: "gencol"=..\tools\gencol\gencol.dsp - Package Owner=<4> Package=<5> diff --git a/icu4c/source/tools/gencnval/gencnval.c b/icu4c/source/tools/gencnval/gencnval.c new file mode 100644 index 00000000000..5107fb0b8da --- /dev/null +++ b/icu4c/source/tools/gencnval/gencnval.c @@ -0,0 +1,336 @@ +/* +******************************************************************************* +* * +* COPYRIGHT: * +* (C) Copyright International Business Machines Corporation, 1999 * +* Licensed Material - Program-Property of IBM - All Rights Reserved. * +* US Government Users Restricted Rights - Use, duplication, or disclosure * +* restricted by GSA ADP Schedule Contract with IBM Corp. * +* * +******************************************************************************* +* file name: gencnval.c +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 1999nov05 +* created by: Markus W. Scherer +* +* This program reads convrtrs.txt and writes a memory-mappable +* converter name alias table to cnvalias.dat . +*/ + +#include +#include +#include +#include "utypes.h" +#include "cmemory.h" +#include "cstring.h" +#include "filestrm.h" +#include "unewdata.h" + +#define STRING_STORE_SIZE 100000 +#define MAX_ALIAS_COUNT 2000 + +#define DATA_NAME "cnvalias" +#define DATA_TYPE "dat" + +#define DATA_COPYRIGHT "\n" \ + "*******************************************************************************\n" \ + "* COPYRIGHT: *\n" \ + "* (C) Copyright International Business Machines Corporation, 1999 *\n" \ + "* Licensed Material - Program-Property of IBM - All Rights Reserved. *\n" \ + "* US Government Users Restricted Rights - Use, duplication, or disclosure *\n" \ + "* restricted by GSA ADP Schedule Contract with IBM Corp. *\n" \ + "*******************************************************************************\n" + +/* UDataInfo cf. udata.h */ +static const UDataInfo dataInfo={ + sizeof(UDataInfo), + 0, + + U_IS_BIG_ENDIAN, + U_CHARSET_FAMILY, + sizeof(UChar), + 0, + + 0x43, 0x76, 0x41, 0x6c, /* dataFormat="CvAl" */ + 1, 0, 0, 0, /* formatVersion */ + 1, 3, 1, 0 /* dataVersion */ +}; + +static char stringStore[STRING_STORE_SIZE]; +static uint32_t stringTop=0; + +typedef struct { + const char *alias, *converter; +} Alias; + +static Alias aliases[MAX_ALIAS_COUNT]; +static uint16_t aliasCount=0; + +typedef struct { + const char *converter; + uint16_t aliasCount; +} Converter; + +static Converter converters[MAX_ALIAS_COUNT]; +static uint16_t converterCount=0; + +/* prototypes --------------------------------------------------------------- */ + +static void +parseLine(const char *line); + +static void +addAlias(const char *alias, const char *converter); + +static Converter * +addConverter(const char *converter); + +static char * +allocString(uint32_t length); + +static int +compareAliases(const void *file1, const void *file2); + +static int +compareConverters(const void *converter1, const void *converter2); + +/* -------------------------------------------------------------------------- */ + +extern int +main(int argc, char *argv[]) { + char line[512]; + const char *path, *arg; + FileStream *in; + UNewDataMemory *out; + char *s; + UErrorCode errorCode=U_ZERO_ERROR; + int i; + uint16_t stringOffset; + bool_t haveCopyright=TRUE; + + fprintf(stderr, + "usage: %s [-c[+|-]]\n" + "\tread convrtrs.txt and create " DATA_NAME "." DATA_TYPE "\n" + "\t\t-c[+|-] do (not) include a copyright notice\n", + argv[0]); + + for(i=1; i0) { + *s++=icu_tolower(line[start++]); + --length; + } + *s=0; + + /* add the alias/converter pair to the alias table */ + addAlias(alias, converter); + + /* get all the real aliases */ + for(;;) { + /* skip white space */ + while(line[pos]!=0 && isspace((unsigned char)line[pos])) { + ++pos; + } + + /* is there no more alias name on this line? */ + if(line[pos]==0 || line[pos]=='#') { + break; + } + + /* get an alias name */ + start=pos; + while(line[pos]!=0 && line[pos]!='#' && !isspace((unsigned char)line[pos])) { + ++pos; + } + limit=pos; + + /* store the alias name in lowercase */ + length=limit-start; + alias=s=allocString(length+1); + while(length>0) { + *s++=icu_tolower(line[start++]); + --length; + } + *s=0; + + /* add the alias/converter pair to the alias table */ + addAlias(alias, converter); + + /* count it for the converter */ + ++cnv->aliasCount; + + } +} + +static void +addAlias(const char *alias, const char *converter) { + if(aliasCount==MAX_ALIAS_COUNT) { + fprintf(stderr, "gencnval: too many aliases\n"); + exit(U_BUFFER_OVERFLOW_ERROR); + } + + aliases[aliasCount].alias=alias; + aliases[aliasCount].converter=converter; + + ++aliasCount; +} + +static Converter * +addConverter(const char *converter) { + if(converterCount==MAX_ALIAS_COUNT) { + fprintf(stderr, "gencnval: too many converters\n"); + exit(U_BUFFER_OVERFLOW_ERROR); + } + + converters[converterCount].converter=converter; + converters[converterCount].aliasCount=0; + + ++converterCount; + + return converters+converterCount-1; +} + +static char * +allocString(uint32_t length) { + uint32_t top=stringTop+length; + char *p; + + if(top>STRING_STORE_SIZE) { + fprintf(stderr, "gencnval: out of memory\n"); + exit(U_MEMORY_ALLOCATION_ERROR); + } + p=stringStore+stringTop; + stringTop=top; + return p; +} + +static int +compareAliases(const void *alias1, const void *alias2) { + return icu_strcmp(((Alias *)alias1)->alias, ((Alias *)alias2)->alias); +} + +static int +compareConverters(const void *converter1, const void *converter2) { + return icu_strcmp(((Converter *)converter1)->converter, ((Converter *)converter2)->converter); +} diff --git a/icu4c/source/tools/gencnval/gencnval.dsp b/icu4c/source/tools/gencnval/gencnval.dsp new file mode 100644 index 00000000000..d9656407b6f --- /dev/null +++ b/icu4c/source/tools/gencnval/gencnval.dsp @@ -0,0 +1,102 @@ +# Microsoft Developer Studio Project File - Name="gencnval" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=gencnval - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "gencnval.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "gencnval.mak" CFG="gencnval - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "gencnval - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "gencnval - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "gencnval - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\common" /I "..\toolutil" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 toolutil.lib icuuc.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\toolutil\Release" /libpath:"..\..\..\lib\Release" + +!ELSEIF "$(CFG)" == "gencnval - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\common" /I "..\toolutil" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 toolutil.lib icuuc.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\toolutil\Debug" /libpath:"..\..\..\lib\Debug" + +!ENDIF + +# Begin Target + +# Name "gencnval - Win32 Release" +# Name "gencnval - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\gencnval.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/icu4c/source/tools/makedata.bat b/icu4c/source/tools/makedata.bat index 10a00a39249..a30a4cbeb43 100755 --- a/icu4c/source/tools/makedata.bat +++ b/icu4c/source/tools/makedata.bat @@ -30,16 +30,22 @@ echo create unames.dat and unames_dat.c from UnicodeData.txt gennames\%toolversion%\gennames -v- -c- "%ICU_DATA%UnicodeData-3.0.0.txt" genccode\%toolversion%\genccode "%ICU_DATA%unames.dat" +echo create cnvalias.dat and cnvalias_dat.c from convrtrs.txt +gencnval\%toolversion%\gencnval -c- +genccode\%toolversion%\genccode "%ICU_DATA%cnvalias.dat" + echo create the data DLL -cl "/I..\..\include" /GD /c "%ICU_DATA%unames_dat.c" +cl "/I..\..\include" /GD /c "%ICU_DATA%unames_dat.c" "%ICU_DATA%cnvalias_dat.c" echo "/out:%ICU_DATA%icudata.dll">mkdll.tmp echo unames_dat.obj>>mkdll.tmp +echo cnvalias_dat.obj>>mkdll.tmp type mkdll.lk>>mkdll.tmp link @mkdll.tmp echo create the common, memory-mappable file del "%ICU_DATA%icudata.dat" echo %ICU_DATA%unames.dat>mkmap.tmp +echo %ICU_DATA%cnvalias.dat>mkmap.tmp gencmn\%toolversion%\gencmn 1000000 mkmap.tmp goto :end