aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2006-02-13 17:03:47 +0000
committerdrh <drh@noemail.net>2006-02-13 17:03:47 +0000
commit89ea93121d010660a0d7da134082d5042d83770c (patch)
tree2bcb8826d80c28c34a00567d404776c5fce23c26 /src/os_unix.c
parent99681dbbdb64e44cc4385ba351bb7c22dca6e304 (diff)
downloadsqlite-89ea93121d010660a0d7da134082d5042d83770c.tar.gz
sqlite-89ea93121d010660a0d7da134082d5042d83770c.zip
Add in-process file locking to test_async.c. The unix implementation of
sqlite3OsFullPathname() now attempts to remove /./ and /../ elements from the path. (CVS 3090) FossilOrigin-Name: 42379c623073eb541d053c2dff9f49087fb290f8
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index f7adab2b2..6621625ac 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -1539,6 +1539,7 @@ static int unixClose(OsFile **pId){
*/
char *sqlite3UnixFullPathname(const char *zRelative){
char *zFull = 0;
+ int i, j;
if( zRelative[0]=='/' ){
sqlite3SetString(&zFull, zRelative, (char*)0);
}else{
@@ -1551,6 +1552,28 @@ char *sqlite3UnixFullPathname(const char *zRelative){
(char*)0);
sqliteFree(zBuf);
}
+ /*
+ ** Remove "/./" path elements and convert "/A/./" path elements
+ ** to just "/".
+ */
+ if( zFull ){
+ for(i=j=0; zFull[i]; i++){
+ if( zFull[i]=='/' ){
+ if( zFull[i+1]=='/' ) continue;
+ if( zFull[i+1]=='.' && zFull[i+2]=='/' ){
+ i += 1;
+ continue;
+ }
+ if( zFull[i+1]=='.' && zFull[i+2]=='.' && zFull[i+3]=='/' ){
+ while( j>0 && zFull[j-1]!='/' ){ j--; }
+ i += 3;
+ continue;
+ }
+ }
+ zFull[j++] = zFull[i];
+ }
+ zFull[j] = 0;
+ }
return zFull;
}