X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fpath-concat.c;h=d6dafc939850ad1467f2612f88649364313e642a;hb=49c86fdb3d58fc15ae14f804e0f69b681ff4fb70;hp=ac2c8b8d512563e3299eb65f1ba698238f2e8bf6;hpb=e704e54e6aef6e1a319b727a1d6c847f0fec74aa;p=gnulib.git diff --git a/lib/path-concat.c b/lib/path-concat.c index ac2c8b8d5..d6dafc939 100644 --- a/lib/path-concat.c +++ b/lib/path-concat.c @@ -32,7 +32,9 @@ #include char *malloc (); +#ifndef strdup char *strdup (); +#endif #ifndef DIRECTORY_SEPARATOR # define DIRECTORY_SEPARATOR '/' @@ -84,10 +86,13 @@ path_concat (const char *dir, const char *base, char **base_in_result) p = mempcpy (p_concat, dir, dir_len); - if (ISSLASH (*(p - 1)) && ISSLASH(*base)) - --p; - else if (!ISSLASH (*(p - 1)) && !ISSLASH(*base)) - *p++ = DIRECTORY_SEPARATOR; + if (dir_len > 0) + { + if (ISSLASH (*(p - 1)) && ISSLASH(*base)) + --p; + else if (!ISSLASH (*(p - 1)) && !ISSLASH(*base)) + *p++ = DIRECTORY_SEPARATOR; + } if (base_in_result) *base_in_result = p;