From bae5bf798a5b797fc7a66fbfb4f1ae2576d0763a Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 28 Apr 2008 12:35:29 +0200 Subject: [PATCH] Remove trailing slashed fo the uris. --- src/csync.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/csync.c b/src/csync.c index 6af2bbd33c..178b56cce1 100644 --- a/src/csync.c +++ b/src/csync.c @@ -42,18 +42,27 @@ int csync_create(CSYNC **csync, const char *local, const char *remote) { CSYNC *ctx; + size_t len = 0; ctx = c_malloc(sizeof(CSYNC)); if (ctx == NULL) { return -1; } - ctx->local.uri = c_strdup(local); + /* remove trailing slashes */ + len = strlen(local); + while(len > 0 && local[len - 1] == '/') --len; + + ctx->local.uri = c_strndup(local, len); if (ctx->local.uri == NULL) { return -1; } - ctx->remote.uri = c_strdup(remote); + /* remove trailing slashes */ + len = strlen(remote); + while(len > 0 && remote[len - 1] == '/') --len; + + ctx->remote.uri = c_strndup(remote, len); if (ctx->remote.uri == NULL) { SAFE_FREE(ctx->remote.uri); return -1;