A bit of refactoring

This commit is contained in:
o9000
2017-12-21 11:57:49 +01:00
parent f4384b786c
commit 5dd814773a
2 changed files with 30 additions and 15 deletions

View File

@@ -483,10 +483,10 @@ char *contract_tilde(const char *s)
strlcat(home_slash, "/", buf_size);
if ((strcmp(s, home) == 0 || strstr(s, home_slash) == s)) {
size_t buf_size = strlen(s) - strlen(home) + 2;
char *result = calloc(buf_size, 1);
strlcat(result, "~", buf_size);
strlcat(result, s + strlen(home), buf_size);
size_t buf_size2 = strlen(s) - strlen(home) + 2;
char *result = calloc(buf_size2, 1);
strlcat(result, "~", buf_size2);
strlcat(result, s + strlen(home), buf_size2);
free(home_slash);
return result;
} else {