diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-08-17 23:08:11 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-08-17 23:08:11 -0400 |
commit | d067ad66ac2b6eb22eef3bfb7efa0007b7af9e5b (patch) | |
tree | 2514ad0e09eaacd59641974c823f194d3abd3140 /src/nvim/path.c | |
parent | 16a04bae0a91e00d120b6fdd8e24b620b9859c87 (diff) | |
parent | d2988e12fe577bcb6e91be359049b1355fa51aed (diff) | |
download | rneovim-d067ad66ac2b6eb22eef3bfb7efa0007b7af9e5b.tar.gz rneovim-d067ad66ac2b6eb22eef3bfb7efa0007b7af9e5b.tar.bz2 rneovim-d067ad66ac2b6eb22eef3bfb7efa0007b7af9e5b.zip |
Merge pull request #977 from splinterofchaos/fish
vim-patch:7.4.276
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r-- | src/nvim/path.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c index dbbb77a8e9..2d819b39a4 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -131,6 +131,35 @@ char_u *path_tail_with_sep(char_u *fname) return tail; } +/// Finds the path tail (or executable) in an invocation. +/// +/// @param[in] invocation A program invocation in the form: +/// "path/to/exe [args]". +/// @param[out] len Stores the length of the executable name. +/// +/// @post if `len` is not null, stores the length of the executable name. +/// +/// @return The position of the last path separator + 1. +const char_u *invocation_path_tail(const char_u *invocation, size_t *len) + FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1) +{ + const char_u *tail = get_past_head((char_u *) invocation); + const char_u *p = tail; + while (*p != NUL && *p != ' ') { + bool was_sep = vim_ispathsep_nocolon(*p); + mb_ptr_adv(p); + if (was_sep) { + tail = p; // Now tail points one past the separator. + } + } + + if (len != NULL) { + *len = (size_t)(p - tail); + } + + return tail; +} + /// Get the next path component of a path name. /// /// @param fname A file path. (Must be != NULL.) |