diff options
author | 2007-05-11 05:11:28 +1000 | |
---|---|---|
committer | 2007-05-11 05:11:28 +1000 | |
commit | e4f5bc69e29b88796b13eb117dde098695dad9b9 (patch) | |
tree | 260c37e0361e4d9a119f6cb478f1d4fe064706ee /path.c | |
parent | 03f322c7152c8f10805a0b8a75bf517e88fdf427 (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.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -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; +} + |