Changeset 76660 in vbox for trunk/src/VBox/Runtime/common/path/RTPathCalcRelative.cpp
- Timestamp:
- Jan 6, 2019 7:11:08 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/path/RTPathCalcRelative.cpp
r76595 r76660 33 33 34 34 #include <iprt/assert.h> 35 #if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS36 # include <iprt/ctype.h>37 #endif38 35 #include <iprt/errcore.h> 39 36 #include <iprt/string.h> 37 #if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS 38 # include <iprt/uni.h> 39 #endif 40 40 #include "internal/path.h" 41 41 42 43 #if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS 44 /** Helper for doing case insensitive comparison of a mismatching codepoint. */ 45 DECLINLINE(bool) rtPathCalcRelativeEqualICaseCodepoint(const char *pszPathFromStart, const char *pszPathFrom, 46 const char *pszPathToStart, const char *pszPathTo) 47 { 48 RTUNICP ucFrom = RTStrGetCp(RTStrPrevCp(pszPathFromStart, pszPathFrom)); 49 RTUNICP ucTo = RTStrGetCp(RTStrPrevCp(pszPathToStart, pszPathTo)); 50 return ucFrom == ucTo 51 || RTUniCpToLower(ucFrom) == RTUniCpToLower(ucTo) 52 || RTUniCpToUpper(ucFrom) == RTUniCpToUpper(ucTo); 53 } 54 #endif 42 55 43 56 … … 50 63 AssertPtrReturn(pszPathFrom, VERR_INVALID_POINTER); 51 64 AssertPtrReturn(pszPathTo, VERR_INVALID_POINTER); 65 #if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS 66 const char * const pszPathFromStart = pszPathFrom; 67 const char * const pszPathToStart = pszPathTo; 68 #endif 52 69 53 70 /* … … 70 87 #else 71 88 if (RTStrNICmp(pszPathFrom, pszPathTo, offRootFrom)) 72 for (size_t off = 0; off < offRootFrom; off++) 73 { 74 char const chFrom = pszPathFrom[off]; 75 char const chTo = pszPathTo[off]; 76 if ( chFrom != chTo 77 && RT_C_TO_LOWER(chFrom) != RT_C_TO_LOWER(chTo) /** @todo proper case insensitivity! */ 78 && (!RTPATH_IS_SLASH(chFrom) || !RTPATH_IS_SLASH(chTo)) ) 89 { 90 const char *pszFromCursor = pszPathFrom; 91 const char *pszToCursor = pszPathTo; 92 while ((size_t)(pszFromCursor - pszPathFrom) < offRootFrom) 93 { 94 RTUNICP ucFrom; 95 int rc = RTStrGetCpEx(&pszFromCursor, &ucFrom); 96 AssertRCReturn(rc, rc); 97 98 RTUNICP ucTo; 99 rc = RTStrGetCpEx(&pszToCursor, &ucTo); 100 AssertRCReturn(rc, rc); 101 if ( ucFrom != ucTo 102 && RTUniCpToLower(ucFrom) != RTUniCpToLower(ucTo) 103 && RTUniCpToUpper(ucFrom) != RTUniCpToUpper(ucTo) 104 && (!RTPATH_IS_SLASH(ucFrom) || !RTPATH_IS_SLASH(ucTo)) ) 79 105 return VERR_NOT_SUPPORTED; 80 106 } 107 } 81 108 #endif 82 109 … … 120 147 } 121 148 #if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS 122 else if ( RT_C_TO_LOWER(chFrom) == RT_C_TO_LOWER(chTo))149 else if (rtPathCalcRelativeEqualICaseCodepoint(pszPathFromStart, pszPathFrom + 1, pszPathToStart, pszPathTo + 1)) 123 150 { /* if not likely, then simpler code structure wise. */ } 124 151 #endif
Note:
See TracChangeset
for help on using the changeset viewer.