]> Dogcows Code - chaz/openbox/blobdiff - parser/parse.c
Don't replace ~ when we shouldn't
[chaz/openbox] / parser / parse.c
index 636b451f2b5d3a937b76279ebdf971bc3b767655..ed66f088f6ba33f715b805fce01a25e5123a427e 100644 (file)
@@ -456,14 +456,16 @@ void parse_paths_shutdown(void)
 
 gchar *parse_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.02659 seconds and 4 git commands to generate.