Skip to content

Commit

Permalink
Avoid converting slashes in root names in path::lexically_normal.
Browse files Browse the repository at this point in the history
lexically_normal is supposed to convert directory separators, so it
should not modify the path root name.
  • Loading branch information
Lastique committed Jan 3, 2024
1 parent d91f548 commit b8870c9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
3 changes: 2 additions & 1 deletion doc/release_history.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@

<h2>1.85.0</h2>
<ul>
<li><code>path::generic_path</code> and <code>path::generic_string</code> methods now remove duplicate directory separators in the returned paths. The methods also avoid converting backslashes to forward slashes in root names of the paths. For example, on Windows, <code>path("\\\\?\\c:\\foo").generic_string()</code> now returns "\\?\c:/foo" instead of "//?/c:/foo". Similarly, <code>path("\\\\host\\share").generic_string()</code> now returns "\\host/share".</li>
<li><code>path::generic_path</code> and <code>path::generic_string</code> methods now remove duplicate directory separators in the returned paths.</li>
<li><code>path::generic_path</code>, <code>path::generic_string</code> and <code>path::lexically_normal</code> avoid converting between backslashes and forward slashes in path root names. For example, on Windows, <code>path("\\\\?\\c:\\foo").generic_string()</code> now returns "\\?\c:/foo" instead of "//?/c:/foo". Similarly, <code>path("\\\\host/share/foo/..").lexically_normal()</code> now returns "\\host\share".</li>
</ul>

<h2>1.84.0</h2>
Expand Down
16 changes: 0 additions & 16 deletions src/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,6 @@ BOOST_FILESYSTEM_DECL path path_algorithms::lexically_normal_v3(path const& p)
size_type root_dir_pos = find_root_directory_start(pathname, pathname_size, root_name_size);
path normal(pathname, pathname + root_name_size);

#if defined(BOOST_WINDOWS_API)
for (size_type i = 0; i < root_name_size; ++i)
{
if (normal.m_pathname[i] == path::separator)
normal.m_pathname[i] = path::preferred_separator;
}
#endif

size_type root_path_size = root_name_size;
if (root_dir_pos < pathname_size)
{
Expand Down Expand Up @@ -272,14 +264,6 @@ BOOST_FILESYSTEM_DECL path path_algorithms::lexically_normal_v4(path const& p)
size_type root_dir_pos = find_root_directory_start(pathname, pathname_size, root_name_size);
path normal(pathname, pathname + root_name_size);

#if defined(BOOST_WINDOWS_API)
for (size_type i = 0; i < root_name_size; ++i)
{
if (normal.m_pathname[i] == path::separator)
normal.m_pathname[i] = path::preferred_separator;
}
#endif

size_type root_path_size = root_name_size;
if (root_dir_pos < pathname_size)
{
Expand Down

0 comments on commit b8870c9

Please sign in to comment.