Fossil SCM

Fix to the pathname simplifer logic.

drh 2008-11-21 22:16 trunk
Commit d31c0f9c29b27aa9deaae9adde86a94cebc2e43d
1 file changed +3 -2
+3 -2
--- src/file.c
+++ src/file.c
@@ -207,11 +207,11 @@
207207
/*
208208
** Simplify a filename by
209209
**
210210
** * removing any trailing and duplicate /
211211
** * removing /./
212
-** * removing /A/./
212
+** * removing /A/../
213213
**
214214
** Changes are made in-place. Return the new name length.
215215
*/
216216
int file_simplify_name(char *z, int n){
217217
int i, j;
@@ -223,11 +223,12 @@
223223
i += 1;
224224
continue;
225225
}
226226
if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){
227227
while( j>0 && z[j-1]!='/' ){ j--; }
228
- i += 3;
228
+ if( j>0 ){ j--; }
229
+ i += 2;
229230
continue;
230231
}
231232
}
232233
z[j++] = z[i];
233234
}
234235
--- src/file.c
+++ src/file.c
@@ -207,11 +207,11 @@
207 /*
208 ** Simplify a filename by
209 **
210 ** * removing any trailing and duplicate /
211 ** * removing /./
212 ** * removing /A/./
213 **
214 ** Changes are made in-place. Return the new name length.
215 */
216 int file_simplify_name(char *z, int n){
217 int i, j;
@@ -223,11 +223,12 @@
223 i += 1;
224 continue;
225 }
226 if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){
227 while( j>0 && z[j-1]!='/' ){ j--; }
228 i += 3;
 
229 continue;
230 }
231 }
232 z[j++] = z[i];
233 }
234
--- src/file.c
+++ src/file.c
@@ -207,11 +207,11 @@
207 /*
208 ** Simplify a filename by
209 **
210 ** * removing any trailing and duplicate /
211 ** * removing /./
212 ** * removing /A/../
213 **
214 ** Changes are made in-place. Return the new name length.
215 */
216 int file_simplify_name(char *z, int n){
217 int i, j;
@@ -223,11 +223,12 @@
223 i += 1;
224 continue;
225 }
226 if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){
227 while( j>0 && z[j-1]!='/' ){ j--; }
228 if( j>0 ){ j--; }
229 i += 2;
230 continue;
231 }
232 }
233 z[j++] = z[i];
234 }
235

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button