/* path-concat.c -- concatenate two arbitrary pathnames
- Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <sys/types.h>
char *malloc ();
+#ifndef strdup
+char *strdup ();
+#endif
#ifndef DIRECTORY_SEPARATOR
# define DIRECTORY_SEPARATOR '/'
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;