diff --git a/icu4c/source/i18n/tzdat.h b/icu4c/source/i18n/tzdat.h index afb302d2b58..c1d3f5ea6a2 100644 --- a/icu4c/source/i18n/tzdat.h +++ b/icu4c/source/i18n/tzdat.h @@ -15,8 +15,6 @@ #include "unicode/utypes.h" -#if !UCONFIG_NO_FORMATTING - /* This file defines the format of the memory-mapped data file * containing system time zone data for icu. See also gentz * and tz.pl. @@ -67,6 +65,8 @@ #define TZ_DATA_NAME "tz" #define TZ_DATA_TYPE "icu" +#if !UCONFIG_NO_FORMATTING + // Fields in UDataInfo: // TZ_SIG[] is encoded as numeric literals for compatibility with the HP compiler diff --git a/icu4c/source/i18n/ucol_imp.h b/icu4c/source/i18n/ucol_imp.h index 8c047016d5d..3a4e9ec0e68 100644 --- a/icu4c/source/i18n/ucol_imp.h +++ b/icu4c/source/i18n/ucol_imp.h @@ -28,6 +28,11 @@ #include "unicode/utypes.h" +#define UCA_DATA_TYPE "icu" +#define UCA_DATA_NAME "ucadata" +#define INVC_DATA_TYPE "icu" +#define INVC_DATA_NAME "invuca" + #if !UCONFIG_NO_COLLATION #include "unicode/ucol.h" @@ -408,11 +413,6 @@ ucol_cloneRuleData(const UCollator *coll, int32_t *length, UErrorCode *status); #define getExpansionSuffix(coleiter) ((coleiter)->iteratordata_.CEpos - (coleiter)->iteratordata_.toReturn) #define setExpansionSuffix(coleiter, offset) ((coleiter)->iteratordata_.toReturn = (coleiter)->iteratordata_.CEpos - leftoverces) -#define UCA_DATA_TYPE "icu" -#define UCA_DATA_NAME "ucadata" -#define INVC_DATA_TYPE "icu" -#define INVC_DATA_NAME "invuca" - /* This is an enum that lists magic special byte values from the fractional UCA */ /* TODO: all the #defines that refer to special byte values from the UCA should be changed to point here */ diff --git a/icu4c/source/tools/genbrk/genbrk.cpp b/icu4c/source/tools/genbrk/genbrk.cpp index f5df4d15aca..1937247142a 100644 --- a/icu4c/source/tools/genbrk/genbrk.cpp +++ b/icu4c/source/tools/genbrk/genbrk.cpp @@ -28,17 +28,6 @@ #include #include "unicode/utypes.h" - -#if UCONFIG_NO_BREAK_ITERATION - -extern int -main(int argc, const char *argv[]) { - fprintf(stderr, "genbrk performs no-op because of UCONFIG_NO_BREAK_ITERATION, see uconfig.h\n"); - return 0; -} - -#else - #include "unicode/ucnv.h" #include "unicode/unistr.h" #include "unicode/rbbi.h" @@ -46,10 +35,14 @@ main(int argc, const char *argv[]) { #include "unicode/udata.h" #include "uoptions.h" +#include "unewdata.h" #include "ucmndata.h" #include #include +#include + +#define DATA_TYPE "brk" static char *progName; static UOption options[]={ @@ -66,6 +59,49 @@ void usageAndDie(int retCode) { exit (retCode); } + +#if UCONFIG_NO_BREAK_ITERATION + +/* dummy UDataInfo cf. udata.h */ +static UDataInfo dummyDataInfo = { + sizeof(UDataInfo), + 0, + + U_IS_BIG_ENDIAN, + U_CHARSET_FAMILY, + U_SIZEOF_UCHAR, + 0, + + { 0, 0, 0, 0 }, /* dummy dataFormat */ + { 0, 0, 0, 0 }, /* dummy formatVersion */ + { 0, 0, 0, 0 } /* dummy dataVersion */ +}; + +#else + +// +// Set up the ICU data header, defined in ucmndata.h +// +DataHeader dh ={ + {sizeof(DataHeader), // Struct MappedData + 0xda, + 0x27}, + + { // struct UDataInfo + sizeof(UDataInfo), // size + 0, // reserved + U_IS_BIG_ENDIAN, + U_CHARSET_FAMILY, + U_SIZEOF_UCHAR, + 0, // reserved + + { 0x42, 0x72, 0x6b, 0x20 }, // dataFormat="Brk " + { 2, 1, 0, 0 }, // formatVersion + { 3, 1, 0, 0 } // dataVersion (Unicode version) + }}; + +#endif + //---------------------------------------------------------------------------- // // main for genbrk @@ -105,6 +141,44 @@ int main(int argc, char **argv) { u_setDataDirectory(options[5].value); } +#if UCONFIG_NO_BREAK_ITERATION + + UNewDataMemory *pData; + char msg[2048], folder[2048], name[32]; + char *basename; + int length; + + /* split the outFileName into folder + name + type */ + strcpy(folder, outFileName); + basename = strrchr(folder, U_FILE_SEP_CHAR); + if(basename == NULL) { + basename = folder; + } else { + ++basename; + } + + /* copy the data name and remove it from the folder */ + strcpy(name, basename); + *basename = 0; + + /* write message with just the name */ + sprintf(msg, "genbrk writes dummy %s because of UCONFIG_NO_BREAK_ITERATION, see uconfig.h", name); + fprintf(stderr, "%s\n", msg); + + /* remove the type suffix (hardcode to DATA_TYPE) */ + length = strlen(name); + if(length > 4 && name[length - 4] == '.') { + name[length - 4] = 0; + } + + /* write the dummy data file */ + pData = udata_create(folder, DATA_TYPE, name, &dummyDataInfo, NULL, &status); + udata_writeBlock(pData, msg, strlen(msg)); + udata_finish(pData, &status); + return (int)status; + +#else + // // Read in the rule source file // @@ -224,27 +298,6 @@ int main(int argc, char **argv) { exit(-1); } - - // - // Set up the ICU data header, defined in ucmndata.h - // - DataHeader dh ={ - {sizeof(DataHeader), // Struct MappedData - 0xda, - 0x27}, - - { // struct UDataInfo - sizeof(UDataInfo), // size - 0, // reserved - U_IS_BIG_ENDIAN, - U_CHARSET_FAMILY, - U_SIZEOF_UCHAR, - 0, // reserved - - { 0x42, 0x72, 0x6b, 0x20 }, // dataFormat="Brk " - { 2, 1, 0, 0 }, // formatVersion - { 3, 1, 0, 0 } // dataVersion (Unicode version) - }}; bytesWritten = fwrite(&dh, 1, sizeof(DataHeader), file); // @@ -265,6 +318,6 @@ int main(int argc, char **argv) { printf("genbrk: tool completed successfully.\n"); return 0; -} #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ +} diff --git a/icu4c/source/tools/gentz/gentz.cpp b/icu4c/source/tools/gentz/gentz.cpp index 95e993ec833..824b1ad4fe5 100644 --- a/icu4c/source/tools/gentz/gentz.cpp +++ b/icu4c/source/tools/gentz/gentz.cpp @@ -28,17 +28,6 @@ #include #include #include "unicode/utypes.h" - -#if UCONFIG_NO_FORMATTING - -extern int -main(int argc, const char *argv[]) { - fprintf(stderr, "gentz performs no-op because of UCONFIG_NO_FORMATTING, see uconfig.h\n"); - return 0; -} - -#else - #include "unicode/putil.h" #include "cmemory.h" #include "cstring.h" @@ -50,6 +39,25 @@ main(int argc, const char *argv[]) { #define INPUT_FILE "tz.txt" #define OUTPUT_FILE "tz.icu" +#if UCONFIG_NO_FORMATTING + +/* dummy UDataInfo cf. udata.h */ +static UDataInfo dummyDataInfo = { + sizeof(UDataInfo), + 0, + + U_IS_BIG_ENDIAN, + U_CHARSET_FAMILY, + U_SIZEOF_UCHAR, + 0, + + { 0, 0, 0, 0 }, /* dummy dataFormat */ + { 0, 0, 0, 0 }, /* dummy formatVersion */ + { 0, 0, 0, 0 } /* dummy dataVersion */ +}; + +#else + /* UDataInfo cf. udata.h */ static UDataInfo dataInfo = { sizeof(UDataInfo), @@ -65,6 +73,7 @@ static UDataInfo dataInfo = { {0, 0, 0, 0} /* dataVersion - will be filled in with year.suffix */ }; +#endif class gentz { // These must match SimpleTimeZone!!! @@ -94,6 +103,7 @@ class gentz { static const char* END_KEYWORD; +#if! UCONFIG_NO_FORMATTING enum { BUFLEN = 1024 }; char buffer[BUFLEN]; int32_t lineNumber; @@ -115,6 +125,7 @@ class gentz { uint32_t maxPerOffset; // Maximum number of zones per offset uint32_t maxPerEquiv; // Maximum number of zones per equivalency group uint32_t equivCount; // Number of equivalency groups +#endif UBool useCopyright; UBool verbose; @@ -122,6 +133,8 @@ class gentz { public: int MMain(int argc, char *argv[]); + +#if! UCONFIG_NO_FORMATTING private: int32_t writeTzDatFile(const char *destdir); void parseTzTextFile(FileStream* in); @@ -150,6 +163,7 @@ private: // Error handling void die(const char* msg); +#endif }; int main(int argc, char *argv[]) { @@ -212,6 +226,20 @@ int gentz::MMain(int argc, char* argv[]) { useCopyright=options[2].doesOccur; verbose = options[4].doesOccur; +#if UCONFIG_NO_FORMATTING + + UNewDataMemory *pData; + const char *msg = "gentz writes dummy " U_ICUDATA_NAME "_" TZ_DATA_NAME "." TZ_DATA_TYPE " because of UCONFIG_NO_FORMATTING, see uconfig.h"; + UErrorCode status = U_ZERO_ERROR; + + fprintf(stderr, "%s\n", msg); + pData = udata_create(options[3].value, TZ_DATA_TYPE, U_ICUDATA_NAME "_" TZ_DATA_NAME, &dummyDataInfo, + NULL, &status); + udata_writeBlock(pData, msg, strlen(msg)); + udata_finish(pData, &status); + return (int)status; + +#else //////////////////////////////////////////////////////////// // Read the input file @@ -239,8 +267,12 @@ int gentz::MMain(int argc, char* argv[]) { } return 0; // success + +#endif } +#if !UCONFIG_NO_FORMATTING + int32_t gentz::writeTzDatFile(const char *destdir) { UNewDataMemory *pdata; UErrorCode status = U_ZERO_ERROR; diff --git a/icu4c/source/tools/genuca/genuca.cpp b/icu4c/source/tools/genuca/genuca.cpp index a5c932c187b..2be99fdb848 100644 --- a/icu4c/source/tools/genuca/genuca.cpp +++ b/icu4c/source/tools/genuca/genuca.cpp @@ -25,31 +25,41 @@ #include #include "unicode/utypes.h" - -#if UCONFIG_NO_COLLATION - -extern int -main(int argc, const char *argv[]) { - fprintf(stderr, "genuca performs no-op because of UCONFIG_NO_COLLATION, see uconfig.h\n"); - return 0; -} - -#else - +#include "unicode/udata.h" +#include "ucol_imp.h" #include "genuca.h" #include "uoptions.h" #include "toolutil.h" +#include "unewdata.h" #include "cstring.h" - #include "cmemory.h" -UCAElements le; - /* * Global - verbosity */ UBool VERBOSE = FALSE; +#if UCONFIG_NO_COLLATION + +/* dummy UDataInfo cf. udata.h */ +static UDataInfo dummyDataInfo = { + sizeof(UDataInfo), + 0, + + U_IS_BIG_ENDIAN, + U_CHARSET_FAMILY, + U_SIZEOF_UCHAR, + 0, + + { 0, 0, 0, 0 }, /* dummy dataFormat */ + { 0, 0, 0, 0 }, /* dummy formatVersion */ + { 0, 0, 0, 0 } /* dummy dataVersion */ +}; + +#else + +UCAElements le; + int32_t readElement(char **from, char *to, char separator, UErrorCode *status) { if(U_FAILURE(*status)) { return 0; @@ -906,6 +916,8 @@ struct { return 0; } +#endif /* #if !UCONFIG_NO_COLLATION */ + static UOption options[]={ UOPTION_HELP_H, /* 0 Numbers for those who*/ UOPTION_HELP_QUESTION_MARK, /* 1 can't count. */ @@ -960,7 +972,12 @@ int main(int argc, char* argv[]) { if(options[3].doesOccur) { fprintf(stdout, "genuca version %hu.%hu, ICU tool to read UCA text data and create UCA data tables for collation.\n", - ucaDataInfo.formatVersion[0], ucaDataInfo.formatVersion[1]); +#if UCONFIG_NO_COLLATION + 0, 0 +#else + ucaDataInfo.formatVersion[0], ucaDataInfo.formatVersion[1] +#endif + ); fprintf(stdout, "Copyright (C) 2000-2001, International Business Machines\n"); fprintf(stdout, "Corporation and others. All Rights Reserved.\n"); exit(0); @@ -1001,10 +1018,34 @@ int main(int argc, char* argv[]) { exit(1); } #endif - return write_uca_table(filename, destdir, copyright, &status); -} -#endif /* #if !UCONFIG_NO_COLLATION */ +#if UCONFIG_NO_COLLATION + + UNewDataMemory *pData; + const char *msg; + + msg = "genuca writes dummy " U_ICUDATA_NAME "_" UCA_DATA_NAME "." UCA_DATA_TYPE " because of UCONFIG_NO_COLLATION, see uconfig.h"; + fprintf(stderr, "%s\n", msg); + pData = udata_create(destdir, UCA_DATA_TYPE, U_ICUDATA_NAME "_" UCA_DATA_NAME, &dummyDataInfo, + NULL, &status); + udata_writeBlock(pData, msg, strlen(msg)); + udata_finish(pData, &status); + + msg = "genuca writes dummy " U_ICUDATA_NAME "_" INVC_DATA_NAME "." INVC_DATA_TYPE " because of UCONFIG_NO_COLLATION, see uconfig.h"; + fprintf(stderr, "%s\n", msg); + pData = udata_create(destdir, INVC_DATA_TYPE, U_ICUDATA_NAME "_" INVC_DATA_NAME, &dummyDataInfo, + NULL, &status); + udata_writeBlock(pData, msg, strlen(msg)); + udata_finish(pData, &status); + + return (int)status; + +#else + + return write_uca_table(filename, destdir, copyright, &status); + +#endif +} /* * Hey, Emacs, please set the following: diff --git a/icu4c/source/tools/genuca/genuca.h b/icu4c/source/tools/genuca/genuca.h index 99d456aeebe..501be4e059f 100644 --- a/icu4c/source/tools/genuca/genuca.h +++ b/icu4c/source/tools/genuca/genuca.h @@ -22,6 +22,10 @@ #ifndef UCADATA_H #define UCADATA_H +#include "unicode/utypes.h" + +#if !UCONFIG_NO_COLLATION + #include "ucol_elm.h" #include #include @@ -39,5 +43,6 @@ uint32_t getSingleCEValue(char *primary, char *secondary, char *tertiary, UBool void printOutTable(UCATableHeader *myData, UErrorCode *status); UCAElements *readAnElement(FILE *data, tempUCATable *t, UCAConstants *consts, UErrorCode *status); +#endif /* #if !UCONFIG_NO_COLLATION */ #endif