[awesome-menu] rewrite handling of ~ which was too buggy
This commit is contained in:
parent
df8e3abf50
commit
cb525dd4ba
|
@ -193,7 +193,7 @@ get_last_word(char *text)
|
||||||
static Bool
|
static Bool
|
||||||
item_list_fill_file(const char *directory)
|
item_list_fill_file(const char *directory)
|
||||||
{
|
{
|
||||||
char cwd[PATH_MAX], *special_opendir_name = NULL;
|
char cwd[PATH_MAX], *home;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *dirinfo;
|
struct dirent *dirinfo;
|
||||||
item_t *item;
|
item_t *item;
|
||||||
|
@ -203,19 +203,19 @@ item_list_fill_file(const char *directory)
|
||||||
|
|
||||||
if(a_strlen(directory))
|
if(a_strlen(directory))
|
||||||
{
|
{
|
||||||
if(directory[0] == '~')
|
if(!a_strncmp(directory, "~/", 2)
|
||||||
special_opendir_name = getenv("HOME");
|
&& (home = getenv("HOME")))
|
||||||
a_strcpy(cwd, sizeof(cwd), directory);
|
{
|
||||||
|
a_strcpy(cwd, sizeof(cwd), home);
|
||||||
|
a_strcat(cwd, sizeof(cwd), directory + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
a_strcpy(cwd, sizeof(cwd), directory);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
a_strcpy(cwd, sizeof(cwd), ".");
|
a_strcpy(cwd, sizeof(cwd), ".");
|
||||||
|
|
||||||
if(special_opendir_name)
|
if(!(dir = opendir(cwd)))
|
||||||
{
|
|
||||||
if(!(dir = opendir(special_opendir_name)))
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
else if(!(dir = opendir(cwd)))
|
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
while((dirinfo = readdir(dir)))
|
while((dirinfo = readdir(dir)))
|
||||||
|
@ -224,7 +224,7 @@ item_list_fill_file(const char *directory)
|
||||||
len = a_strlen(dirinfo->d_name) + a_strlen(cwd) + 1;
|
len = a_strlen(dirinfo->d_name) + a_strlen(cwd) + 1;
|
||||||
item->data = p_new(char, len);
|
item->data = p_new(char, len);
|
||||||
if(a_strcmp(cwd, "."))
|
if(a_strcmp(cwd, "."))
|
||||||
a_strcpy(item->data, len, cwd);
|
a_strcpy(item->data, len, directory);
|
||||||
a_strcat(item->data, len, dirinfo->d_name);
|
a_strcat(item->data, len, dirinfo->d_name);
|
||||||
item_list_push(&globalconf.items, item);
|
item_list_push(&globalconf.items, item);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue