ICU-1404 Fix broken out-of-source-directory build

X-SVN-Rev: 6571
This commit is contained in:
Andy Heninger 2001-11-02 02:24:15 +00:00
parent 0972265bf5
commit cf191f47df
10 changed files with 178 additions and 152 deletions

View File

@ -36,11 +36,11 @@ endif
DEFS = @DEFS@ DEFS = @DEFS@
DATADIR := $(shell pwd)/../../../data BUILDDIR := $(shell pwd)/../..
# we define ICU_UNICODE_VERSION so we can test it # we define ICU_UNICODE_VERSION so we can test it
CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/tools/toolutil \ CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/tools/toolutil \
-DICU_UNICODE_VERSION=\"$(UNICODE_VERSION)\" -DICU_VERSION=\"@VERSION@\" -DICUDATA_NAME=\"$(ICUDATA_NAME)\" -DU_SRCDATADIR=\"$(DATADIR)/\" -DICU_UNICODE_VERSION=\"$(UNICODE_VERSION)\" -DICU_VERSION=\"@VERSION@\" -DICUDATA_NAME=\"$(ICUDATA_NAME)\" -DU_TOPSRCDIR=\"$(top_srcdir)/\" -DU_TOPBUILDDIR=\"$(BUILDDIR)\"
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@ CXXFLAGS = @CXXFLAGS@
ENABLE_RPATH = @ENABLE_RPATH@ ENABLE_RPATH = @ENABLE_RPATH@

View File

@ -220,14 +220,17 @@ void ctest_setICU_DATA() {
return; return;
} }
/* U_SRCDATADIR is set by the makefiles on UNIXes when building cintltst and intltst /* U_TOPBUILDDIR is set by the makefiles on UNIXes when building cintltst and intltst
* to point to "wherever/icu/data" // to point to the top of the build hierarchy, which may or
* We can make a path from there to "wherever/icu/source/data" // may not be the same as the source directory, depending on
* The value is complete with quotes, so it can be used as-is as a string constant. // the configure options used. At any rate,
// set the data path to the built data from this directory.
// The value is complete with quotes, so it can be used
// as-is as a string constant.
*/ */
#if defined (U_SRCDATADIR) #if defined (U_TOPBUILDDIR)
{ {
static char env_string[] = U_SRCDATADIR "/../source/data/"; static char env_string[] = U_TOPBUILDDIR "/data/";
u_setDataDirectory(env_string); u_setDataDirectory(env_string);
return; return;
} }
@ -238,7 +241,7 @@ void ctest_setICU_DATA() {
* Change to "wherever\icu\source\data" * Change to "wherever\icu\source\data"
*/ */
{ {
char p[sizeof(__FILE__) + 1]; char p[sizeof(__FILE__) + 10];
char *pBackSlash; char *pBackSlash;
int i; int i;

View File

@ -318,7 +318,7 @@ static void TestNormalizedUnicodeChar()
ucol_close(th_th); ucol_close(th_th);
return; return;
} }
backAndForth(iter); backAndForth(iter);
ucol_closeElements(iter); ucol_closeElements(iter);
@ -343,7 +343,7 @@ static void TestNormalizedUnicodeChar()
static void TestNormalization() static void TestNormalization()
{ {
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
const char *str = const char *str =
"&a < \\u0300\\u0315 < A\\u0300\\u0315 < \\u0316\\u0315B < \\u0316\\u0300\\u0315"; "&a < \\u0300\\u0315 < A\\u0300\\u0315 < \\u0316\\u0315B < \\u0316\\u0300\\u0315";
UCollator *coll; UCollator *coll;
UChar rule[50]; UChar rule[50];
@ -373,12 +373,12 @@ static void TestNormalization()
iter = ucol_openElements(coll, source, srclen - 1, &status); iter = ucol_openElements(coll, source, srclen - 1, &status);
backAndForth(iter); backAndForth(iter);
ucol_closeElements(iter); ucol_closeElements(iter);
srclen = u_unescape(testdata[1], source, 10); srclen = u_unescape(testdata[1], source, 10);
iter = ucol_openElements(coll, source, srclen - 1, &status); iter = ucol_openElements(coll, source, srclen - 1, &status);
backAndForth(iter); backAndForth(iter);
ucol_closeElements(iter); ucol_closeElements(iter);
while (count < 12) { while (count < 12) {
srclen = u_unescape(testdata[count], source, 10); srclen = u_unescape(testdata[count], source, 10);
iter = ucol_openElements(coll, source, srclen - 1, &status); iter = ucol_openElements(coll, source, srclen - 1, &status);
@ -444,7 +444,7 @@ static void TestPrevious()
c1 = ucol_openRules(rule, u_strlen(rule), UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL, &status); c1 = ucol_openRules(rule, u_strlen(rule), UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL, &status);
log_verbose("Contraction rule testing back and forth with no normalization\n"); log_verbose("Contraction rule testing back and forth with no normalization\n");
if (c1 == NULL || U_FAILURE(status)) if (c1 == NULL || U_FAILURE(status))
{ {
log_err("Couldn't create a RuleBasedCollator with a contracting sequence\n %s\n", log_err("Couldn't create a RuleBasedCollator with a contracting sequence\n %s\n",
@ -462,7 +462,7 @@ static void TestPrevious()
backAndForth(iter); backAndForth(iter);
ucol_closeElements(iter); ucol_closeElements(iter);
ucol_close(c1); ucol_close(c1);
/* Test with an expanding character sequence */ /* Test with an expanding character sequence */
u_uastrcpy(rule, "&a < b < c/abd < d"); u_uastrcpy(rule, "&a < b < c/abd < d");
c2 = ucol_openRules(rule, u_strlen(rule), UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL, &status); c2 = ucol_openRules(rule, u_strlen(rule), UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL, &status);
@ -665,7 +665,7 @@ static void TestOffset()
} }
count ++; count ++;
} }
if(U_FAILURE(status)){ if(U_FAILURE(status)){
log_err("ERROR: in iterating collation elements %s\n", log_err("ERROR: in iterating collation elements %s\n",
myErrorName(status)); myErrorName(status));
@ -879,7 +879,7 @@ static void TestMaxExpansion()
ch ++; ch ++;
} }
ch = 0x63; ch = 0x63;
ucol_setText(iter, &ch, 1, &status); ucol_setText(iter, &ch, 1, &status);
temporder = ucol_previous(iter, &status); temporder = ucol_previous(iter, &status);
@ -888,7 +888,7 @@ static void TestMaxExpansion()
ch, 3); ch, 3);
} }
ch = 0x64; ch = 0x64;
ucol_setText(iter, &ch, 1, &status); ucol_setText(iter, &ch, 1, &status);
temporder = ucol_previous(iter, &status); temporder = ucol_previous(iter, &status);
@ -929,7 +929,7 @@ static void TestMaxExpansion()
rule[7] = 0x71; rule[7] = 0x71;
rule[8] = 0x71; rule[8] = 0x71;
rule[9] = 0; rule[9] = 0;
coll = ucol_openRules(rule, u_strlen(rule), UCOL_DEFAULT, coll = ucol_openRules(rule, u_strlen(rule), UCOL_DEFAULT,
UCOL_DEFAULT_STRENGTH,NULL, &status); UCOL_DEFAULT_STRENGTH,NULL, &status);
iter = ucol_openElements(coll, &ch, 1, &status); iter = ucol_openElements(coll, &ch, 1, &status);
@ -1080,7 +1080,7 @@ static void TestSmallBuffer()
ucol_reset(testiter); ucol_reset(testiter);
/* ensures that the writable buffer was cleared */ /* ensures that the writable buffer was cleared */
if (testiter->iteratordata_.writableBuffer != if (testiter->iteratordata_.writableBuffer !=
testiter->iteratordata_.stackWritableBuffer) { testiter->iteratordata_.stackWritableBuffer) {
log_err("Error Writable buffer in collation element iterator not reset\n"); log_err("Error Writable buffer in collation element iterator not reset\n");
} }
@ -1108,9 +1108,9 @@ static int32_t hex2num(char hex) {
} }
} }
/** /**
* Getting codepoints from a string * Getting codepoints from a string
* @param str character string contain codepoints seperated by space and ended * @param str character string contain codepoints seperated by space and ended
* by a semicolon * by a semicolon
* @param codepoints array for storage, assuming size > 5 * @param codepoints array for storage, assuming size > 5
* @return position at the end of the codepoint section * @return position at the end of the codepoint section
@ -1119,16 +1119,16 @@ static char * getCodePoints(char *str, UChar *codepoints) {
char *pStartCP = str; char *pStartCP = str;
char *pEndCP = str + 4; char *pEndCP = str + 4;
*codepoints = (UChar)((hex2num(*pStartCP) << 12) | *codepoints = (UChar)((hex2num(*pStartCP) << 12) |
(hex2num(*(pStartCP + 1)) << 8) | (hex2num(*(pStartCP + 1)) << 8) |
(hex2num(*(pStartCP + 2)) << 4) | (hex2num(*(pStartCP + 2)) << 4) |
(hex2num(*(pStartCP + 3)))); (hex2num(*(pStartCP + 3))));
codepoints ++; codepoints ++;
while (*pEndCP != ';') { while (*pEndCP != ';') {
pStartCP = pEndCP + 1; pStartCP = pEndCP + 1;
*codepoints = (UChar)((hex2num(*pStartCP) << 12) | *codepoints = (UChar)((hex2num(*pStartCP) << 12) |
(hex2num(*(pStartCP + 1)) << 8) | (hex2num(*(pStartCP + 1)) << 8) |
(hex2num(*(pStartCP + 2)) << 4) | (hex2num(*(pStartCP + 2)) << 4) |
(hex2num(*(pStartCP + 3)))); (hex2num(*(pStartCP + 3))));
codepoints ++; codepoints ++;
pEndCP = pStartCP + 4; pEndCP = pStartCP + 4;
@ -1155,9 +1155,9 @@ readElement(char **from, char *to, char separator, UErrorCode *status)
(*from)++; (*from)++;
*(buffer + i) = 0; *(buffer + i) = 0;
strcpy(to, buffer); strcpy(to, buffer);
return i/2; return i/2;
} }
return 0; return 0;
} }
@ -1165,7 +1165,7 @@ readElement(char **from, char *to, char separator, UErrorCode *status)
* Sniplets of code from genuca * Sniplets of code from genuca
*/ */
static uint32_t static uint32_t
getSingleCEValue(char *primary, char *secondary, char *tertiary, getSingleCEValue(char *primary, char *secondary, char *tertiary,
UErrorCode *status) UErrorCode *status)
{ {
if (U_SUCCESS(*status)) { if (U_SUCCESS(*status)) {
@ -1184,12 +1184,12 @@ getSingleCEValue(char *primary, char *secondary, char *tertiary,
primsave = *primend; primsave = *primend;
*primend = '\0'; *primend = '\0';
} }
if (uprv_strlen(secondary) > 2) { if (uprv_strlen(secondary) > 2) {
secsave = *secend; secsave = *secend;
*secend = '\0'; *secend = '\0';
} }
if (uprv_strlen(tertiary) > 2) { if (uprv_strlen(tertiary) > 2) {
tersave = *terend; tersave = *terend;
*terend = '\0'; *terend = '\0';
@ -1202,8 +1202,8 @@ getSingleCEValue(char *primary, char *secondary, char *tertiary,
primvalue <<= 8; primvalue <<= 8;
} }
value = ((primvalue << UCOL_PRIMARYORDERSHIFT) & UCOL_PRIMARYORDERMASK) value = ((primvalue << UCOL_PRIMARYORDERSHIFT) & UCOL_PRIMARYORDERMASK)
| ((secvalue << UCOL_SECONDARYORDERSHIFT) & UCOL_SECONDARYORDERMASK) | ((secvalue << UCOL_SECONDARYORDERSHIFT) & UCOL_SECONDARYORDERMASK)
| (tervalue & UCOL_TERTIARYORDERMASK); | (tervalue & UCOL_TERTIARYORDERMASK);
if(primsave!='\0') { if(primsave!='\0') {
@ -1220,9 +1220,9 @@ getSingleCEValue(char *primary, char *secondary, char *tertiary,
return 0; return 0;
} }
/** /**
* Getting collation elements generated from a string * Getting collation elements generated from a string
* @param str character string contain collation elements contained in [] and * @param str character string contain collation elements contained in [] and
* seperated by space * seperated by space
* @param ce array for storage, assuming size > 20 * @param ce array for storage, assuming size > 20
* @param status error status * @param status error status
@ -1235,7 +1235,7 @@ static char * getCEs(char *str, uint32_t *ces, UErrorCode *status) {
char primary[100]; char primary[100];
char secondary[100]; char secondary[100];
char tertiary[100]; char tertiary[100];
while (*pStartCP == '[') { while (*pStartCP == '[') {
uint32_t primarycount = 0; uint32_t primarycount = 0;
uint32_t secondarycount = 0; uint32_t secondarycount = 0;
@ -1257,7 +1257,7 @@ static char * getCEs(char *str, uint32_t *ces, UErrorCode *status) {
break; break;
} }
while (2 * CEi < primarycount || CEi < secondarycount || while (2 * CEi < primarycount || CEi < secondarycount ||
CEi < tertiarycount) { CEi < tertiarycount) {
uint32_t value = UCOL_CONTINUATION_MARKER; /* Continuation marker */ uint32_t value = UCOL_CONTINUATION_MARKER; /* Continuation marker */
if (2 * CEi < primarycount) { if (2 * CEi < primarycount) {
@ -1290,7 +1290,7 @@ static char * getCEs(char *str, uint32_t *ces, UErrorCode *status) {
return pStartCP; return pStartCP;
} }
/** /**
* Getting the FractionalUCA.txt file stream * Getting the FractionalUCA.txt file stream
*/ */
static FileStream * getFractionalUCA(void) static FileStream * getFractionalUCA(void)
@ -1304,12 +1304,17 @@ static FileStream * getFractionalUCA(void)
uprv_strcat(newPath, "unidata" U_FILE_SEP_STRING ); uprv_strcat(newPath, "unidata" U_FILE_SEP_STRING );
uprv_strcat(newPath, "FractionalUCA.txt"); uprv_strcat(newPath, "FractionalUCA.txt");
uprv_strcpy(backupPath, u_getDataDirectory()); /* As a fallback, try to guess where the source data was located
uprv_strcat(backupPath, ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data"); * at the time ICU was built, and look there.
uprv_strcat(backupPath, U_FILE_SEP_STRING); */
uprv_strcat(backupPath, "unidata" U_FILE_SEP_STRING ); #if defined (U_TOPSRCDIR)
uprv_strcat(backupPath, "FractionalUCA.txt"); strcpy(backupPath, U_TOPSRCDIR U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data");
#else
strcpy(backupPath, u_getDataDirectory());
strcat(backupPath, ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data");
#endif
strcat(backupPath, U_FILE_SEP_STRING "unidata" U_FILE_SEP_STRING "FractionalUCA.txt");
result = T_FileStream_open(newPath, "rb"); result = T_FileStream_open(newPath, "rb");
if (result == NULL) { if (result == NULL) {
@ -1348,9 +1353,9 @@ static void TestCEs() {
while (T_FileStream_readLine(file, line, sizeof(line)) != NULL) { while (T_FileStream_readLine(file, line, sizeof(line)) != NULL) {
int count = 0; int count = 0;
UCollationElements *iter; UCollationElements *iter;
/* skip this line if it is empty or a comment or is a return value /* skip this line if it is empty or a comment or is a return value
or start of some variable section */ or start of some variable section */
if(line[0] == 0 || line[0] == '#' || line[0] == '\n' || if(line[0] == 0 || line[0] == '#' || line[0] == '\n' ||
line[0] == 0x000D || line[0] == '[') { line[0] == 0x000D || line[0] == '[') {
continue; continue;
} }
@ -1361,11 +1366,11 @@ static void TestCEs() {
log_err("Error in parsing collation elements in FractionalUCA.txt\n"); log_err("Error in parsing collation elements in FractionalUCA.txt\n");
break; break;
} }
iter = ucol_openElements(coll, codepoints, -1, &status); iter = ucol_openElements(coll, codepoints, -1, &status);
if (U_FAILURE(status)) { if (U_FAILURE(status)) {
log_err("Error in opening collation elements\n"); log_err("Error in opening collation elements\n");
break; break;
} }
for (;;) { for (;;) {
uint32_t ce = (uint32_t)ucol_next(iter, &status); uint32_t ce = (uint32_t)ucol_next(iter, &status);
if (ce == 0xFFFFFFFF) { if (ce == 0xFFFFFFFF) {
@ -1391,48 +1396,48 @@ static void TestCEs() {
* Testing the discontigous contractions * Testing the discontigous contractions
*/ */
static void TestDiscontiguos() { static void TestDiscontiguos() {
const char *rulestr = const char *rulestr =
"&z < AB < X\\u0300 < ABC < X\\u0300\\u0315"; "&z < AB < X\\u0300 < ABC < X\\u0300\\u0315";
UChar rule[50]; UChar rule[50];
int rulelen = u_unescape(rulestr, rule, 50); int rulelen = u_unescape(rulestr, rule, 50);
const char *src[] = { const char *src[] = {
"ADB", "ADBC", "A\\u0315B", "A\\u0315BC", "ADB", "ADBC", "A\\u0315B", "A\\u0315BC",
/* base character blocked */ /* base character blocked */
"XD\\u0300", "XD\\u0300\\u0315", "XD\\u0300", "XD\\u0300\\u0315",
/* non blocking combining character */ /* non blocking combining character */
"X\\u0319\\u0300", "X\\u0319\\u0300\\u0315", "X\\u0319\\u0300", "X\\u0319\\u0300\\u0315",
/* blocking combining character */ /* blocking combining character */
"X\\u0314\\u0300", "X\\u0314\\u0300\\u0315", "X\\u0314\\u0300", "X\\u0314\\u0300\\u0315",
/* contraction prefix */ /* contraction prefix */
"ABDC", "AB\\u0315C","X\\u0300D\\u0315", "X\\u0300\\u0319\\u0315", "ABDC", "AB\\u0315C","X\\u0300D\\u0315", "X\\u0300\\u0319\\u0315",
"X\\u0300\\u031A\\u0315", "X\\u0300\\u031A\\u0315",
/* ends not with a contraction character */ /* ends not with a contraction character */
"X\\u0319\\u0300D", "X\\u0319\\u0300\\u0315D", "X\\u0300D\\u0315D", "X\\u0319\\u0300D", "X\\u0319\\u0300\\u0315D", "X\\u0300D\\u0315D",
"X\\u0300\\u0319\\u0315D", "X\\u0300\\u031A\\u0315D" "X\\u0300\\u0319\\u0315D", "X\\u0300\\u031A\\u0315D"
}; };
const char *tgt[] = { const char *tgt[] = {
/* non blocking combining character */ /* non blocking combining character */
"A D B", "A D BC", "A \\u0315 B", "A \\u0315 BC", "A D B", "A D BC", "A \\u0315 B", "A \\u0315 BC",
/* base character blocked */ /* base character blocked */
"X D \\u0300", "X D \\u0300\\u0315", "X D \\u0300", "X D \\u0300\\u0315",
/* non blocking combining character */ /* non blocking combining character */
"X\\u0300 \\u0319", "X\\u0300\\u0315 \\u0319", "X\\u0300 \\u0319", "X\\u0300\\u0315 \\u0319",
/* blocking combining character */ /* blocking combining character */
"X \\u0314 \\u0300", "X \\u0314 \\u0300\\u0315", "X \\u0314 \\u0300", "X \\u0314 \\u0300\\u0315",
/* contraction prefix */ /* contraction prefix */
"AB DC", "AB \\u0315 C","X\\u0300 D \\u0315", "X\\u0300\\u0315 \\u0319", "AB DC", "AB \\u0315 C","X\\u0300 D \\u0315", "X\\u0300\\u0315 \\u0319",
"X\\u0300 \\u031A \\u0315", "X\\u0300 \\u031A \\u0315",
/* ends not with a contraction character */ /* ends not with a contraction character */
"X\\u0300 \\u0319D", "X\\u0300\\u0315 \\u0319D", "X\\u0300 D\\u0315D", "X\\u0300 \\u0319D", "X\\u0300\\u0315 \\u0319D", "X\\u0300 D\\u0315D",
"X\\u0300\\u0315 \\u0319D", "X\\u0300 \\u031A\\u0315D" "X\\u0300\\u0315 \\u0319D", "X\\u0300 \\u031A\\u0315D"
}; };
int size = 20; int size = 20;
UCollator *coll; UCollator *coll;
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
int count = 0; int count = 0;
UCollationElements *iter; UCollationElements *iter;
UCollationElements *resultiter; UCollationElements *resultiter;
coll = ucol_openRules(rule, rulelen, UCOL_OFF, UCOL_DEFAULT_STRENGTH,NULL, &status); coll = ucol_openRules(rule, rulelen, UCOL_OFF, UCOL_DEFAULT_STRENGTH,NULL, &status);
iter = ucol_openElements(coll, rule, 1, &status); iter = ucol_openElements(coll, rule, 1, &status);
resultiter = ucol_openElements(coll, rule, 1, &status); resultiter = ucol_openElements(coll, rule, 1, &status);
@ -1448,7 +1453,7 @@ static void TestDiscontiguos() {
int strLen = u_unescape(src[count], str, 20); int strLen = u_unescape(src[count], str, 20);
UChar *s; UChar *s;
ucol_setText(iter, str, strLen, &status); ucol_setText(iter, str, strLen, &status);
if (U_FAILURE(status)) { if (U_FAILURE(status)) {
log_err("Error opening collation iterator\n"); log_err("Error opening collation iterator\n");
return; return;
@ -1458,21 +1463,21 @@ static void TestDiscontiguos() {
s = tstr; s = tstr;
log_verbose("count %d\n", count); log_verbose("count %d\n", count);
for (;;) { for (;;) {
uint32_t ce; uint32_t ce;
UChar *e = u_strchr(s, 0x20); UChar *e = u_strchr(s, 0x20);
if (e == 0) { if (e == 0) {
e = u_strchr(s, 0); e = u_strchr(s, 0);
} }
ucol_setText(resultiter, s, e - s, &status); ucol_setText(resultiter, s, e - s, &status);
ce = ucol_next(resultiter, &status); ce = ucol_next(resultiter, &status);
if (U_FAILURE(status)) { if (U_FAILURE(status)) {
log_err("Error manipulating collation iterator\n"); log_err("Error manipulating collation iterator\n");
return; return;
} }
while (ce != UCOL_NULLORDER) { while (ce != UCOL_NULLORDER) {
if (ce != (uint32_t)ucol_next(iter, &status) || if (ce != (uint32_t)ucol_next(iter, &status) ||
U_FAILURE(status)) { U_FAILURE(status)) {
log_err("Discontiguos contraction test mismatch\n"); log_err("Discontiguos contraction test mismatch\n");
return; return;
@ -1497,27 +1502,27 @@ static void TestDiscontiguos() {
ucol_close(coll); ucol_close(coll);
} }
static void TestCEBufferOverflow() static void TestCEBufferOverflow()
{ {
UChar str[UCOL_EXPAND_CE_BUFFER_SIZE + 1]; UChar str[UCOL_EXPAND_CE_BUFFER_SIZE + 1];
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
UChar rule[10]; UChar rule[10];
UCollator *coll; UCollator *coll;
UCollationElements *iter; UCollationElements *iter;
u_uastrcpy(rule, "&z < AB"); u_uastrcpy(rule, "&z < AB");
coll = ucol_openRules(rule, u_strlen(rule), UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL,&status); coll = ucol_openRules(rule, u_strlen(rule), UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL,&status);
if (U_FAILURE(status)) { if (U_FAILURE(status)) {
log_err("Rule based collator not created for testing ce buffer overflow\n"); log_err("Rule based collator not created for testing ce buffer overflow\n");
} }
/* 0xDCDC is a trail surrogate hence deemed unsafe by the heuristic /* 0xDCDC is a trail surrogate hence deemed unsafe by the heuristic
test. this will cause an overflow in getPrev */ test. this will cause an overflow in getPrev */
str[0] = 0x0041; /* 'A' */ str[0] = 0x0041; /* 'A' */
/*uprv_memset(str + 1, 0xE0, sizeof(UChar) * UCOL_EXPAND_CE_BUFFER_SIZE);*/ /*uprv_memset(str + 1, 0xE0, sizeof(UChar) * UCOL_EXPAND_CE_BUFFER_SIZE);*/
uprv_memset(str + 1, 0xDC, sizeof(UChar) * UCOL_EXPAND_CE_BUFFER_SIZE); uprv_memset(str + 1, 0xDC, sizeof(UChar) * UCOL_EXPAND_CE_BUFFER_SIZE);
str[UCOL_EXPAND_CE_BUFFER_SIZE] = 0x0042; /* 'B' */ str[UCOL_EXPAND_CE_BUFFER_SIZE] = 0x0042; /* 'B' */
iter = ucol_openElements(coll, str, UCOL_EXPAND_CE_BUFFER_SIZE + 1, iter = ucol_openElements(coll, str, UCOL_EXPAND_CE_BUFFER_SIZE + 1,
&status); &status);
if (ucol_previous(iter, &status) != UCOL_NULLORDER || if (ucol_previous(iter, &status) != UCOL_NULLORDER ||
status != U_BUFFER_OVERFLOW_ERROR) { status != U_BUFFER_OVERFLOW_ERROR) {
@ -1564,7 +1569,7 @@ static uint8_t getCase(const UChar *s, uint32_t len) {
while (len > 0) { while (len > 0) {
UChar c = *ps ++; UChar c = *ps ++;
if (u_islower(c)) { if (u_islower(c)) {
lower = TRUE; lower = TRUE;
} }
@ -1574,7 +1579,7 @@ static uint8_t getCase(const UChar *s, uint32_t len) {
if (u_istitle(c)) { if (u_istitle(c)) {
title = TRUE; title = TRUE;
} }
len --; len --;
} }
if ((lower && !upper && !title) || (!lower && !upper && !title)){ if ((lower && !upper && !title) || (!lower && !upper && !title)){
@ -1584,7 +1589,7 @@ static uint8_t getCase(const UChar *s, uint32_t len) {
return UCOL_UPPER_CASE; return UCOL_UPPER_CASE;
} }
/* mix of cases here */ /* mix of cases here */
/* len = unorm_normalize(s, len, UNORM_NFKD, 0, str, 256, &status); /* len = unorm_normalize(s, len, UNORM_NFKD, 0, str, 256, &status);
if (U_FAILURE(status)) { if (U_FAILURE(status)) {
log_err("Error normalizing data string\n"); log_err("Error normalizing data string\n");
return UCOL_LOWER_CASE; return UCOL_LOWER_CASE;
@ -1603,9 +1608,9 @@ static uint8_t getCase(const UChar *s, uint32_t len) {
/** /**
* Checking collation element validity given the boundary arguments. * Checking collation element validity given the boundary arguments.
*/ */
static UBool checkCEValidity(const UCollator *coll, const UChar *codepoints, static UBool checkCEValidity(const UCollator *coll, const UChar *codepoints,
int length, uint32_t primarymax, int length, uint32_t primarymax,
uint32_t secondarymax) uint32_t secondarymax)
{ {
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
UCollationElements *iter = ucol_openElements(coll, codepoints, length, UCollationElements *iter = ucol_openElements(coll, codepoints, length,
@ -1629,8 +1634,8 @@ static UBool checkCEValidity(const UCollator *coll, const UChar *codepoints,
uint32_t secondary = UCOL_SECONDARYORDER(ce); uint32_t secondary = UCOL_SECONDARYORDER(ce);
uint32_t tertiary = UCOL_TERTIARYORDER(ce); uint32_t tertiary = UCOL_TERTIARYORDER(ce);
/* uint32_t scasebits = tertiary & 0xC0;*/ /* uint32_t scasebits = tertiary & 0xC0;*/
if ((tertiary == 0 && secondary != 0) || if ((tertiary == 0 && secondary != 0) ||
(tertiary < 0xC0 && secondary == 0 && primary != 0)) { (tertiary < 0xC0 && secondary == 0 && primary != 0)) {
/* n-1th level is not zero when the nth level is /* n-1th level is not zero when the nth level is
except for continuations, this is wrong */ except for continuations, this is wrong */
@ -1661,9 +1666,9 @@ static UBool checkCEValidity(const UCollator *coll, const UChar *codepoints,
} }
ucol_closeElements(iter); ucol_closeElements(iter);
return TRUE; return TRUE;
fail : fail :
ucol_closeElements(iter); ucol_closeElements(iter);
return FALSE; return FALSE;
} }
static void TestCEValidity() static void TestCEValidity()
@ -1690,7 +1695,7 @@ static void TestCEValidity()
} }
while (T_FileStream_readLine(file, line, sizeof(line)) != NULL) { while (T_FileStream_readLine(file, line, sizeof(line)) != NULL) {
if(line[0] == 0 || line[0] == '#' || line[0] == '\n' || if(line[0] == 0 || line[0] == '#' || line[0] == '\n' ||
line[0] == 0x000D || line[0] == '[') { line[0] == 0x000D || line[0] == '[') {
continue; continue;
} }
@ -1707,30 +1712,30 @@ static void TestCEValidity()
} }
codepoints[0] ++; codepoints[0] ++;
} }
ucol_close(coll); ucol_close(coll);
/* testing tailored collation elements */ /* testing tailored collation elements */
log_verbose("Testing tailored elements\n"); log_verbose("Testing tailored elements\n");
while (count < 5) { while (count < 5) {
const UChar *rules = NULL, const UChar *rules = NULL,
*current = NULL; *current = NULL;
UChar *rulesCopy = NULL; UChar *rulesCopy = NULL;
int32_t ruleLen = 0; int32_t ruleLen = 0;
uint32_t chOffset = 0; uint32_t chOffset = 0;
uint32_t chLen = 0; uint32_t chLen = 0;
uint32_t exOffset = 0; uint32_t exOffset = 0;
uint32_t exLen = 0; uint32_t exLen = 0;
uint32_t prefixOffset = 0; uint32_t prefixOffset = 0;
uint32_t prefixLen = 0; uint32_t prefixLen = 0;
UBool startOfRules = TRUE; UBool startOfRules = TRUE;
UColOptionSet opts; UColOptionSet opts;
UColTokenParser src; UColTokenParser src;
uint32_t strength = 0; uint32_t strength = 0;
uint8_t specs = 0; uint8_t specs = 0;
coll = ucol_open(locale[count], &status); coll = ucol_open(locale[count], &status);
if (U_FAILURE(status)) { if (U_FAILURE(status)) {
log_err("%s collator creation failed\n", locale[count]); log_err("%s collator creation failed\n", locale[count]);
@ -1741,7 +1746,7 @@ static void TestCEValidity()
rules = ucol_getRules(coll, &ruleLen); rules = ucol_getRules(coll, &ruleLen);
if (ruleLen > 0) { if (ruleLen > 0) {
rulesCopy = (UChar *)uprv_malloc((ruleLen + rulesCopy = (UChar *)uprv_malloc((ruleLen +
UCOL_TOK_EXTRA_RULE_SPACE_SIZE) * sizeof(UChar)); UCOL_TOK_EXTRA_RULE_SPACE_SIZE) * sizeof(UChar));
uprv_memcpy(rulesCopy, rules, ruleLen * sizeof(UChar)); uprv_memcpy(rulesCopy, rules, ruleLen * sizeof(UChar));
src.source = src.current = rulesCopy; src.source = src.current = rulesCopy;
@ -1749,26 +1754,26 @@ static void TestCEValidity()
src.extraCurrent = src.end; src.extraCurrent = src.end;
src.extraEnd = src.end + UCOL_TOK_EXTRA_RULE_SPACE_SIZE; src.extraEnd = src.end + UCOL_TOK_EXTRA_RULE_SPACE_SIZE;
while ((current = ucol_tok_parseNextToken(&src, &strength, while ((current = ucol_tok_parseNextToken(&src, &strength,
&chOffset, &chLen, &exOffset, &exLen, &chOffset, &chLen, &exOffset, &exLen,
&prefixOffset, &prefixLen, &prefixOffset, &prefixLen,
&specs, startOfRules, &parseError,&status)) != NULL) { &specs, startOfRules, &parseError,&status)) != NULL) {
startOfRules = FALSE; startOfRules = FALSE;
uprv_memcpy(codepoints, rules + chOffset, uprv_memcpy(codepoints, rules + chOffset,
chLen * sizeof(UChar)); chLen * sizeof(UChar));
codepoints[chLen] = 0; codepoints[chLen] = 0;
checkCEValidity(coll, codepoints, u_strlen(codepoints), 4, 85); checkCEValidity(coll, codepoints, u_strlen(codepoints), 4, 85);
} }
uprv_free(rulesCopy); uprv_free(rulesCopy);
} }
ucol_close(coll); ucol_close(coll);
count ++; count ++;
} }
} }
static void printSortKeyError(const UChar *codepoints, int length, static void printSortKeyError(const UChar *codepoints, int length,
uint8_t *sortkey, int sklen) uint8_t *sortkey, int sklen)
{ {
int count = 0; int count = 0;
log_err("Sortkey not valid for "); log_err("Sortkey not valid for ");
@ -1788,26 +1793,26 @@ static void printSortKeyError(const UChar *codepoints, int length,
/** /**
* Checking sort key validity for all levels * Checking sort key validity for all levels
*/ */
static UBool checkSortKeyValidity(UCollator *coll, static UBool checkSortKeyValidity(UCollator *coll,
const UChar *codepoints, const UChar *codepoints,
int length) int length)
{ {
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
UCollationStrength strength[5] = {UCOL_PRIMARY, UCOL_SECONDARY, UCollationStrength strength[5] = {UCOL_PRIMARY, UCOL_SECONDARY,
UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_TERTIARY, UCOL_QUATERNARY,
UCOL_IDENTICAL}; UCOL_IDENTICAL};
int strengthlen = 5; int strengthlen = 5;
int index = 0; int index = 0;
int caselevel = 0; int caselevel = 0;
while (caselevel < 1) { while (caselevel < 1) {
if (caselevel == 0) { if (caselevel == 0) {
ucol_setAttribute(coll, UCOL_CASE_LEVEL, UCOL_OFF, &status); ucol_setAttribute(coll, UCOL_CASE_LEVEL, UCOL_OFF, &status);
} }
else { else {
ucol_setAttribute(coll, UCOL_CASE_LEVEL, UCOL_ON, &status); ucol_setAttribute(coll, UCOL_CASE_LEVEL, UCOL_ON, &status);
} }
while (index < strengthlen) { while (index < strengthlen) {
int count01 = 0; int count01 = 0;
uint32_t count = 0; uint32_t count = 0;
@ -1835,7 +1840,7 @@ static UBool checkSortKeyValidity(UCollator *coll,
} }
caselevel ++; caselevel ++;
} }
return TRUE; return TRUE;
} }
static void TestSortKeyValidity(void) static void TestSortKeyValidity(void)
@ -1862,7 +1867,7 @@ static void TestSortKeyValidity(void)
} }
while (T_FileStream_readLine(file, line, sizeof(line)) != NULL) { while (T_FileStream_readLine(file, line, sizeof(line)) != NULL) {
if(line[0] == 0 || line[0] == '#' || line[0] == '\n' || if(line[0] == 0 || line[0] == '#' || line[0] == '\n' ||
line[0] == 0x000D || line[0] == '[') { line[0] == 0x000D || line[0] == '[') {
continue; continue;
} }
@ -1873,37 +1878,37 @@ static void TestSortKeyValidity(void)
log_verbose("Testing UCA elements for the whole range of unicode characters\n"); log_verbose("Testing UCA elements for the whole range of unicode characters\n");
codepoints[0] = 0; codepoints[0] = 0;
while (codepoints[0] < 0xFFFF) { while (codepoints[0] < 0xFFFF) {
if (u_isdefined((UChar32)codepoints[0])) { if (u_isdefined((UChar32)codepoints[0])) {
checkSortKeyValidity(coll, codepoints, 1); checkSortKeyValidity(coll, codepoints, 1);
} }
codepoints[0] ++; codepoints[0] ++;
} }
ucol_close(coll); ucol_close(coll);
/* testing tailored collation elements */ /* testing tailored collation elements */
log_verbose("Testing tailored elements\n"); log_verbose("Testing tailored elements\n");
while (count < 5) { while (count < 5) {
const UChar *rules = NULL, const UChar *rules = NULL,
*current = NULL; *current = NULL;
UChar *rulesCopy = NULL; UChar *rulesCopy = NULL;
int32_t ruleLen = 0; int32_t ruleLen = 0;
uint32_t chOffset = 0; uint32_t chOffset = 0;
uint32_t chLen = 0; uint32_t chLen = 0;
uint32_t exOffset = 0; uint32_t exOffset = 0;
uint32_t exLen = 0; uint32_t exLen = 0;
uint32_t prefixOffset = 0; uint32_t prefixOffset = 0;
uint32_t prefixLen = 0; uint32_t prefixLen = 0;
UBool startOfRules = TRUE; UBool startOfRules = TRUE;
UColOptionSet opts; UColOptionSet opts;
UColTokenParser src; UColTokenParser src;
uint32_t strength = 0; uint32_t strength = 0;
uint8_t specs = 0; uint8_t specs = 0;
coll = ucol_open(locale[count], &status); coll = ucol_open(locale[count], &status);
if (U_FAILURE(status)) { if (U_FAILURE(status)) {
log_err("%s collator creation failed\n", locale[count]); log_err("%s collator creation failed\n", locale[count]);
@ -1914,7 +1919,7 @@ static void TestSortKeyValidity(void)
rules = ucol_getRules(coll, &ruleLen); rules = ucol_getRules(coll, &ruleLen);
if (ruleLen > 0) { if (ruleLen > 0) {
rulesCopy = (UChar *)uprv_malloc((ruleLen + rulesCopy = (UChar *)uprv_malloc((ruleLen +
UCOL_TOK_EXTRA_RULE_SPACE_SIZE) * sizeof(UChar)); UCOL_TOK_EXTRA_RULE_SPACE_SIZE) * sizeof(UChar));
uprv_memcpy(rulesCopy, rules, ruleLen * sizeof(UChar)); uprv_memcpy(rulesCopy, rules, ruleLen * sizeof(UChar));
src.source = src.current = rulesCopy; src.source = src.current = rulesCopy;
@ -1922,19 +1927,19 @@ static void TestSortKeyValidity(void)
src.extraCurrent = src.end; src.extraCurrent = src.end;
src.extraEnd = src.end + UCOL_TOK_EXTRA_RULE_SPACE_SIZE; src.extraEnd = src.end + UCOL_TOK_EXTRA_RULE_SPACE_SIZE;
while ((current = ucol_tok_parseNextToken(&src, &strength, while ((current = ucol_tok_parseNextToken(&src, &strength,
&chOffset, &chLen, &exOffset, &exLen, &chOffset, &chLen, &exOffset, &exLen,
&prefixOffset, &prefixLen, &prefixOffset, &prefixLen,
&specs, startOfRules,&parseError, &status)) != NULL) { &specs, startOfRules,&parseError, &status)) != NULL) {
startOfRules = FALSE; startOfRules = FALSE;
uprv_memcpy(codepoints, rules + chOffset, uprv_memcpy(codepoints, rules + chOffset,
chLen * sizeof(UChar)); chLen * sizeof(UChar));
codepoints[chLen] = 0; codepoints[chLen] = 0;
checkSortKeyValidity(coll, codepoints, u_strlen(codepoints)); checkSortKeyValidity(coll, codepoints, u_strlen(codepoints));
} }
uprv_free(rulesCopy); uprv_free(rulesCopy);
} }
ucol_close(coll); ucol_close(coll);
count ++; count ++;
} }

View File

@ -589,8 +589,15 @@ static void TestUnicodeData()
strcpy(newPath, u_getDataDirectory()); strcpy(newPath, u_getDataDirectory());
strcat(newPath, "unidata" U_FILE_SEP_STRING "UnicodeData.txt"); strcat(newPath, "unidata" U_FILE_SEP_STRING "UnicodeData.txt");
strcpy(backupPath, u_getDataDirectory()); /* As a fallback, try to guess where the source data was located
strcat(backupPath, ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data"); * at the time ICU was built, and look there.
*/
#if defined (U_TOPSRCDIR)
strcpy(backupPath, U_TOPSRCDIR U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data");
#else
strcpy(backupPath, u_getDataDirectory());
strcat(backupPath, ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data");
#endif
strcat(backupPath, U_FILE_SEP_STRING); strcat(backupPath, U_FILE_SEP_STRING);
strcat(backupPath, "unidata" U_FILE_SEP_STRING "UnicodeData.txt"); strcat(backupPath, "unidata" U_FILE_SEP_STRING "UnicodeData.txt");

View File

@ -23,8 +23,8 @@ CLEANFILES = *~ $(DEPS)
TARGET = intltest TARGET = intltest
DEFS = @DEFS@ DEFS = @DEFS@
DATADIR := $(shell pwd)/../../../data BUILDDIR := $(shell pwd)/../..
CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/toolutil -D'U_SRCDATADIR=$(MACRO_SEPARATOR)"$(DATADIR)/"' CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/toolutil -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@ CXXFLAGS = @CXXFLAGS@
LDFLAGS = @LDFLAGS@ \ LDFLAGS = @LDFLAGS@ \

View File

@ -156,28 +156,28 @@ void ConvertTest::TestConvert()
someConverters[0] = new UnicodeConverter("ibm-1123",err); someConverters[0] = new UnicodeConverter("ibm-1123",err);
if (U_FAILURE(err)) { if (U_FAILURE(err)) {
errln ((UnicodeString)"FAILURE! " + myErrorName(err)); errln ((UnicodeString)"FAILURE a! " + myErrorName(err));
return; return;
} }
someConverters[1] = new UnicodeConverter("ibm-1123",err); someConverters[1] = new UnicodeConverter("ibm-1123",err);
if (U_FAILURE(err)) { if (U_FAILURE(err)) {
errln ((UnicodeString)"FAILURE! " + myErrorName(err)); errln ((UnicodeString)"FAILURE b! " + myErrorName(err));
return; return;
} }
someConverters[2] = new UnicodeConverter("ibm-1123",err); someConverters[2] = new UnicodeConverter("ibm-1123",err);
if (U_FAILURE(err)) { if (U_FAILURE(err)) {
errln ((UnicodeString)"FAILURE! " + myErrorName(err)); errln ((UnicodeString)"FAILURE c! " + myErrorName(err));
return; return;
} }
someConverters[3] = new UnicodeConverter("ibm-834", err); someConverters[3] = new UnicodeConverter("ibm-834", err);
if (U_FAILURE(err)) { if (U_FAILURE(err)) {
errln ((UnicodeString)"FAILURE! " + myErrorName(err)); errln ((UnicodeString)"FAILURE d! " + myErrorName(err));
return; return;
} }
someConverters[4] = new UnicodeConverter("ibm-941", err); someConverters[4] = new UnicodeConverter("ibm-949", err);
if (U_FAILURE(err)) { if (U_FAILURE(err)) {
errln ((UnicodeString)"FAILURE! " + myErrorName(err)); errln ((UnicodeString)"FAILURE e! " + myErrorName(err));
return; return;
} }

View File

@ -396,32 +396,33 @@ void IntlTest::setICU_DATA() {
return; return;
} }
/* U_SRCDATADIR is set by the makefiles on UNIXes when building cintltst and intltst // U_TOPBUILDDIR is set by the makefiles on UNIXes when building cintltst and intltst
* to point to "wherever/icu/data" // to point to the top of the build hierarchy, which may or
* We can make a path from there to "wherever/icu/source/data" // may not be the same as the source directory, depending on
* The value is complete with quotes, so it can be used as-is as a string constant. // the configure options used. At any rate,
*/ // set the data path to the built data from this directory.
#if defined (U_SRCDATADIR) // The value is complete with quotes, so it can be used
// as-is as a string constant.
#if defined (U_TOPBUILDDIR)
{ {
static char env_string[] = U_SRCDATADIR "/../source/data/"; static char env_string[] = U_TOPBUILDDIR "/data/";
u_setDataDirectory(env_string); u_setDataDirectory(env_string);
return; return;
} }
#else #else
/* Use #else so we don't get compiler warnings due to the return above. // Use #else so we don't get compiler warnings due to the return above.
/* On Windows, the file name obtained from __FILE__ includes a full path. /* On Windows, the file name obtained from __FILE__ includes a full path.
* This file is "wherever\icu\source\test\cintltst\cintltst.c" * This file is "wherever\icu\source\test\cintltst\cintltst.c"
* Change to "wherever\icu\source\data" * Change to "wherever\icu\source\data"
*/ */
{ {
char p[sizeof(__FILE__) + 1]; char p[sizeof(__FILE__) + 10];
char *pBackSlash; char *pBackSlash;
int i; int i;
// p = new char [strlen("\\data") + strlen(__FILE__) + 1]; // <<< LEAK
// strcpy(p, "ICU_DATA=");
strcpy(p, __FILE__); strcpy(p, __FILE__);
/* We want to back over three '\' chars. */ /* We want to back over three '\' chars. */
/* Only Windows should end up here, so looking for '\' is safe. */ /* Only Windows should end up here, so looking for '\' is safe. */

View File

@ -58,13 +58,16 @@ void NormalizerConformanceTest::TestConformance(void) {
strcat(newPath, "unidata" U_FILE_SEP_STRING ); strcat(newPath, "unidata" U_FILE_SEP_STRING );
strcat(newPath, TEST_SUITE_FILE); strcat(newPath, TEST_SUITE_FILE);
strcpy(backupPath, u_getDataDirectory()); // As a fallback, try to guess where the source data was located
strcat(backupPath, ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data"); // at the time ICU was built, and look there.
strcat(backupPath, U_FILE_SEP_STRING); #if defined (U_TOPSRCDIR)
strcat(backupPath, "unidata" U_FILE_SEP_STRING ); strcpy(backupPath, U_TOPSRCDIR U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data");
strcat(backupPath, TEST_SUITE_FILE); #else
strcpy(backupPath, u_getDataDirectory());
strcat(backupPath, ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data");
#endif
strcat(backupPath, U_FILE_SEP_STRING "unidata" U_FILE_SEP_STRING TEST_SUITE_FILE);
input = T_FileStream_open(newPath, "rb"); input = T_FileStream_open(newPath, "rb");
if (input == 0) { if (input == 0) {

View File

@ -34,8 +34,8 @@ TransliteratorRoundTripTest::runIndexedTest(int32_t index, UBool exec,
CASE(1,TestKatakana); CASE(1,TestKatakana);
//CASE(2,TestArabic); //CASE(2,TestArabic);
//CASE(3,TestHebrew); //CASE(3,TestHebrew);
CASE(2,TestGreek); //CASE(2,TestGreek);
CASE(3,TestCyrillic); //CASE(3,TestCyrillic);
/* /*
CASE(7,TestJamo); CASE(7,TestJamo);
CASE(8,TestJamoHangul); CASE(8,TestJamoHangul);

View File

@ -476,8 +476,15 @@ void UnicodeTest::TestUnicodeData()
strcpy(newPath, u_getDataDirectory()); strcpy(newPath, u_getDataDirectory());
strcat(newPath, "unidata" U_FILE_SEP_STRING "UnicodeData.txt"); strcat(newPath, "unidata" U_FILE_SEP_STRING "UnicodeData.txt");
strcpy(backupPath, u_getDataDirectory());
strcat(backupPath, ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data"); // As a fallback, try to guess where the source data was located
// at the time ICU was built, and look there.
#if defined (U_TOPSRCDIR)
strcpy(backupPath, U_TOPSRCDIR U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data");
#else
strcpy(backupPath, u_getDataDirectory());
strcat(backupPath, ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data");
#endif
strcat(backupPath, U_FILE_SEP_STRING); strcat(backupPath, U_FILE_SEP_STRING);
strcat(backupPath, "unidata" U_FILE_SEP_STRING "UnicodeData.txt"); strcat(backupPath, "unidata" U_FILE_SEP_STRING "UnicodeData.txt");