View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014186CMakeCMakepublic2013-06-02 01:542013-11-04 09:33
ReporterYichao Yu 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformLinuxOSArchlinuxOS Version
Product VersionCMake 2.8.11 
Target VersionCMake 2.8.12Fixed in VersionCMake 2.8.12 
Summary0014186: get_filename_component(ABSOLUTE) return wrong value for parent dir of /
DescriptionOn unix-like system the parent directory of / should be / itself. However, get_filename_component return empty string for that case.
Steps To ReproduceIn (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 !!)
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0033195)
Brad King (manager)
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 (reporter)
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 (manager)
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 (manager)
2013-11-04 09:33

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2013-06-02 01:54 Yichao Yu New Issue
2013-06-03 09:08 Brad King Note Added: 0033195
2013-06-03 09:08 Brad King Assigned To => Brad King
2013-06-03 09:08 Brad King Status new => assigned
2013-06-03 09:08 Brad King Target Version => CMake 2.8.12
2013-06-03 09:09 Brad King Note Edited: 0033195
2013-06-03 09:55 Yichao Yu Note Added: 0033199
2013-06-03 23:56 Yichao Yu Note Edited: 0033199
2013-06-03 23:56 Yichao Yu Note Edited: 0033199
2013-06-04 09:17 Brad King Note Added: 0033228
2013-06-04 09:18 Brad King Status assigned => resolved
2013-06-04 09:18 Brad King Resolution open => fixed
2013-06-04 09:18 Brad King Fixed in Version => CMake 2.8.12
2013-11-04 09:33 Robert Maynard Note Added: 0034362
2013-11-04 09:33 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team