File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -218,8 +218,8 @@ mod test {
218218    #[ test]  
219219    fn  test_prefix_rpath ( )  { 
220220        let  res = get_install_prefix_rpath ( "/usr/lib" ,  "triple" ) ; 
221-         assert str :: ends_with ( res ,   #env ( "CFG_PREFIX" ) 
222-                               +  "/lib/rustc/triple/lib" ) ; 
221+         let  d = fs :: connect ( #env ( "CFG_PREFIX" ) ,   "/lib/rustc/triple/lib" ) ; 
222+         assert str :: ends_with ( res ,  d ) ; 
223223    } 
224224
225225    #[ test]  
Original file line number Diff line number Diff line change @@ -81,17 +81,20 @@ Function: connect
8181
8282Connects to path segments 
8383
84- Given paths `pre` and `post` this function will return a path  
85- that is equal to  `post` appended to `pre`, inserting a path separator 
86- between the two as needed .
84+ Given paths `pre` and `post, removes any trailing path separator on `pre` and  
85+ any leading path separator on  `post`, and returns the concatenation of the two 
86+ with a single path separator between them .
8787*/ 
88- fn  connect ( pre :  path ,  post :  path )  -> path  { 
89-     let  len = str:: byte_len ( pre) ; 
90-     ret  if  pre[ len - 1 u]  == os_fs:: path_sep as  u8  { 
9188
92-             // Trailing '/'? 
93-             pre + post
94-         }  else  {  pre + path_sep ( )  + post } ; 
89+ fn  connect ( pre :  path ,  post :  path )  -> path  { 
90+     let  pre_ = pre; 
91+     let  post_ = post; 
92+     let  sep = os_fs:: path_sep as  u8 ; 
93+     let  pre_len = str:: byte_len ( pre) ; 
94+     let  post_len = str:: byte_len ( post) ; 
95+     if  pre_len > 1 u && pre[ pre_len-1 u]  == sep {  str:: pop_byte ( pre_) ;  } 
96+     if  post_len > 1 u && post[ 0 ]  == sep {  str:: shift_byte ( post_) ;  } 
97+     ret pre_ + path_sep ( )  + post_; 
9598} 
9699
97100/* 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments