diff options
author | Luis Ressel <aranea@aixah.de> | 2019-01-27 09:01:03 +0100 |
---|---|---|
committer | Luis Ressel <aranea@aixah.de> | 2019-02-04 19:02:05 +0100 |
commit | 86bc76ab639608f85d71c8858173661ae2726c95 (patch) | |
tree | 65fd1bbf54dea8eb163559ca68dee9508904aa35 /user/i3status/glob_tilde.patch | |
parent | a993427bebef75d184f5fbe04d29093db76e0f38 (diff) | |
download | packages-86bc76ab639608f85d71c8858173661ae2726c95.tar.gz packages-86bc76ab639608f85d71c8858173661ae2726c95.tar.bz2 packages-86bc76ab639608f85d71c8858173661ae2726c95.tar.xz packages-86bc76ab639608f85d71c8858173661ae2726c95.zip |
user/i3status: New package
Diffstat (limited to 'user/i3status/glob_tilde.patch')
-rw-r--r-- | user/i3status/glob_tilde.patch | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/user/i3status/glob_tilde.patch b/user/i3status/glob_tilde.patch new file mode 100644 index 000000000..b1f2ba667 --- /dev/null +++ b/user/i3status/glob_tilde.patch @@ -0,0 +1,59 @@ +diff --git i/i3status.c w/i3status.c +index 5088c96..3c18214 100644 +--- i/i3status.c ++++ w/i3status.c +@@ -210,29 +210,19 @@ static int valid_color(const char *value) { + * + */ + static char *resolve_tilde(const char *path) { +- static glob_t globbuf; +- char *head, *tail, *result = NULL; +- +- tail = strchr(path, '/'); +- head = strndup(path, tail ? (size_t)(tail - path) : strlen(path)); +- +- int res = glob(head, GLOB_TILDE, NULL, &globbuf); +- free(head); +- /* no match, or many wildcard matches are bad */ +- if (res == GLOB_NOMATCH || globbuf.gl_pathc != 1) +- result = sstrdup(path); +- else if (res != 0) { +- die("glob() failed"); +- } else { +- head = globbuf.gl_pathv[0]; +- result = scalloc(strlen(head) + (tail ? strlen(tail) : 0) + 1); +- strncpy(result, head, strlen(head)); +- if (tail) +- strncat(result, tail, strlen(tail)); ++ char *home, *result = NULL; ++ ++ if (strncmp(path, "~/", 2) == 0) { ++ home = getenv("HOME"); ++ if (home != NULL) { ++ result = scalloc(strlen(home) + strlen(path)); ++ strcpy(result, home); ++ strcat(result, path+1); ++ return result; ++ } + } +- globfree(&globbuf); + +- return result; ++ return sstrdup(path); + } + + static char *get_config_path(void) { +diff --git i/include/i3status.h w/include/i3status.h +index 9ac471d..27ecae4 100644 +--- i/include/i3status.h ++++ w/include/i3status.h +@@ -236,4 +236,9 @@ extern cfg_t *cfg, *cfg_general, *cfg_section; + extern void **cur_instance; + + extern pthread_t main_thread; ++ ++#ifndef GLOB_TILDE ++#define GLOB_TILDE 0 ++#endif ++ + #endif |