isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit da5ce5d8f42a15a2842d6d14043452f1a7892a0a
parent 312f4be4b28564d7de3264d49504431b71676f7b
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Sun, 24 Mar 2013 11:10:59 +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.

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

diff --git a/src/config.c b/src/config.c @@ -219,7 +219,7 @@ getopt_helper( conffile_t *cfile, int *cops, int ops[], char **sync_state ) while ((arg = get_arg( cfile, ARG_OPTIONAL, 0 ))); ops[M] |= 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 @@ -337,24 +337,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 ); }