Launcher: Replace ~/ by $HOME/

This commit is contained in:
Philippe Pepiot 2009-10-15 20:49:03 +02:00
parent e723c03fe3
commit 39ef26690c

View File

@ -275,7 +275,17 @@ complete_on_files(char *start, size_t hits)
path = _strdup(".");
else
{
dirname = _strdup(p);
/* remplace ~ by $HOME in dirname */
if (!strncmp(p, "~/", 2) && getenv("HOME"))
asprintf(&dirname, "%s%s", getenv("HOME"), p+1);
else
dirname = _strdup(p);
/* Set p to filename to be complete
* and path the directory containing the file
* /foooooo/baaaaaar/somethinglikethis<tab>
* <---- path - ---><------- p ------>
*/
p = strrchr(dirname, '/');
if (p != dirname)
{