commit d53205fde766ec7abf69088ee247e316d9a0118a
Author: Oswald Buddenhagen <o...@kde.org>
Date:   Sun Mar 24 11:10:59 2013 +0100

    make path expansion match docu: paths are relative to ~
    
    the current behavior of being relative to the current directory sort of
    makes no sense, and contradicts the docu.
    (cherry picked from commit 56db48d31b62cef3fbf6bb718319ccc46add4167)

 src/config.c |    2 +-
 src/util.c   |   15 +++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/config.c b/src/config.c
index d8f9b52..c671c30 100644
--- a/src/config.c
+++ b/src/config.c
@@ -163,7 +163,7 @@ getopt_helper( conffile_t *cfile, int *cops, int *mops, int 
*sops, char **sync_s
                while ((arg = next_arg( &cfile->rest )));
                *mops |= XOP_HAVE_CREATE;
        } else if (!strcasecmp( "SyncState", cfile->cmd ))
-               *sync_state = expand_strdup( cfile->val );
+               *sync_state = !strcmp( cfile->val, "*" ) ? nfstrdup( "*" ) : 
expand_strdup( cfile->val );
        else
                return 0;
        return 1;
diff --git a/src/util.c b/src/util.c
index 6fb43c2..4f6a353 100644
--- a/src/util.c
+++ b/src/util.c
@@ -303,24 +303,35 @@ expand_strdup( const char *s )
        if (*s == '~') {
                s++;
                if (!*s) {
+                 rethome:
                        p = 0;
                        q = Home;
                } else if (*s == '/') {
-                       p = s;
+                       p = s + 1;
                        q = Home;
                } else {
                        if ((p = strchr( s, '/' ))) {
                                r = my_strndup( s, (int)(p - s) );
                                pw = getpwnam( r );
                                free( r );
+                               p++;
                        } else
                                pw = getpwnam( s );
                        if (!pw)
                                return 0;
                        q = pw->pw_dir;
                }
-               nfasprintf( &r, "%s%s", q, p ? p : "" );
+               if (!p)
+                       return nfstrdup( q );
+         retjoin:
+               nfasprintf( &r, "%s/%s", q, p );
                return r;
+       } else if (*s != '/') {
+               if (*s == '.' && !s[1])
+                       goto rethome;
+               p = s;
+               q = Home;
+               goto retjoin;
        } else
                return nfstrdup( s );
 }

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to