pkg: pkg_get_parent_dir() should fall back to '/' directory separator if necessary

Some environments such as the MingW-MSYS shell environment use both \ and / as directory
separators, thusly we should fall back to the POSIX directory separator.  Both directory
separators are fully supported by Windows.
feature/tap-sh
William Pitcock 2012-09-14 15:42:06 -05:00
parent 847ddbbc22
commit 3867a66434
1 changed files with 4 additions and 1 deletions

5
pkg.c
View File

@ -131,7 +131,10 @@ pkg_get_parent_dir(pkg_t *pkg)
char *pathbuf;
strlcpy(buf, pkg->filename, sizeof buf);
if ((pathbuf = strrchr(buf, PKG_DIR_SEP_S)) != NULL)
pathbuf = strrchr(buf, PKG_DIR_SEP_S);
if (pathbuf == NULL)
pathbuf = strrchr(buf, '/');
if (pathbuf != NULL)
pathbuf[0] = '\0';
return buf;