~alpine/aports

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[alpine-aports] [PATCH] testing/i3wm: expand tilde in config path

Mark White <mark@celos.net>
Details
Message ID
<1454967500-24549-1-git-send-email-mark@celos.net>
Sender timestamp
1454967500
DKIM signature
missing
Download raw message
Patch: +37 -15
Expand ~ to $HOME if path begins with "~/". Not a complete GLOB_TILDE,
but fixes current use of literal "$HOME/~/.config/i3" by default.

fixes #5078
---
 testing/i3wm/APKBUILD   |    6 +++---
 testing/i3wm/musl.patch |   46 ++++++++++++++++++++++++++++++++++------------
 2 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/testing/i3wm/APKBUILD b/testing/i3wm/APKBUILD
index 57597b6..5089cc8 100644
--- a/testing/i3wm/APKBUILD
+++ b/testing/i3wm/APKBUILD
@@ -42,8 +42,8 @@ package() {
}

md5sums="6b003955333a90cb831516f8dbf6e57d  i3-4.11.tar.bz2
c111abf5d38d2ad356923047a47f6a65  musl.patch"
aa998beb0b9a83d2910508768ac7faae  musl.patch"
sha256sums="78ce1e06fbd92fd63765bbe23faa7b8f929c17f99ed623f7abf2e568169d982f  i3-4.11.tar.bz2
626886ec7edfa768b4ab8cb9eaef4b3944e0a7cac2bb6748b7ce2622c409d08a  musl.patch"
b7d084c53addc71fda13ccb8b3dcca2a32d9ca1590a28bf3be1a0c61870d3817  musl.patch"
sha512sums="76d45be9006973dd4093fd21ea1c83742b7977c7698e133ce8f9e7826d97d1631fbe6c3ea4a7eb3d989027f98e12738158e72ec450b0df3dddd28f912ff49a4f  i3-4.11.tar.bz2
b3d2947f95b83f4421b54899d6411d93124828fcb06d6777330db523b8a101ab425bc3201c1aaed00206b468320c85617a6e0657427a7a1aec4d671082aa6494  musl.patch"
8ce7d00371c43b93dabbe0dadf9caf7c58a68f4a0079f5a9b9552c15c55bfa0df16d7e87a281595af2ac5254632ba28ccf82a467cea16159b41490f6f2910299  musl.patch"
diff --git a/testing/i3wm/musl.patch b/testing/i3wm/musl.patch
index 56feaa9..82ad619 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);
 }
-- 
1.7.10.4



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---

[alpine-aports] [PATCH v2] testing/i3wm: expand tilde in config path

Mark White <mark@celos.net>
Details
Message ID
<1455010588-29779-1-git-send-email-mark@celos.net>
In-Reply-To
<1454967500-24549-1-git-send-email-mark@celos.net> (view parent)
Sender timestamp
1455010588
DKIM signature
missing
Download raw message
Patch: +38 -16
Expand ~ to $HOME if path begins with "~/". Not a complete GLOB_TILDE,
but fixes current default use of literal "$HOME/~/.config/i3".

fixes #5078
---
Changes v1 -> v2:
 - increment pkgrel (forgot, oops)

 testing/i3wm/APKBUILD   |    8 ++++----
 testing/i3wm/musl.patch |   46 ++++++++++++++++++++++++++++++++++------------
 2 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/testing/i3wm/APKBUILD b/testing/i3wm/APKBUILD
index 57597b6..03a4368 100644
--- a/testing/i3wm/APKBUILD
+++ b/testing/i3wm/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=i3wm
pkgver=4.11
pkgrel=0
pkgrel=1
pkgdesc="A tiling window manager"
url="http://i3wm.org"
arch="all"
@@ -42,8 +42,8 @@ package() {
}

md5sums="6b003955333a90cb831516f8dbf6e57d  i3-4.11.tar.bz2
c111abf5d38d2ad356923047a47f6a65  musl.patch"
aa998beb0b9a83d2910508768ac7faae  musl.patch"
sha256sums="78ce1e06fbd92fd63765bbe23faa7b8f929c17f99ed623f7abf2e568169d982f  i3-4.11.tar.bz2
626886ec7edfa768b4ab8cb9eaef4b3944e0a7cac2bb6748b7ce2622c409d08a  musl.patch"
b7d084c53addc71fda13ccb8b3dcca2a32d9ca1590a28bf3be1a0c61870d3817  musl.patch"
sha512sums="76d45be9006973dd4093fd21ea1c83742b7977c7698e133ce8f9e7826d97d1631fbe6c3ea4a7eb3d989027f98e12738158e72ec450b0df3dddd28f912ff49a4f  i3-4.11.tar.bz2
b3d2947f95b83f4421b54899d6411d93124828fcb06d6777330db523b8a101ab425bc3201c1aaed00206b468320c85617a6e0657427a7a1aec4d671082aa6494  musl.patch"
8ce7d00371c43b93dabbe0dadf9caf7c58a68f4a0079f5a9b9552c15c55bfa0df16d7e87a281595af2ac5254632ba28ccf82a467cea16159b41490f6f2910299  musl.patch"
diff --git a/testing/i3wm/musl.patch b/testing/i3wm/musl.patch
index 56feaa9..82ad619 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);
 }
-- 
1.7.10.4



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
Reply to thread Export thread (mbox)