X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..d5d484b0fbe924d3663b177965538d517ee412c1:/icuSources/tools/gentest/gentest.c diff --git a/icuSources/tools/gentest/gentest.c b/icuSources/tools/gentest/gentest.c index 9365efab..b65bd0bf 100644 --- a/icuSources/tools/gentest/gentest.c +++ b/icuSources/tools/gentest/gentest.c @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1999-2001, International Business Machines +* Copyright (C) 1999-2006, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -20,13 +20,14 @@ #include #include "unicode/utypes.h" #include "unicode/putil.h" +#include "unicode/uclean.h" #include "unicode/udata.h" #include "unewdata.h" #include "cmemory.h" #include "cstring.h" #include "uoptions.h" +#include "gentest.h" -#define DATA_PKG "testdata" #define DATA_NAME "test" #define DATA_TYPE "icu" @@ -45,16 +46,19 @@ static const UDataInfo dataInfo={ {1, 0, 0, 0} /* dataVersion */ }; -static void createData(const char*); +static void createData(const char*, UErrorCode *); static UOption options[]={ - UOPTION_HELP_H, - UOPTION_HELP_QUESTION_MARK, - UOPTION_DESTDIR + /*0*/ UOPTION_HELP_H, + /*1*/ UOPTION_HELP_QUESTION_MARK, + /*2*/ UOPTION_DESTDIR, + /*3*/ UOPTION_DEF("genres", 'r', UOPT_NO_ARG) }; extern int main(int argc, char* argv[]) { + UErrorCode errorCode = U_ZERO_ERROR; + /* preset then read command line options */ options[2].value=u_getDataDirectory(); argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options); @@ -68,35 +72,39 @@ main(int argc, char* argv[]) { if(argc<0 || options[0].doesOccur || options[1].doesOccur) { fprintf(stderr, "usage: %s [-options]\n" - "\tcreate the test file " DATA_PKG "_" DATA_NAME "." DATA_TYPE "\n" + "\tcreate the test file " DATA_NAME "." DATA_TYPE " unless the -r option is given.\n" "\toptions:\n" "\t\t-h or -? or --help this usage text\n" - "\t\t-d or --destdir destination directory, followed by the path\n", + "\t\t-d or --destdir destination directory, followed by the path\n" + "\t\t-r or --genres generate resource file testtable32.txt instead of UData test \n", argv[0]); return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; } - /* printf("Generating the test memory mapped file\n"); */ - createData(options[2].value); - return 0; + if ( options[3].doesOccur ) { + return genres32( argv[0], options[2].value ); + } else { + /* printf("Generating the test memory mapped file\n"); */ + createData(options[2].value, &errorCode); + } + return U_FAILURE(errorCode); } /* Create data file ----------------------------------------------------- */ static void -createData(const char* outputDirectory) { +createData(const char* outputDirectory, UErrorCode *errorCode) { UNewDataMemory *pData; - UErrorCode errorCode=U_ZERO_ERROR; char stringValue[]={'Y', 'E', 'A', 'R', '\0'}; uint16_t intValue=2000; long dataLength; uint32_t size; - pData=udata_create(outputDirectory, DATA_TYPE, DATA_PKG "_" DATA_NAME, &dataInfo, - U_COPYRIGHT_STRING, &errorCode); - if(U_FAILURE(errorCode)) { - fprintf(stderr, "gentest: unable to create data memory, error %d\n", errorCode); - exit(errorCode); + pData=udata_create(outputDirectory, DATA_TYPE, DATA_NAME, &dataInfo, + U_COPYRIGHT_STRING, errorCode); + if(U_FAILURE(*errorCode)) { + fprintf(stderr, "gentest: unable to create data memory, error %d\n", *errorCode); + exit(*errorCode); } /* write the data to the file */ @@ -105,10 +113,10 @@ createData(const char* outputDirectory) { udata_writeString(pData, stringValue, sizeof(stringValue)); /* finish up */ - dataLength=udata_finish(pData, &errorCode); - if(U_FAILURE(errorCode)) { - fprintf(stderr, "gentest: error %d writing the output file\n", errorCode); - exit(errorCode); + dataLength=udata_finish(pData, errorCode); + if(U_FAILURE(*errorCode)) { + fprintf(stderr, "gentest: error %d writing the output file\n", *errorCode); + exit(*errorCode); } size=sizeof(stringValue) + sizeof(intValue);