diff options
author | Andreas Schneider <asn@samba.org> | 2014-02-17 11:32:14 +0100 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2014-02-19 18:22:30 +0100 |
commit | 3b207dc0f3ef642ec5f16bc1dbce7c018c89cf55 (patch) | |
tree | 081c0b525d574ce7127d7098c61f6eef3873e62d /source3/client/clitar.c | |
parent | ef150e7dfa17bd0b6432ac8b5e1a6afd055edb17 (diff) | |
download | samba-3b207dc0f3ef642ec5f16bc1dbce7c018c89cf55.tar.gz samba-3b207dc0f3ef642ec5f16bc1dbce7c018c89cf55.tar.xz samba-3b207dc0f3ef642ec5f16bc1dbce7c018c89cf55.zip |
s3-clitar: Improve readabilty of fix_unix_path().
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Diffstat (limited to 'source3/client/clitar.c')
-rw-r--r-- | source3/client/clitar.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/source3/client/clitar.c b/source3/client/clitar.c index 8dd69d34335..bad7eac4ad8 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -1662,39 +1662,42 @@ static int max_token (const char *str) * @path: path to convert * @removeprefix: if true, remove leading ./ or /. */ -static char *fix_unix_path (char *path, bool removeprefix) +static char *fix_unix_path (char *path, bool do_remove_prefix) { char *from = path, *to = path; - if (!path || !*path) + if (path == NULL || path[0] == '\0') { return path; + } /* remove prefix: * ./path => path * /path => path */ - if (removeprefix) { + if (do_remove_prefix) { /* /path */ if (path[0] == '/' || path[0] == '\\') { from += 1; } /* ./path */ - if (path[1] && path[0] == '.' && (path[1] == '/' || path[1] == '\\')) { + if (path[1] != '\0' && path[0] == '.' && (path[1] == '/' || path[1] == '\\')) { from += 2; } } /* replace / with \ */ - while (*from) { - if (*from == '/') { - *to = '\\'; + while (from[0] != '\0') { + if (from[0] == '/') { + to[0] = '\\'; } else { - *to = *from; + to[0] = from[0]; } - from++; to++; + + from++; + to++; } - *to = 0; + to[0] = '\0'; return path; } |