From: Daniel Carl Date: Thu, 5 Jun 2014 21:46:42 +0000 (+0200) Subject: Fixed trailing / in ~/ expansion. X-Git-Url: https://git.owens.tech/style.css/style.css/git?a=commitdiff_plain;h=38b7d109ea5e38a25c51789315ce7174d19a6c3f;p=vimb.git Fixed trailing / in ~/ expansion. If ~/ was expanded the path had a trailing / but according to the shell this should end up in directory without a slash. --- diff --git a/src/util.c b/src/util.c index 0dcd0c3..94edd7c 100644 --- a/src/util.c +++ b/src/util.c @@ -398,6 +398,11 @@ gboolean util_parse_expansion(const char **input, GString *str, int flags, if (**input == '/') { g_string_append(str, util_get_home_dir()); expanded = true; + /* if there is no char or space after ~/ skip the / to get + * /home/user instead of /home/user/ */ + if (!*(*input + 1) || VB_IS_SPACE(*(*input + 1))) { + (*input)++; + } } else { /* look ahead to / space or end of string to get a possible * username for ~user pattern */ @@ -468,9 +473,10 @@ gboolean util_parse_expansion(const char **input, GString *str, int flags, if (**input == quote) { /* move pointer to the next char */ (*input)++; - if (!*input) { + if (!**input) { /* if input ends here - use only the quote char */ g_string_append_c(str, quote); + (*input)--; } else if (strchr(quoteable, **input) || (flags & UTIL_EXP_TILDE && **input == '~') || (flags & UTIL_EXP_DOLLAR && **input == '$')