ICU-578 icudata conflicts with user data
X-SVN-Rev: 2407
This commit is contained in:
parent
66bae3ec8a
commit
6b707c92f0
@ -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*/
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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; i<fileCount; ++i) {
|
||||
sprintf(buffer, ",\n %s[]", files[i].pathname);
|
||||
sprintf(buffer, ",\n %s%s[]", symPrefix, files[i].pathname);
|
||||
T_FileStream_writeLine(out, buffer);
|
||||
}
|
||||
T_FileStream_writeLine(out, ";\n\n");
|
||||
@ -309,7 +322,7 @@ main(int argc, const char *argv[]) {
|
||||
" const char *name;\n"
|
||||
" const void *data;\n"
|
||||
" } toc[%lu];\n"
|
||||
"} U_EXPORT2 icudata_dat = {\n"
|
||||
"} U_EXPORT2 %s_dat = {\n"
|
||||
" 32, 0xda, 0x27, {\n"
|
||||
" %lu, 0, \n"
|
||||
" %u, %u, %u, 0, \n"
|
||||
@ -320,6 +333,7 @@ main(int argc, const char *argv[]) {
|
||||
" \"\", %lu, 0, {\n",
|
||||
32-4-sizeof(UDataInfo),
|
||||
fileCount,
|
||||
options[6].value,
|
||||
sizeof(UDataInfo),
|
||||
U_IS_BIG_ENDIAN,
|
||||
U_CHARSET_FAMILY,
|
||||
@ -328,10 +342,10 @@ main(int argc, const char *argv[]) {
|
||||
);
|
||||
T_FileStream_writeLine(out, buffer);
|
||||
|
||||
sprintf(buffer, " { \"%s\", %s }", files[0].basename, files[0].pathname);
|
||||
sprintf(buffer, " { \"%s\", %s%s }", files[0].basename, symPrefix, files[0].pathname);
|
||||
T_FileStream_writeLine(out, buffer);
|
||||
for(i=1; i<fileCount; ++i) {
|
||||
sprintf(buffer, ",\n { \"%s\", %s }", files[i].basename, files[i].pathname);
|
||||
sprintf(buffer, ",\n { \"%s\", %s%s }", files[i].basename, symPrefix, files[i].pathname);
|
||||
T_FileStream_writeLine(out, buffer);
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ void writeObjRules(UPKGOptions *o, FileStream *makefile, CharList **objects)
|
||||
parents = pkg_appendToList(parents, NULL, uprv_strdup(infiles->str));
|
||||
|
||||
/* 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) ");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user