Lines 166-177
Link Here
|
166 |
register char *p; |
166 |
register char *p; |
167 |
register char *q; |
167 |
register char *q; |
168 |
char *tpath; |
168 |
char *tpath; |
|
|
169 |
int hasdriveletter = 0; |
170 |
|
171 |
DB_ENTER( "Clean_path" ); |
169 |
|
172 |
|
170 |
/* Skip the root part. */ |
173 |
/* Skip the root part. */ |
171 |
tpath=path; |
174 |
tpath=path; |
|
|
175 |
|
172 |
#ifdef HAVE_DRIVE_LETTERS |
176 |
#ifdef HAVE_DRIVE_LETTERS |
173 |
if( *tpath && tpath[1] == ':' && isalpha(*tpath) ) |
|
|
174 |
tpath+=2; |
175 |
|
177 |
|
176 |
/* Change all occurences from DirBrkStr to *DirSepStr. */ |
178 |
/* Change all occurences from DirBrkStr to *DirSepStr. */ |
177 |
#if __CYGWIN__ |
179 |
#if __CYGWIN__ |
Lines 181-187
Link Here
|
181 |
for( q = tpath; (q = strchr(q, '/')) != NIL(char); ) |
183 |
for( q = tpath; (q = strchr(q, '/')) != NIL(char); ) |
182 |
*q = *DirSepStr; |
184 |
*q = *DirSepStr; |
183 |
#endif |
185 |
#endif |
|
|
186 |
/* The following dosn't trigger often because _normalize_path() uses |
187 |
* a cygwin function and bypasses Clean_path() if it encounters a path |
188 |
* with a drive letter. */ |
189 |
if( *tpath && tpath[1] == ':' && isalpha(*tpath) ) { |
190 |
hasdriveletter = 1; |
191 |
tpath+=2; |
192 |
if( *tpath != *DirSepStr ) |
193 |
Warning("Malformed DOS path %s", path); |
194 |
} |
195 |
|
184 |
#endif |
196 |
#endif |
|
|
197 |
|
198 |
/* Collapse > 2 ( > 1 if its an absolute DOS path ) into one slash. |
199 |
* Keep // as it is reserved in posix. */ |
200 |
q = tpath; |
201 |
for( ; *q == *DirSepStr ; ++q ) |
202 |
; |
203 |
if( q - tpath > 2 - hasdriveletter ) { |
204 |
strcpy(tpath+1, q); |
205 |
} |
206 |
|
207 |
/* Set tpath after leading slash / drive letter. */ |
185 |
for( ; *tpath == *DirSepStr ; ++tpath ) |
208 |
for( ; *tpath == *DirSepStr ; ++tpath ) |
186 |
; |
209 |
; |
187 |
q = tpath; |
210 |
q = tpath; |
Lines 204-211
Link Here
|
204 |
continue; |
227 |
continue; |
205 |
} |
228 |
} |
206 |
|
229 |
|
207 |
/* Remove './' */ |
230 |
/* Remove './'. If OOOSPECIAL is set do this only if it is not at |
208 |
if ( p-q == 1 && *q == '.' ) { |
231 |
* the start of the path. */ |
|
|
232 |
if ( p-q == 1 && *q == '.' && (q != path || !STOBOOL(OOoSpecial)) ) { |
209 |
strcpy(q,p+1); |
233 |
strcpy(q,p+1); |
210 |
q = tpath; |
234 |
q = tpath; |
211 |
continue; |
235 |
continue; |
Lines 230-235
Link Here
|
230 |
q = p+1; |
254 |
q = p+1; |
231 |
} |
255 |
} |
232 |
|
256 |
|
233 |
DB_PRINT( "path", ("path: %s", path )); |
257 |
DB_PRINT( "path", ("Cleaned path: %s", path )); |
234 |
return; |
258 |
|
|
|
259 |
DB_VOID_RETURN; |
235 |
} |
260 |
} |