+ const char *treeChar;
+
+ UBool isICUData = FALSE;
+
+ if(path == NULL ||
+ !strcmp(path, U_ICUDATA_ALIAS) ||
+ !uprv_strncmp(path, U_ICUDATA_NAME U_TREE_SEPARATOR_STRING,
+ uprv_strlen(U_ICUDATA_NAME U_TREE_SEPARATOR_STRING)) ||
+ !uprv_strncmp(path, U_ICUDATA_ALIAS U_TREE_SEPARATOR_STRING,
+ uprv_strlen(U_ICUDATA_ALIAS U_TREE_SEPARATOR_STRING))) {
+ isICUData = TRUE;
+ }
+
+#if (U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR)
+ /* remap from alternate path char to the main one */
+ TinyString_init(&altSepPath);
+ if(path) {
+ char *p;
+ if((p=uprv_strchr(path,U_FILE_ALT_SEP_CHAR))) {
+ TinyString_append(&altSepPath, path);
+ while((p=uprv_strchr(altSepPath.s,U_FILE_ALT_SEP_CHAR))) {
+ *p = U_FILE_SEP_CHAR;
+ }
+#if defined (UDATA_DEBUG)
+ fprintf(stderr, "Changed path from [%s] to [%s]\n", path, altSepPath.s);
+#endif
+ path = altSepPath.s;
+ }
+ }
+#endif
+
+ TinyString_init(&oldIndFileName);
+ TinyString_init(&tocEntryName);
+ TinyString_init(&tocEntryPath);
+ TinyString_init(&oldStylePath);
+ TinyString_init(&oldStylePathBasename);
+
+ TinyString_init(&pkgName);
+ TinyString_init(&treeName);
+
+
+ if(path==NULL) {
+ TinyString_append(&pkgName, U_ICUDATA_NAME);
+ } else {
+ const char *pkg;
+ const char *first;
+ pkg = uprv_strrchr(path, U_FILE_SEP_CHAR);
+ first = uprv_strchr(path, U_FILE_SEP_CHAR);
+ if(uprv_pathIsAbsolute(path) || (pkg != first)) { /* more than one slash in the path- not a tree name */
+ /* see if this is an /absolute/path/to/package path */
+ if(pkg) {
+ TinyString_append(&pkgName, pkg+1);
+ } else {
+ TinyString_append(&pkgName, path);
+ }
+ } else {
+ treeChar = uprv_strchr(path, U_TREE_SEPARATOR);
+ if(treeChar) {
+ TinyString_append(&treeName, treeChar+1); /* following '-' */
+ if(!isICUData) {
+ TinyString_appendn(&pkgName, path, (int32_t)(treeChar-path));
+ } else {
+ TinyString_append(&pkgName, U_ICUDATA_NAME);
+ }
+ } else {
+ if(!isICUData) {
+ TinyString_append(&pkgName, path);
+ } else {
+ TinyString_append(&pkgName, U_ICUDATA_NAME);
+ }
+ }
+ }
+ }
+
+#ifdef UDATA_DEBUG
+ fprintf(stderr, " P=%s T=%s\n", pkgName.s, treeName.s);
+#endif
+
+ /* Make up a full name by appending the type to the supplied