1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Back out check-in (6380). Replace it with a proper fix to the

xFullPathname method in the async VFS. (CVS 6398)

FossilOrigin-Name: 767a7f7b55456df404a7f8966a0c48318ddac120
This commit is contained in:
drh
2009-03-28 15:04:24 +00:00
parent ac86169fff
commit 94dfe476fa
6 changed files with 40 additions and 63 deletions

View File

@@ -10,7 +10,7 @@
**
*************************************************************************
**
** $Id: test_async.c,v 1.53 2009/03/27 09:10:12 danielk1977 Exp $
** $Id: test_async.c,v 1.54 2009/03/28 15:04:24 drh Exp $
**
** This file contains an example implementation of an asynchronous IO
** backend for SQLite.
@@ -1285,40 +1285,27 @@ static int asyncFullPathname(
** file-system uses unix style paths.
*/
if( rc==SQLITE_OK ){
int iIn;
int iOut = 0;
int nPathOut = strlen(zPathOut);
for(iIn=0; iIn<nPathOut; iIn++){
/* Replace any occurences of "//" with "/" */
if( iIn<=(nPathOut-2) && zPathOut[iIn]=='/' && zPathOut[iIn+1]=='/'
){
continue;
int i, j;
int n = nPathOut;
char *z = zPathOut;
while( n>1 && z[n-1]=='/' ){ n--; }
for(i=j=0; i<n; i++){
if( z[i]=='/' ){
if( z[i+1]=='/' ) continue;
if( z[i+1]=='.' && i+2<n && z[i+2]=='/' ){
i += 1;
continue;
}
if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){
while( j>0 && z[j-1]!='/' ){ j--; }
if( j>0 ){ j--; }
i += 2;
continue;
}
}
/* Replace any occurences of "/./" with "/" */
if( iIn<=(nPathOut-3)
&& zPathOut[iIn]=='/' && zPathOut[iIn+1]=='.' && zPathOut[iIn+2]=='/'
){
iIn++;
continue;
}
/* Replace any occurences of "<path-component>/../" with "" */
if( iOut>0 && iIn<=(nPathOut-4)
&& zPathOut[iIn]=='/' && zPathOut[iIn+1]=='.'
&& zPathOut[iIn+2]=='.' && zPathOut[iIn+3]=='/'
){
iIn += 3;
iOut--;
for( ; iOut>0 && zPathOut[iOut-1]!='/'; iOut--);
continue;
}
zPathOut[iOut++] = zPathOut[iIn];
z[j++] = z[i];
}
zPathOut[iOut] = '\0';
z[j] = 0;
}
return rc;