diff options
author | Andy Wingo <wingo@pobox.com> | 2012-05-21 19:20:27 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2012-05-21 19:20:27 +0200 |
commit | 74bbb99457c661a98fbdde0c0504da1b3a053fc3 (patch) | |
tree | 654f0a4cf3d4f8441d2b2638f4d8af7adde24846 /libguile/filesys.c | |
parent | 730af462c387ce9cca30e84b8963edba10399d2e (diff) | |
parent | 15bb587f45b718f08756993fec9274212cc7df58 (diff) | |
download | guile-74bbb99457c661a98fbdde0c0504da1b3a053fc3.tar.gz |
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
module/language/tree-il/analyze.scm
module/language/tree-il/effects.scm
module/language/tree-il/fix-letrec.scm
module/language/tree-il/peval.scm
test-suite/tests/cse.test
test-suite/tests/peval.test
Diffstat (limited to 'libguile/filesys.c')
-rw-r--r-- | libguile/filesys.c | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/libguile/filesys.c b/libguile/filesys.c index a45a56488..8e90eed3e 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1587,32 +1587,40 @@ scm_i_relativize_path (SCM path, SCM in_path) scanon = scm_take_locale_string (canon); for (; scm_is_pair (in_path); in_path = scm_cdr (in_path)) - if (scm_is_true (scm_string_prefix_p (scm_car (in_path), - scanon, - SCM_UNDEFINED, SCM_UNDEFINED, - SCM_UNDEFINED, SCM_UNDEFINED))) - { - size_t len = scm_c_string_length (scm_car (in_path)); - - /* The path either has a trailing delimiter or doesn't. scanon will be - delimited by single delimiters. In the case in which the path does - not have a trailing delimiter, add one to the length to strip off the - delimiter within scanon. */ - if (!len + { + SCM dir = scm_car (in_path); + size_t len = scm_c_string_length (dir); + + /* When DIR is empty, it means "current working directory". We + could set DIR to (getcwd) in that case, but then the + canonicalization would depend on the current directory, which + is not what we want in the context of `compile-file', for + instance. */ + if (len > 0 + && scm_is_true (scm_string_prefix_p (dir, scanon, + SCM_UNDEFINED, SCM_UNDEFINED, + SCM_UNDEFINED, SCM_UNDEFINED))) + { + /* DIR either has a trailing delimiter or doesn't. SCANON + will be delimited by single delimiters. When DIR does not + have a trailing delimiter, add one to the length to strip + off the delimiter within SCANON. */ + if ( #ifdef __MINGW32__ - || (scm_i_string_ref (scm_car (in_path), len - 1) != '/' - && scm_i_string_ref (scm_car (in_path), len - 1) != '\\') + (scm_i_string_ref (dir, len - 1) != '/' + && scm_i_string_ref (dir, len - 1) != '\\') #else - || scm_i_string_ref (scm_car (in_path), len - 1) != '/' + scm_i_string_ref (dir, len - 1) != '/' #endif - ) - len++; + ) + len++; - if (scm_c_string_length (scanon) > len) - return scm_substring (scanon, scm_from_size_t (len), SCM_UNDEFINED); - else - return SCM_BOOL_F; - } + if (scm_c_string_length (scanon) > len) + return scm_substring (scanon, scm_from_size_t (len), SCM_UNDEFINED); + else + return SCM_BOOL_F; + } + } return SCM_BOOL_F; } |