X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftal%2Fpath%2Fpath.c;h=b50120667c0759649d35292578f627ef644988c3;hb=7d1f0c73e4d321561abb74f82c8be97f10d69836;hp=a0dbe291440e248fba0faddf6a70bf0062c0c009;hpb=ba57295a55704ad68f46f7ee741dc8f3ac9db6af;p=ccan diff --git a/ccan/tal/path/path.c b/ccan/tal/path/path.c index a0dbe291..b5012066 100644 --- a/ccan/tal/path/path.c +++ b/ccan/tal/path/path.c @@ -1,7 +1,6 @@ /* Licensed under BSD-MIT - see LICENSE file for details */ #include #include -#include #include #include #include @@ -12,9 +11,6 @@ #include #include -#define PATH_SEP_STR "/" -#define PATH_SEP (PATH_SEP_STR[0]) - char *path_cwd(const tal_t *ctx) { size_t len = 64; @@ -50,10 +46,10 @@ char *path_join(const tal_t *ctx, const char *base, const char *a) goto out; len = strlen(base); - ret = tal_dup(ctx, char, base, len, 1 + strlen(a) + 1); + ret = tal_dup_arr(ctx, char, base, len, 1 + strlen(a) + 1); if (!ret) goto out; - if (ret[len-1] != PATH_SEP) + if (len != 0 && ret[len-1] != PATH_SEP) ret[len++] = PATH_SEP; strcpy(ret + len, a); @@ -465,7 +461,7 @@ char *path_basename(const tal_t *ctx, const char *path) static char *fixed_string(const tal_t *ctx, const char *str, const char *path) { - char *ret = tal_dup(ctx, char, path, 0, strlen(str)+1); + char *ret = tal_dup_arr(ctx, char, path, 0, strlen(str)+1); if (ret) strcpy(ret, str); return ret;