diff options
author | Ron Yorston <rmy@pobox.com> | 2024-12-29 10:56:48 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-12-29 10:56:48 +0000 |
commit | c5e5da5eb1e0f6acee26bc22d2f567406a2840bc (patch) | |
tree | 5503adc914f0769dff6e212538589cbe99bfab75 | |
parent | 90c87dc65452889cd79debdc58d46fee76d17726 (diff) | |
download | busybox-w32-c5e5da5eb1e0f6acee26bc22d2f567406a2840bc.tar.gz busybox-w32-c5e5da5eb1e0f6acee26bc22d2f567406a2840bc.tar.bz2 busybox-w32-c5e5da5eb1e0f6acee26bc22d2f567406a2840bc.zip |
ash: strip trailing slash from directory if necessary
The previous commit removed trailing dots and spaces from the last
component of a pathname when changing directory. If the result has
a trailing slash remove that too. But not if it's a drive root,
to avoid 'cd C:/' showing a current directory of 'C:'.
Adds 48 bytes.
(GitHub issue #478)
-rw-r--r-- | win32/mingw.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 6842dba48..7a5198ccf 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -2189,6 +2189,11 @@ void FAST_FUNC strip_dot_space(char *p) | |||
2189 | while (end > start && (end[-1] == '.' || end[-1] == ' ')) { | 2189 | while (end > start && (end[-1] == '.' || end[-1] == ' ')) { |
2190 | *--end = '\0'; | 2190 | *--end = '\0'; |
2191 | } | 2191 | } |
2192 | |||
2193 | // Strip trailing slash, but not from a drive root (C:/) | ||
2194 | if (--end != start && (*end == '/' || *end == '\\') && | ||
2195 | !(end == p + 2 && root_len(p) == 2)) | ||
2196 | *end = '\0'; | ||
2192 | } | 2197 | } |
2193 | 2198 | ||
2194 | size_t FAST_FUNC remove_cr(char *p, size_t len) | 2199 | size_t FAST_FUNC remove_cr(char *p, size_t len) |