diff options
author | drh <drh@noemail.net> | 2009-03-28 15:04:24 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2009-03-28 15:04:24 +0000 |
commit | 94dfe476fa32b6b56787ba3e564d0f712513ed22 (patch) | |
tree | ace9f83c8d6b34587be179654014127b2759ab75 /src/test_async.c | |
parent | ac86169fff3804caff3760804d0aa741b696e13e (diff) | |
download | sqlite-94dfe476fa32b6b56787ba3e564d0f712513ed22.tar.gz sqlite-94dfe476fa32b6b56787ba3e564d0f712513ed22.zip |
Back out check-in (6380). Replace it with a proper fix to the
xFullPathname method in the async VFS. (CVS 6398)
FossilOrigin-Name: 767a7f7b55456df404a7f8966a0c48318ddac120
Diffstat (limited to 'src/test_async.c')
-rw-r--r-- | src/test_async.c | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/src/test_async.c b/src/test_async.c index 3ff29b8b7..9cd5957cc 100644 --- a/src/test_async.c +++ b/src/test_async.c @@ -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; - } - - /* 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; + 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; + } } - - zPathOut[iOut++] = zPathOut[iIn]; + z[j++] = z[i]; } - zPathOut[iOut] = '\0'; + z[j] = 0; } return rc; |