1. | If the path is empty, stop. |
2. | |
3. | [Note 4: The generic pathname grammar defines directory-separator as one or more slashes and preferred-separators. — end note] |
4. | Remove each dot filename and any immediately following directory-separator. |
5. | As long as any appear, remove a non-dot-dot filename immediately followed by a directory-separator and a dot-dot filename, along with any immediately following directory-separator. |
6. | If there is a root-directory, remove all dot-dot filenames and any directory-separators immediately following them. |
7. | If the last filename is dot-dot, remove any trailing directory-separator. |
8. | If the path is empty, add a dot. |