X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ftpath.c;h=0fdf529a359882ff70e4f5d48a60525399c3138b;hp=520038020ac2b565545e03b4f3e7376db47d5de6;hb=6f3861dbfb754ceffb8587c64e7631ae6ca3b650;hpb=68db5d6050f959bd126eec404447019b6176d2a1 diff --git a/src/tpath.c b/src/tpath.c index 5200380..0fdf529 100644 --- a/src/tpath.c +++ b/src/tpath.c @@ -1,12 +1,12 @@ /* - * Copyright (C) 1995-2005, Index Data ApS + * Copyright (C) 1995-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: tpath.c,v 1.7 2006-04-26 09:40:43 adam Exp $ + * $Id: tpath.c,v 1.10 2006-06-08 10:26:10 adam Exp $ */ /** * \file tpath.c - * \brief Implements path fopen + * \brief File Path utilities */ #if HAVE_CONFIG_H @@ -20,9 +20,7 @@ #include #include #include -#if HAVE_SYS_STAT_H #include -#endif #if HAVE_UNISTD_H #include #endif @@ -64,15 +62,17 @@ char *yaz_filepath_resolve(const char *fname, const char *path, len = path_sep - path; else len = strlen(path); + /* is path is relative and base is to be used */ if (!strchr ("/\\", *path) && base) { + /* yes: make base the first part */ strcpy (fullpath, base); slen = strlen(fullpath); fullpath[slen++] = '/'; } memcpy (fullpath+slen, path, len); slen += len; - if (!strchr("/\\", fullpath[slen-1])) + if (slen > 0 && !strchr("/\\", fullpath[slen-1])) fullpath[slen++] = '/'; } strcpy (fullpath+slen, fname);