| 205 | // normal --------------------------------------------------------------------------// |
| 206 | |
| 207 | BOOST_FILESYSTEM_DECL path path_algorithms::lexically_normal_v3(path const& p) |
| 208 | { |
| 209 | const value_type* const pathname = p.m_pathname.c_str(); |
| 210 | const size_type pathname_size = p.m_pathname.size(); |
| 211 | size_type root_name_size = 0; |
| 212 | size_type root_dir_pos = find_root_directory_start(pathname, pathname_size, root_name_size); |
| 213 | path normal(pathname, pathname + root_name_size); |
| 214 | |
| 215 | #if defined(BOOST_FILESYSTEM_WINDOWS_API) |
| 216 | for (size_type i = 0; i < root_name_size; ++i) |
| 217 | { |
| 218 | if (normal.m_pathname[i] == path::separator) |
| 219 | normal.m_pathname[i] = path::preferred_separator; |
| 220 | } |
| 221 | #endif |
| 222 | |
| 223 | size_type root_path_size = root_name_size; |
| 224 | if (root_dir_pos < pathname_size) |
| 225 | { |
| 226 | root_path_size = root_dir_pos + 1; |
| 227 | normal.m_pathname.push_back(path::preferred_separator); |
| 228 | } |
| 229 | |
| 230 | size_type i = root_path_size; |
| 231 | |
| 232 | // Skip redundant directory separators after the root directory |
| 233 | while (i < pathname_size && detail::is_directory_separator(pathname[i])) |
| 234 | ++i; |
| 235 | |
| 236 | if (i < pathname_size) |
| 237 | { |
| 238 | bool last_element_was_dot = false; |
| 239 | while (true) |
| 240 | { |
| 241 | { |
| 242 | const size_type start_pos = i; |
| 243 | |
| 244 | // Find next separator |
| 245 | i += find_separator(pathname + i, pathname_size - i); |
| 246 | |
| 247 | const size_type size = i - start_pos; |
| 248 | |
| 249 | // Skip dot elements |
| 250 | if (size == 1u && pathname[start_pos] == path::dot) |
| 251 | { |
| 252 | last_element_was_dot = true; |
| 253 | goto skip_append; |
| 254 | } |
| 255 | |
| 256 | last_element_was_dot = false; |
| 257 | |
| 258 | // Process dot dot elements |
| 259 | if (size == 2u && pathname[start_pos] == path::dot && pathname[start_pos + 1] == path::dot && normal.m_pathname.size() > root_path_size) |
| 260 | { |
| 261 | // Don't remove previous dot dot elements |
| 262 | const size_type normal_size = normal.m_pathname.size(); |
| 263 | size_type filename_size = find_filename_size(normal.m_pathname, root_path_size, normal_size); |
| 264 | size_type pos = normal_size - filename_size; |
nothing calls this directly
no test coverage detected