diff options
author | Mark White <mark@celos.net> | 2016-02-09 09:36:28 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2016-02-15 10:42:08 +0000 |
commit | 5d7a4ebb42c965c69c944e69b1a0a3a56eb5ed53 (patch) | |
tree | 17a83723468de9e7c97c046c63710ddc1b911279 /testing/i3wm/musl.patch | |
parent | 7f00c15878265d146be084435d3509c2cf44ebfe (diff) | |
download | aports-5d7a4ebb42c965c69c944e69b1a0a3a56eb5ed53.tar.bz2 aports-5d7a4ebb42c965c69c944e69b1a0a3a56eb5ed53.tar.xz |
testing/i3wm: expand tilde in config path
Expand ~ to $HOME if path begins with "~/". Not a complete GLOB_TILDE,
but fixes current default use of literal "$HOME/~/.config/i3".
fixes #5078
Diffstat (limited to 'testing/i3wm/musl.patch')
-rw-r--r-- | testing/i3wm/musl.patch | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/testing/i3wm/musl.patch b/testing/i3wm/musl.patch index 56feaa9814..82ad6195b8 100644 --- a/testing/i3wm/musl.patch +++ b/testing/i3wm/musl.patch @@ -1,7 +1,7 @@ -diff -upr i3-4.11.orig/i3bar/src/main.c i3-4.11/i3bar/src/main.c ---- i3-4.11.orig/i3bar/src/main.c 2015-10-06 22:45:01.791199587 +0200 -+++ i3-4.11/i3bar/src/main.c 2015-10-06 22:45:52.921029327 +0200 -@@ -45,14 +45,7 @@ void debuglog(char *fmt, ...) { +diff -urp i3-4.11/i3bar/src/main.c i3-4.11.new/i3bar/src/main.c +--- i3-4.11/i3bar/src/main.c 2015-09-30 07:55:10.000000000 +0100 ++++ i3-4.11.new/i3bar/src/main.c 2016-02-08 20:03:41.777392482 +0000 +@@ -45,14 +45,20 @@ void debuglog(char *fmt, ...) { * */ char *expand_path(char *path) { @@ -9,24 +9,37 @@ diff -upr i3-4.11.orig/i3bar/src/main.c i3-4.11/i3bar/src/main.c - if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0) { - ELOG("glob() failed\n"); - exit(EXIT_FAILURE); -- } ++ char *home, *expanded; ++ ++ if (strncmp(path, "~/", 2) == 0) { ++ home = getenv("HOME"); ++ if (home != NULL) { ++ /* new length: sum - 1 (omit '~') + 1 (for '\0') */ ++ expanded = scalloc(strlen(home)+strlen(path), 1); ++ strcpy(expanded, home); ++ strcat(expanded, path+1); ++ return expanded; ++ } + } - char *result = sstrdup(globbuf.gl_pathc > 0 ? globbuf.gl_pathv[0] : path); - globfree(&globbuf); - return result; ++ + return sstrdup(path); } void print_usage(char *elf_name) { -diff -upr i3-4.11.orig/libi3/resolve_tilde.c i3-4.11/libi3/resolve_tilde.c ---- i3-4.11.orig/libi3/resolve_tilde.c 2015-10-06 22:45:01.801199553 +0200 -+++ i3-4.11/libi3/resolve_tilde.c 2015-10-06 22:46:32.874229612 +0200 -@@ -19,27 +19,5 @@ +diff -urp i3-4.11/libi3/resolve_tilde.c i3-4.11.new/libi3/resolve_tilde.c +--- i3-4.11/libi3/resolve_tilde.c 2015-09-30 07:55:10.000000000 +0100 ++++ i3-4.11.new/libi3/resolve_tilde.c 2016-02-08 20:03:47.849230953 +0000 +@@ -19,27 +19,18 @@ * */ char *resolve_tilde(const char *path) { - static glob_t globbuf; - char *head, *tail, *result; -- ++ char *home, *expanded; + - tail = strchr(path, '/'); - head = sstrndup(path, tail ? (size_t)(tail - path) : strlen(path)); - @@ -43,9 +56,18 @@ diff -upr i3-4.11.orig/libi3/resolve_tilde.c i3-4.11/libi3/resolve_tilde.c - strncpy(result, head, strlen(head)); - if (tail) - strncat(result, tail, strlen(tail)); -- } ++ if (strncmp(path, "~/", 2) == 0) { ++ home = getenv("HOME"); ++ if (home != NULL) { ++ /* new length: sum - 1 (omit '~') + 1 (for '\0') */ ++ expanded = scalloc(strlen(home)+strlen(path), 1); ++ strcpy(expanded, home); ++ strcat(expanded, path+1); ++ return expanded; ++ } + } - globfree(&globbuf); -- + - return result; + return sstrdup(path); } |