aboutsummaryrefslogtreecommitdiffhomepage
path: root/path.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2007-05-11 05:11:28 +1000
committerGravatar axel <axel@liljencrantz.se>2007-05-11 05:11:28 +1000
commite4f5bc69e29b88796b13eb117dde098695dad9b9 (patch)
tree260c37e0361e4d9a119f6cb478f1d4fe064706ee /path.c
parent03f322c7152c8f10805a0b8a75bf517e88fdf427 (diff)
Make sure that the PWD and HOME variables are always in canonical form
darcs-hash:20070510191128-ac50b-dd51a75617d62e4f403094ddc7527a82c5de3103.gz
Diffstat (limited to 'path.c')
-rw-r--r--path.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/path.c b/path.c
index 469c702c..7cb3e0a5 100644
--- a/path.c
+++ b/path.c
@@ -266,3 +266,38 @@ wchar_t *path_get_config( void *context)
}
+wchar_t *path_make_canonical( void *context, const wchar_t *path )
+{
+ wchar_t *res = halloc_wcsdup( context, path );
+ wchar_t *in, *out;
+
+ in = out = res;
+
+ while( *in )
+ {
+ if( *in == L'/' )
+ {
+ while( *(in+1) == L'/' )
+ {
+ in++;
+ }
+ }
+ *out = *in;
+
+ out++;
+ in++;
+ }
+
+ while( 1 )
+ {
+ if( out == res )
+ break;
+ if( *(out-1) != L'/' )
+ break;
+ out--;
+ }
+ *out = 0;
+
+ return res;
+}
+