From 6b707c92f0b923d3d7dad31f4016710a9c70bdb0 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Wed, 30 Aug 2000 23:58:24 +0000 Subject: [PATCH] ICU-578 icudata conflicts with user data X-SVN-Rev: 2407 --- icu4c/source/test/cintltst/udatatst.c | 24 ++++++++++++------------ icu4c/source/tools/Makefile.in | 4 ++-- icu4c/source/tools/genccode/genccode.c | 24 +++++++++++++++++++----- icu4c/source/tools/gencmn/gencmn.c | 24 +++++++++++++++++++----- icu4c/source/tools/pkgdata/dllmode.c | 21 ++++++++++++--------- 5 files changed, 64 insertions(+), 33 deletions(-) diff --git a/icu4c/source/test/cintltst/udatatst.c b/icu4c/source/test/cintltst/udatatst.c index c91de60ce9..69aa1dbe30 100644 --- a/icu4c/source/test/cintltst/udatatst.c +++ b/icu4c/source/test/cintltst/udatatst.c @@ -57,10 +57,10 @@ void TestUDataOpen(){ const char* type="dat"; char* path=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("icudata") +1 ) ); - char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("base") +1 ) ); + char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("testdat1") +1 ) ); strcat(strcpy(path, u_getDataDirectory()), "icudata"); - strcat(strcpy(testPath, u_getDataDirectory()), "base"); + strcat(strcpy(testPath, u_getDataDirectory()), "testdat1"); log_verbose("Testing udata_open()\n"); @@ -197,9 +197,9 @@ void TestUDataOpenChoiceDemo1() { }; const char* type="dat"; - char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("base") +1 ) ); + char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("testdat1") +1 ) ); - strcat(strcpy(testPath, u_getDataDirectory()), "base"); + strcat(strcpy(testPath, u_getDataDirectory()), "testdat1"); result=udata_openChoice(NULL, type, name[0], isAcceptable1, NULL, &status); if(U_FAILURE(status)){ @@ -271,8 +271,8 @@ void TestUDataOpenChoiceDemo2() { const char* type="dat"; const char* base[]={ /* these are the common base names to use for the test */ - "base", /* corresponds to something like 'base.dat', 'base.dll', 'libbase.so', etc.. */ - "base_test" /* libbase_test.so, libbase_test.a, etc... */ + "testdat1", /* corresponds to something like 'base.dat', 'base.dll', 'libbase.so', etc.. */ + "testdat2" /* libbase_test.so, libbase_test.a, etc... */ }; char* path=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen(base[0]) + 1) ); @@ -345,10 +345,10 @@ void TestUDataGetInfo() { const char* type="dat"; char* path=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("icudata") +1 ) ); - char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("base") +1 ) ); + char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("testdat1") +1 ) ); strcat(strcpy(path, u_getDataDirectory()), "icudata"); - strcat(strcpy(testPath, u_getDataDirectory()), "base"); + strcat(strcpy(testPath, u_getDataDirectory()), "testdat1"); log_verbose("Testing udata_getInfo() for cnvalias.dat\n"); @@ -413,9 +413,9 @@ void TestUDataGetMemory() { const char* name2="test"; - char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("base") +1 ) ); + char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("testdat1") +1 ) ); - strcat(strcpy(testPath, u_getDataDirectory()), "base"); + strcat(strcpy(testPath, u_getDataDirectory()), "testdat1"); log_verbose("Testing udata_getMemory for \"cnvalias.dat()\"\n"); result=udata_openChoice(NULL, type, name, isAcceptable1, NULL, &status); @@ -468,10 +468,10 @@ void TestErrorConditions(){ const char* type="dat"; char* path=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("icudata") +1 ) ); - char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("base") +1 ) ); + char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("testdat1") +1 ) ); strcat(strcpy(path, u_getDataDirectory()), "icudata"); - strcat(strcpy(testPath, u_getDataDirectory()), "base"); + strcat(strcpy(testPath, u_getDataDirectory()), "testdat1"); status = U_ILLEGAL_ARGUMENT_ERROR; /*Try udata_open with status != U_ZERO_ERROR*/ diff --git a/icu4c/source/tools/Makefile.in b/icu4c/source/tools/Makefile.in index aea90aaf17..995726637c 100644 --- a/icu4c/source/tools/Makefile.in +++ b/icu4c/source/tools/Makefile.in @@ -200,8 +200,8 @@ $(TMPDATADIR)/icupkg.inc: pkgdata/icupkg.inc build-local build-pkgdata: $(TMPDATADIR)/icudata.lst $(TMPDATADIR)/testdata.lst $(TMPDATADIR)/icupkg.inc $(DATAFILES) $(DATABUILDDIR)/test.dat @$(mkinstalldirs) $(TMPDATADIR) (cd $(TMPDATADIR); $(PKGDATA) -p icudata ./icudata.lst ) - (cd $(TMPDATADIR); $(PKGDATA) -p base ./testdata.lst ) - (cd $(TMPDATADIR); $(PKGDATA) -p base_test ./testdata.lst ) + (cd $(TMPDATADIR); $(PKGDATA) -p testdat1 ./testdata.lst ) + (cd $(TMPDATADIR); $(PKGDATA) -p testdat2 ./testdata.lst ) install-pkgdata: $(TMPDATADIR)/icudata.lst $(TMPDATADIR)/icupkg.inc $(mkinstalldirs) $(TMPDATADIR) $(DESTDIR)$(pkgdatadir)/$(VERSION) diff --git a/icu4c/source/tools/genccode/genccode.c b/icu4c/source/tools/genccode/genccode.c index a2b3480d67..fecb2c18bc 100644 --- a/icu4c/source/tools/genccode/genccode.c +++ b/icu4c/source/tools/genccode/genccode.c @@ -55,14 +55,27 @@ static UOption options[]={ UOPTION_HELP_H, UOPTION_HELP_QUESTION_MARK, UOPTION_DESTDIR, - UOPTION_DEF("object", 'o', UOPT_NO_ARG) + UOPTION_DEF("object", 'o', UOPT_NO_ARG), + UOPTION_DEF("name", 'n', UOPT_REQUIRES_ARG) }; +char symPrefix[100]; + extern int main(int argc, const char *argv[]) { /* read command line options */ argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options); + if(options[4].doesOccur) + { + uprv_strcpy(symPrefix, options[4].value); + uprv_strcat(symPrefix, "_"); + } + else + { + symPrefix[0] = 0; + } + /* error handling, printing usage message */ if(argc<0) { fprintf(stderr, @@ -129,11 +142,12 @@ writeCCode(const char *filename, const char *destdir) { sprintf(buffer, "#include \"unicode/utypes.h\"\n" - "U_EXPORT const struct {\n" + "U_CDECL_BEGIN\n" + "const struct {\n" " double bogus;\n" " uint8_t bytes[%ld]; \n" - "} U_EXPORT2 %s={ 0, {\n", - T_FileStream_size(in), entry); + "} %s%s={ 0, {\n", + T_FileStream_size(in), symPrefix, entry); T_FileStream_writeLine(out, buffer); for(;;) { @@ -146,7 +160,7 @@ writeCCode(const char *filename, const char *destdir) { } } - T_FileStream_writeLine(out, "\n}\n};\n"); + T_FileStream_writeLine(out, "\n}\n};\nU_CDECL_END\n"); if(T_FileStream_error(in)) { fprintf(stderr, "genccode: file read error while generating from file %s\n", filename); diff --git a/icu4c/source/tools/gencmn/gencmn.c b/icu4c/source/tools/gencmn/gencmn.c index 060fcc4f61..f1dff032c4 100644 --- a/icu4c/source/tools/gencmn/gencmn.c +++ b/icu4c/source/tools/gencmn/gencmn.c @@ -86,6 +86,8 @@ static UOption options[]={ UOPTION_DEF( "source", 'S', UOPT_NO_ARG) }; +char symPrefix[100]; + extern int main(int argc, const char *argv[]) { static uint8_t buffer[4096]; @@ -103,6 +105,17 @@ main(int argc, const char *argv[]) { options[7].value=DATA_TYPE; argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options); + /* if it is ICU data.. no prefix. */ + if(!uprv_strcmp(options[6].value, COMMON_DATA_NAME)) + { + symPrefix[0] = 0; + } + else + { + uprv_strcpy(symPrefix, options[6].value); + uprv_strcat(symPrefix, "_"); + } + /* error handling, printing usage message */ if(argc<0) { fprintf(stderr, @@ -289,10 +302,10 @@ main(int argc, const char *argv[]) { options[6].value, options[7].value); T_FileStream_writeLine(out, buffer); - sprintf(buffer, "extern const char\n %s[]", files[0].pathname); + sprintf(buffer, "extern const char\n %s%s[]", symPrefix, files[0].pathname); T_FileStream_writeLine(out, buffer); for(i=1; istr)); /* make up commands.. */ - sprintf(stanza, "$(TOOL) $(GENCCODE) -d $(TEMP_DIR) $<"); + sprintf(stanza, "$(TOOL) $(GENCCODE) -n %s -d $(TEMP_DIR) $<", o->shortName); commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza)); sprintf(stanza, "$(COMPILE.c) -o $@ $(TEMP_DIR)/%s", cfile); @@ -140,16 +140,19 @@ void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status) "\tdone;\n\n"); } - T_FileStream_writeLine(makefile, "$(TEMP_DIR)/icudata_dat.o : $(TEMP_DIR)/icudata_dat.c\n" - "\t$(COMPILE.c) -o $@ $<\n\n"); + sprintf(tmp,"$(TEMP_DIR)/%s_dat.o : $(TEMP_DIR)/%s_dat.c\n" + "\t$(COMPILE.c) -o $@ $<\n\n", + o->shortName, + o->shortName); + T_FileStream_writeLine(makefile, tmp); T_FileStream_writeLine(makefile, "# 'TOCOBJ' contains C Table of Contents objects [if any]\n"); - if(!strcmp(o->shortName, "icudata")) { - T_FileStream_writeLine(makefile, "$(TEMP_DIR)/icudata_dat.c: $(CMNLIST)\n" - "\t$(TOOL) $(GENCMN) -S -d $(TEMP_DIR) 0 $(CMNLIST)\n\n"); - sprintf(tmp, "TOCOBJ= icudata_dat%s \n\n", OBJ_SUFFIX); - T_FileStream_writeLine(makefile, tmp); - } + + sprintf(tmp, "$(TEMP_DIR)/%s_dat.c: $(CMNLIST)\n" + "\t$(TOOL) $(GENCMN) -n %s -S -d $(TEMP_DIR) 0 $(CMNLIST)\n\n", o->shortName, o->shortName); + T_FileStream_writeLine(makefile, tmp); + sprintf(tmp, "TOCOBJ= %s_dat%s \n\n", o->shortName,OBJ_SUFFIX); + T_FileStream_writeLine(makefile, tmp); T_FileStream_writeLine(makefile, "BASE_OBJECTS= $(TOCOBJ) ");