Changeset 545 in kBuild for trunk/src/gmake/w32
- Timestamp:
- Sep 20, 2006 5:56:19 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmake/w32/pathstuff.c
r532 r545 90 90 w32_fixcase(char *pszPath) 91 91 { 92 static char s_szLast[260]; 93 unsigned cchLast; 94 92 95 #ifndef NDEBUG 93 96 # define my_assert(expr) \ … … 151 154 152 155 /* 153 * Pointing to the first char after the unc or drive specifier. 156 * Try make use of the result from the previous call. 157 * This is ignorant to slashes and similar, but may help even so. 158 */ 159 if ( s_szLast[0] == pszPath[0] 160 && (psz - pszPath == 1 || s_szLast[1] == pszPath[1]) 161 && (psz - pszPath <= 2 || s_szLast[2] == pszPath[2]) 162 ) 163 { 164 char *pszLast = &s_szLast[psz - pszPath]; 165 char *pszCur = psz; 166 for (;;) 167 { 168 const char ch1 = *pszCur; 169 const char ch2 = *pszLast; 170 if ( ch1 != ch2 171 && (ch1 != '\\' || ch2 != '/') 172 && (ch1 != '/' || ch2 != '\\')) 173 { 174 if ( tolower(ch1) != tolower(ch2) 175 && toupper(ch1) != toupper(ch2)) 176 break; 177 /* optimistic, component mismatch will be corrected in the next loop. */ 178 *pszCur = ch2; 179 } 180 if (ch1 == '/' || ch1 == '\\') 181 psz = pszCur + 1; 182 else if (ch1 == '\0') 183 { 184 psz = pszCur; 185 break; 186 } 187 pszCur++; 188 pszLast++; 189 } 190 } 191 192 /* 193 * Pointing to the first char after the unc or drive specifier, 194 * or in case of a cache hit, the first non-matching char (following a slash of course). 154 195 */ 155 196 while (*psz) … … 178 219 if (!hDir) 179 220 { 221 cchLast = psz - pszPath; 222 memcpy(s_szLast, pszPath, cchLast + 1); 180 223 pszEnd[0] = chSaved0; 181 224 return; … … 186 229 if (!FindNextFile(hDir, &FindFileData)) 187 230 { 231 cchLast = psz - pszPath; 232 memcpy(s_szLast, pszPath, cchLast + 1); 188 233 pszEnd[0] = chSaved0; 189 234 return; … … 195 240 /* advance to the next component */ 196 241 if (!chSaved0) 197 return; 242 { 243 psz = pszEnd; 244 break; 245 } 198 246 psz = pszEnd + 1; 199 247 my_assert(*psz != '/' && *psz != '\\'); 200 248 } 249 250 /* *psz == '\0', the end. */ 251 cchLast = psz - pszPath; 252 memcpy(s_szLast, pszPath, cchLast + 1); 201 253 #undef my_assert 202 254 }
Note:
See TracChangeset
for help on using the changeset viewer.