diff options
author | Ludovic Courtès <ludo@gnu.org> | 2017-06-15 17:44:57 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2017-06-15 17:48:12 +0200 |
commit | 155ddcdc3bfc0d5e87397f18cd4cfb2f062fbb75 (patch) | |
tree | 6f06a3128c558d574f8b58eb8ab31003baf888df /libguile/filesys.c | |
parent | d3fcefc3d5312d1499de0352f8f6e4c9838e0307 (diff) | |
download | guile-155ddcdc3bfc0d5e87397f18cd4cfb2f062fbb75.tar.gz |
Correctly relativize file names in the presence of common prefixes.
* libguile/filesys.c (scm_i_relativize_path): When DIR is a prefix of
SCANON, make sure DIR ends with a separator or SCANON starts with a
separator.
* test-suite/tests/ports.test (%temporary-directory): New variable.
("%file-port-name-canonicalization")["relative canonicalization with
common prefixes"]: New test.
Diffstat (limited to 'libguile/filesys.c')
-rw-r--r-- | libguile/filesys.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libguile/filesys.c b/libguile/filesys.c index f18560162..af283dd5e 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1,5 +1,5 @@ /* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006, - * 2009, 2010, 2011, 2012, 2013, 2014, 2016 Free Software Foundation, Inc. + * 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -1679,7 +1679,11 @@ scm_i_relativize_path (SCM path, SCM in_path) if (len > 0 && scm_is_true (scm_string_prefix_p (dir, scanon, SCM_UNDEFINED, SCM_UNDEFINED, - SCM_UNDEFINED, SCM_UNDEFINED))) + SCM_UNDEFINED, SCM_UNDEFINED)) + + /* Make sure SCANON starts with DIR followed by a separator. */ + && (is_file_name_separator (scm_c_string_ref (dir, len - 1)) + || is_file_name_separator (scm_c_string_ref (scanon, len)))) { /* DIR either has a trailing delimiter or doesn't. SCANON will be delimited by single delimiters. When DIR does not |