mirror of git://gcc.gnu.org/git/gcc.git
				
				
				
			Apply resolution for LWG DR 3096
Add fix for "path::lexically_relative is confused by trailing slashes". * doc/xml/manual/intro.xml: Document LWG 3096 change. * src/filesystem/std-path.cc (path::lexically_relative(const path&)): Treat a final empty element equivalently to a final dot element. * testsuite/27_io/filesystem/path/generation/relative.cc: Add checks for the examples in the DR. From-SVN: r266566
This commit is contained in:
		
							parent
							
								
									24d9b090fb
								
							
						
					
					
						commit
						bd6ccc290a
					
				|  | @ -1,5 +1,11 @@ | |||
| 2018-11-28  Jonathan Wakely  <jwakely@redhat.com> | ||||
| 
 | ||||
| 	* doc/xml/manual/intro.xml: Document LWG 3096 change. | ||||
| 	* src/filesystem/std-path.cc (path::lexically_relative(const path&)): | ||||
| 	Treat a final empty element equivalently to a final dot element. | ||||
| 	* testsuite/27_io/filesystem/path/generation/relative.cc: Add checks | ||||
| 	for the examples in the DR. | ||||
| 
 | ||||
| 	PR libstdc++/83306 | ||||
| 	* include/bits/fs_path.h (filesystem_error): Move data members into | ||||
| 	pimpl class owned by shared_ptr. Remove inline definitions of member | ||||
|  |  | |||
|  | @ -1194,6 +1194,13 @@ requirements of the license of GCC. | |||
|     <listitem><para>Change constructors to constrained templates. | ||||
|     </para></listitem></varlistentry> | ||||
| 
 | ||||
|     <varlistentry xml:id="manual.bugs.dr3096"><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&DR;#3096">3096</link>: | ||||
|        <emphasis><code>path::lexically_relative</code> is confused by trailing slashes | ||||
|        </emphasis> | ||||
|     </term> | ||||
|     <listitem><para>Implement the fix for trailing slashes. | ||||
|     </para></listitem></varlistentry> | ||||
| 
 | ||||
|   </variablelist> | ||||
| 
 | ||||
|  </section> | ||||
|  |  | |||
|  | @ -529,10 +529,12 @@ path::lexically_relative(const path& base) const | |||
|       const path& p = *b; | ||||
|       if (is_dotdot(p)) | ||||
| 	--n; | ||||
|       else if (!is_dot(p)) | ||||
|       else if (!p.empty() && !is_dot(p)) | ||||
| 	++n; | ||||
|     } | ||||
|     if (n >= 0) | ||||
|     if (n == 0 && (a == end() || a->empty())) | ||||
|       ret = "."; | ||||
|     else if (n >= 0) | ||||
|     { | ||||
|       const path dotdot(".."); | ||||
|       while (n--) | ||||
|  |  | |||
|  | @ -45,6 +45,25 @@ test02() | |||
|   compare_paths( p.lexically_relative(p), "." ); | ||||
|   compare_paths( p.lexically_relative("a/../a/b/../b/c/../c/."), "../../b/c" ); | ||||
|   compare_paths( p.lexically_relative("../../../"), "" ); | ||||
| 
 | ||||
|   compare_paths( path("a/./.").lexically_relative("a"), "./." ); | ||||
| } | ||||
| 
 | ||||
| void | ||||
| test03() | ||||
| { | ||||
|   // LWG 3096
 | ||||
|   compare_paths( path("/dir").lexically_relative("/dir"), "." ); | ||||
|   compare_paths( path("/dir").lexically_relative("/dir/"), "." ); | ||||
|   compare_paths( path("/dir").lexically_relative("/dir/."), "." ); | ||||
| 
 | ||||
|   compare_paths( path("/dir/").lexically_relative("/dir"), "." ); | ||||
|   compare_paths( path("/dir/").lexically_relative("/dir/"), "." ); | ||||
|   compare_paths( path("/dir/").lexically_relative("/dir/."), "." ); | ||||
| 
 | ||||
|   compare_paths( path("/dir/.").lexically_relative("/dir"), "." ); | ||||
|   compare_paths( path("/dir/.").lexically_relative("/dir/"), "." ); | ||||
|   compare_paths( path("/dir/.").lexically_relative("/dir/."), "." ); | ||||
| } | ||||
| 
 | ||||
| int | ||||
|  | @ -52,4 +71,5 @@ main() | |||
| { | ||||
|   test01(); | ||||
|   test02(); | ||||
|   test03(); | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Jonathan Wakely
						Jonathan Wakely