From cbf0d0fbcdc9085f062b2bfa18237456a41c3877 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Thu, 15 May 2003 18:38:58 +0000 Subject: [PATCH] ICU-2850 Fix a bug for MSVC 7 X-SVN-Rev: 11937 --- icu4c/source/test/intltest/intltest.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/icu4c/source/test/intltest/intltest.cpp b/icu4c/source/test/intltest/intltest.cpp index 34dc22a03b..68ae1749a8 100644 --- a/icu4c/source/test/intltest/intltest.cpp +++ b/icu4c/source/test/intltest/intltest.cpp @@ -1224,22 +1224,20 @@ const char* IntlTest::loadTestData(UErrorCode& err){ strcpy(p, __FILE__); /* We want to back over three '\' chars. */ /* Only Windows should end up here, so looking for '\' is safe. */ - if (strrchr(p, U_FILE_SEP_CHAR) != NULL) { - for (i=1; i<=3; i++) { - pBackSlash = strrchr(p, U_FILE_SEP_CHAR); - if (pBackSlash != NULL) { - *pBackSlash = 0; /* Truncate the string at the '\' */ - } - } - + for (i=1; i<=3; i++) { + pBackSlash = strrchr(p, U_FILE_SEP_CHAR); if (pBackSlash != NULL) { - /* We found and truncated three names from the path. - * Now append "source\data" and set the environment - */ - strcpy(pBackSlash, U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata"); - directory = p; + *pBackSlash = 0; /* Truncate the string at the '\' */ } } + + if (pBackSlash != NULL) { + /* We found and truncated three names from the path. + * Now append "source\data" and set the environment + */ + strcpy(pBackSlash, U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata"); + directory = p; + } else { /* __FILE__ on MSVC7 does not contain the directory */ directory = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;