changeset 3223:134e82e33716 0.11

Fixed #296: Updated XDG path handling
author unexist
date Wed, 20 Jun 2012 13:29:44 +0200
parents 476e390a9f06
children 627e105ca7d9
files src/subtle/ruby.c
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/subtle/ruby.c	Wed Jun 20 13:27:25 2012 +0200
+++ b/src/subtle/ruby.c	Wed Jun 20 13:29:44 2012 +0200
@@ -2606,14 +2606,14 @@
 
       /* Combine XDG paths */
       if((home = getenv("XDG_CONFIG_HOME")))
-        len += snprintf(tokens, sizeof(tokens), "%s/%s", home, PKG_NAME);
-      else len += snprintf(tokens, sizeof(tokens), "%s/.config/%s",
-        getenv("HOME"), PKG_NAME);
+        len += snprintf(tokens, sizeof(tokens), "%s", home);
+      else len += snprintf(tokens, sizeof(tokens), "%s/.config",
+        getenv("HOME"));
 
       if((dirs = getenv("XDG_CONFIG_DIRS")))
         len += snprintf(tokens + len, sizeof(tokens), ":%s", dirs);
-      else len += snprintf(tokens + len, sizeof(tokens), "%s:%s",
-        tokens, "/etc/xdg");
+      else len += snprintf(tokens + len, sizeof(tokens), ":%s/%s",
+        "/etc/xdg", PKG_NAME);
 
       if((home = getenv("XDG_DATA_HOME")))
         {
@@ -2626,10 +2626,17 @@
       /* Search file in XDG paths */
       while((tok = strsep(&tokensp, ":")))
         {
+          /* Check if config file exists in tok or tok/subtle */
           snprintf(buf, sizeof(buf), "%s/%s", tok, RSTRING_PTR(file));
 
-          if(-1 != access(buf, R_OK)) ///< Check if config file exists
-            break;
+          if(-1 != access(buf, R_OK)) break;
+          else
+            {
+              snprintf(buf, sizeof(buf), "%s/%s/%s",
+                tok, PKG_NAME, RSTRING_PTR(file));
+
+              if(-1 != access(buf, R_OK)) break;
+            }
         }
     }
   else snprintf(buf, sizeof(buf), "%s", RSTRING_PTR(file));