X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=obt%2Fpaths.c;h=68615433e1d9426dc58cdf462050cbe89937cf6c;hb=3bd4397b6ec5212bfe53a36892746962dc45dbeb;hp=6100499893e306a3dce92cd1fd041f49c20c85c2;hpb=163950b23bf796a39870044417ca54d667b6b470;p=chaz%2Fopenbox diff --git a/obt/paths.c b/obt/paths.c index 61004998..68615433 100644 --- a/obt/paths.c +++ b/obt/paths.c @@ -169,14 +169,16 @@ void obt_paths_unref(ObtPaths *p) gchar *obt_paths_expand_tilde(const gchar *f) { - gchar **spl; gchar *ret; + GRegex *regex; if (!f) return NULL; - spl = g_strsplit(f, "~", 0); - ret = g_strjoinv(g_get_home_dir(), spl); - g_strfreev(spl); + + regex = g_regex_new("(?:^|(?<=[ \\t]))~(?=[/ \\t$])", G_REGEX_MULTILINE | G_REGEX_RAW, 0, NULL); + ret = g_regex_replace_literal(regex, f, -1, 0, g_get_home_dir(), 0, NULL); + g_regex_unref(regex); + return ret; }