removes the last path component from 'path' except if 'path' is root */
| 15 | |
| 16 | /* removes the last path component from 'path' except if 'path' is root */ |
| 17 | static void strip_last_component(struct strbuf *path) |
| 18 | { |
| 19 | size_t offset = offset_1st_component(path->buf); |
| 20 | size_t len = path->len; |
| 21 | |
| 22 | /* Find start of the last component */ |
| 23 | while (offset < len && !is_dir_sep(path->buf[len - 1])) |
| 24 | len--; |
| 25 | /* Skip sequences of multiple path-separators */ |
| 26 | while (offset < len && is_dir_sep(path->buf[len - 1])) |
| 27 | len--; |
| 28 | |
| 29 | strbuf_setlen(path, len); |
| 30 | } |
| 31 | |
| 32 | /* get (and remove) the next component in 'remaining' and place it in 'next' */ |
| 33 | static void get_next_component(struct strbuf *next, struct strbuf *remaining) |
no test coverage detected