MantisBT - CMake
View Issue Details
0014186CMakeCMakepublic2013-06-02 01:542013-11-04 09:33
Yichao Yu 
Brad King 
normalminoralways
closedfixed 
LinuxArchlinux
CMake 2.8.11 
CMake 2.8.12CMake 2.8.12 
0014186: get_filename_component(ABSOLUTE) return wrong value for parent dir of /
On unix-like system the parent directory of / should be / itself. However, get_filename_component return empty string for that case.
In (sh-compatible) command line, type:
cmake -DINPUT='/../lib' -P /dev/stdin <<EOF
get_filename_component(abspath "\${INPUT}" ABSOLUTE)
message("\${abspath}")
EOF

expected output /lib
actual output lib (which is not an absolute path at all !!)
No tags attached.
Issue History
2013-06-02 01:54Yichao YuNew Issue
2013-06-03 09:08Brad KingNote Added: 0033195
2013-06-03 09:08Brad KingAssigned To => Brad King
2013-06-03 09:08Brad KingStatusnew => assigned
2013-06-03 09:08Brad KingTarget Version => CMake 2.8.12
2013-06-03 09:09Brad KingNote Edited: 0033195bug_revision_view_page.php?bugnote_id=33195#r1170
2013-06-03 09:55Yichao YuNote Added: 0033199
2013-06-03 23:56Yichao YuNote Edited: 0033199bug_revision_view_page.php?bugnote_id=33199#r1178
2013-06-03 23:56Yichao YuNote Edited: 0033199bug_revision_view_page.php?bugnote_id=33199#r1179
2013-06-04 09:17Brad KingNote Added: 0033228
2013-06-04 09:18Brad KingStatusassigned => resolved
2013-06-04 09:18Brad KingResolutionopen => fixed
2013-06-04 09:18Brad KingFixed in Version => CMake 2.8.12
2013-11-04 09:33Robert MaynardNote Added: 0034362
2013-11-04 09:33Robert MaynardStatusresolved => closed

Notes
(0033195)
Brad King   
2013-06-03 09:08   
(edited on: 2013-06-03 09:09)
Try this patch:

diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 158217e..ce4dfc8 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -3049,7 +3049,7 @@ SystemToolsAppendComponents(
     {
     if(*i == "..")
       {
- if(out_components.begin() != out_components.end())
+ if(out_components.size() > 1)
         {
         out_components.erase(out_components.end()-1, out_components.end());
         }

(0033199)
Yichao Yu   
2013-06-03 09:55   
(edited on: 2013-06-03 23:56)
yep, that works. (although there are some white space problems in the patch pasted....)

(0033228)
Brad King   
2013-06-04 09:17   
Patch applied to upstream KWSys here:

 http://public.kitware.com/gitweb?p=KWSys.git;a=commitdiff;h=d79a792e [^]

and imported into CMake here:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6dc3dd91 [^]

and test case added here:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d26800bc [^]
(0034362)
Robert Maynard   
2013-11-04 09:33   
Closing resolved issues that have not been updated in more than 4 months.