]> Dogcows Code - chaz/openbox/blobdiff - obt/paths.c
Merge branch 'backport' into work
[chaz/openbox] / obt / paths.c
index 6100499893e306a3dce92cd1fd041f49c20c85c2..68615433e1d9426dc58cdf462050cbe89937cf6c 100644 (file)
@@ -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;
 }
 
This page took 0.022588 seconds and 4 git commands to generate.